Merge pull request #1432 from mailpoet/forms-delete-at
Forms delete acceptance test [MQ-50]
This commit is contained in:
@@ -29,6 +29,7 @@ class ListingGroups extends React.Component {
|
|||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
className={classes}
|
className={classes}
|
||||||
onClick={() => this.handleSelect(group.name)}
|
onClick={() => this.handleSelect(group.name)}
|
||||||
|
data-automation-id={`filters_${group.label.replace(' ', '_').toLowerCase()}`}
|
||||||
>
|
>
|
||||||
{group.label}
|
{group.label}
|
||||||
<span className="count">({ parseInt(group.count, 10).toLocaleString() })</span>
|
<span className="count">({ parseInt(group.count, 10).toLocaleString() })</span>
|
||||||
|
@@ -28,13 +28,16 @@ modules:
|
|||||||
adminPath: /wp-admin
|
adminPath: /wp-admin
|
||||||
log_js_errors: true
|
log_js_errors: true
|
||||||
WPLoader:
|
WPLoader:
|
||||||
loadOnly: true
|
loadOnly: false
|
||||||
wpRootFolder: /wp-core
|
wpRootFolder: /wp-core
|
||||||
dbName: wordpress
|
dbName: wordpress
|
||||||
dbHost: mysql
|
dbHost: mysql
|
||||||
dbUser: wordpress
|
dbUser: wordpress
|
||||||
dbPassword: wordpress
|
dbPassword: wordpress
|
||||||
domain: wordpress
|
domain: wordpress
|
||||||
|
tablePrefix: 'mp_'
|
||||||
|
plugins: ['mailpoet/mailpoet.php']
|
||||||
|
activatePlugins: ['mailpoet/mailpoet.php']
|
||||||
WPDb:
|
WPDb:
|
||||||
dsn: 'mysql:host=mysql;dbname=wordpress'
|
dsn: 'mysql:host=mysql;dbname=wordpress'
|
||||||
user: wordpress
|
user: wordpress
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
version: '2'
|
version: '2.1'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
codeception:
|
codeception:
|
||||||
build: .
|
build: .
|
||||||
depends_on:
|
depends_on:
|
||||||
- mailhog
|
mailhog:
|
||||||
- wordpress
|
condition: service_started
|
||||||
|
wordpress:
|
||||||
|
condition: service_healthy
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/project
|
- ./:/project
|
||||||
- wp-core:/wp-core
|
- wp-core:/wp-core
|
||||||
@@ -22,8 +24,10 @@ services:
|
|||||||
build: ./tests/wordpressDockerfile
|
build: ./tests/wordpressDockerfile
|
||||||
image: wordpress:latest
|
image: wordpress:latest
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
mysql:
|
||||||
- chrome
|
condition: service_healthy
|
||||||
|
chrome:
|
||||||
|
condition: service_started
|
||||||
volumes:
|
volumes:
|
||||||
- wp-core:/var/www/html
|
- wp-core:/var/www/html
|
||||||
- ./:/var/www/html/wp-content/plugins/mailpoet
|
- ./:/var/www/html/wp-content/plugins/mailpoet
|
||||||
@@ -35,13 +39,23 @@ services:
|
|||||||
WORDPRESS_DB_USER: wordpress
|
WORDPRESS_DB_USER: wordpress
|
||||||
WORDPRESS_DB_NAME: wordpress
|
WORDPRESS_DB_NAME: wordpress
|
||||||
WORDPRESS_TABLE_PREFIX: mp_
|
WORDPRESS_TABLE_PREFIX: mp_
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost"]
|
||||||
|
interval: 1m30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:5.6
|
image: mysql:5.6
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: wordpress
|
MYSQL_ROOT_PASSWORD: wordpress
|
||||||
MYSQL_DATABASE: wordpress
|
MYSQL_DATABASE: wordpress
|
||||||
MYSQL_USER: wordpress
|
MYSQL_USER: wordpress
|
||||||
MYSQL_PASSWORD: wordpress
|
MYSQL_PASSWORD: wordpress
|
||||||
|
healthcheck:
|
||||||
|
test: mysql --user=wordpress --password=wordpress -e 'SELECT 1'
|
||||||
|
timeout: 20s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
chrome:
|
chrome:
|
||||||
environment:
|
environment:
|
||||||
@@ -53,4 +67,4 @@ services:
|
|||||||
- 4444
|
- 4444
|
||||||
- 5900:5900
|
- 5900:5900
|
||||||
volumes:
|
volumes:
|
||||||
wp-core:
|
wp-core:
|
||||||
|
35
tests/DataFactories/Form.php
Normal file
35
tests/DataFactories/Form.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Test\DataFactories;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class Form {
|
||||||
|
|
||||||
|
private $data;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->data = [
|
||||||
|
'name' => 'New form',
|
||||||
|
'body' => 'a:2:{i:0;a:5:{s:2:"id";s:5:"email";s:4:"name";s:5:"Email";s:4:"type";s:4:"text";s:6:"static";b:1;s:6:"params";a:2:{s:5:"label";s:5:"Email";s:8:"required";b:1;}}i:1;a:5:{s:2:"id";s:6:"submit";s:4:"name";s:6:"Submit";s:4:"type";s:6:"submit";s:6:"static";b:1;s:6:"params";a:1:{s:5:"label";s:10:"Subscribe!";}}}',
|
||||||
|
'settings' => 'a:4:{s:10:"on_success";s:7:"message";s:15:"success_message";s:61:"Check your inbox or spam folder to confirm your subscription.";s:8:"segments";N;s:20:"segments_selected_by";s:5:"admin";}',
|
||||||
|
'created_at' => Carbon::now(),
|
||||||
|
'updated_at' => Carbon::now(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withName($name) {
|
||||||
|
$this->data['name'] = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withDeleted() {
|
||||||
|
$this->data['deleted_at'] = Carbon::now();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create() {
|
||||||
|
\MailPoet\Models\Form::createOrUpdate($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -55,4 +55,10 @@ class AcceptanceTester extends \Codeception\Actor {
|
|||||||
$I->waitForText($page, 5);
|
$I->waitForText($page, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clickItemRowActionByItemName($item_name, $link) {
|
||||||
|
$I = $this;
|
||||||
|
$I->moveMouseOver(['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']);
|
||||||
|
$I->click($link, ['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,4 @@ class FormsCreationCest {
|
|||||||
$I->waitForText('Please select a list.');
|
$I->waitForText('Please select a list.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
70
tests/acceptance/FormsDeletingCest.php
Normal file
70
tests/acceptance/FormsDeletingCest.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Test\Acceptance;
|
||||||
|
|
||||||
|
use MailPoet\Test\DataFactories\Form;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../DataFactories/Form.php';
|
||||||
|
|
||||||
|
class FormsDeletingCest {
|
||||||
|
|
||||||
|
function moveFormToTrash(\AcceptanceTester $I) {
|
||||||
|
$form_name = 'Move to trash form';
|
||||||
|
$form = new Form();
|
||||||
|
$form->withName($form_name)->create();
|
||||||
|
|
||||||
|
$I->wantTo('Move a form to trash');
|
||||||
|
|
||||||
|
$I->login();
|
||||||
|
$I->amOnMailpoetPage('Forms');
|
||||||
|
$I->waitForText($form_name);
|
||||||
|
|
||||||
|
$I->clickItemRowActionByItemName($form_name, 'Move to trash');
|
||||||
|
|
||||||
|
$I->waitForElement('[data-automation-id="filters_trash"]');
|
||||||
|
$I->click('[data-automation-id="filters_trash"]');
|
||||||
|
|
||||||
|
$I->waitForText($form_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreFormFromTrash(\AcceptanceTester $I) {
|
||||||
|
$form_name = 'Restore from trash form';
|
||||||
|
$form = new Form();
|
||||||
|
$form->withName($form_name)->withDeleted()->create();
|
||||||
|
|
||||||
|
$I->wantTo('Restore a form from trash');
|
||||||
|
|
||||||
|
$I->login();
|
||||||
|
$I->amOnMailpoetPage('Forms');
|
||||||
|
|
||||||
|
$I->waitForElement('[data-automation-id="filters_trash"]');
|
||||||
|
$I->click('[data-automation-id="filters_trash"]');
|
||||||
|
$I->waitForText($form_name);
|
||||||
|
|
||||||
|
$I->clickItemRowActionByItemName($form_name, 'Restore');
|
||||||
|
$I->click('[data-automation-id="filters_all"]');
|
||||||
|
$I->waitForText($form_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFormPermanently(\AcceptanceTester $I) {
|
||||||
|
$form_name = 'Delete form permanently';
|
||||||
|
$form = new Form();
|
||||||
|
$form->withName($form_name)->withDeleted()->create();
|
||||||
|
|
||||||
|
$I->wantTo('Delete a form permanently trash');
|
||||||
|
|
||||||
|
$I->login();
|
||||||
|
$I->amOnMailpoetPage('Forms');
|
||||||
|
|
||||||
|
$I->waitForElement('[data-automation-id="filters_trash"]');
|
||||||
|
$I->click('[data-automation-id="filters_trash"]');
|
||||||
|
$I->waitForText($form_name);
|
||||||
|
|
||||||
|
$I->clickItemRowActionByItemName($form_name, 'Delete Permanently');
|
||||||
|
|
||||||
|
$I->waitForText('1 form was permanently deleted.');
|
||||||
|
$I->waitForElementNotVisible($form_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user