Merge pull request #1432 from mailpoet/forms-delete-at

Forms delete acceptance test [MQ-50]
This commit is contained in:
Michelle Shull
2018-07-18 08:26:37 -04:00
committed by GitHub
7 changed files with 140 additions and 13 deletions

View File

@@ -29,6 +29,7 @@ class ListingGroups extends React.Component {
href="javascript:;"
className={classes}
onClick={() => this.handleSelect(group.name)}
data-automation-id={`filters_${group.label.replace(' ', '_').toLowerCase()}`}
>
{group.label}
<span className="count">({ parseInt(group.count, 10).toLocaleString() })</span>

View File

@@ -28,13 +28,16 @@ modules:
adminPath: /wp-admin
log_js_errors: true
WPLoader:
loadOnly: true
loadOnly: false
wpRootFolder: /wp-core
dbName: wordpress
dbHost: mysql
dbUser: wordpress
dbPassword: wordpress
domain: wordpress
tablePrefix: 'mp_'
plugins: ['mailpoet/mailpoet.php']
activatePlugins: ['mailpoet/mailpoet.php']
WPDb:
dsn: 'mysql:host=mysql;dbname=wordpress'
user: wordpress

View File

@@ -1,11 +1,13 @@
version: '2'
version: '2.1'
services:
codeception:
build: .
depends_on:
- mailhog
- wordpress
mailhog:
condition: service_started
wordpress:
condition: service_healthy
volumes:
- ./:/project
- wp-core:/wp-core
@@ -22,8 +24,10 @@ services:
build: ./tests/wordpressDockerfile
image: wordpress:latest
depends_on:
- mysql
- chrome
mysql:
condition: service_healthy
chrome:
condition: service_started
volumes:
- wp-core:/var/www/html
- ./:/var/www/html/wp-content/plugins/mailpoet
@@ -35,13 +39,23 @@ services:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_TABLE_PREFIX: mp_
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 1m30s
timeout: 10s
retries: 3
mysql:
image: mysql:5.6
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
healthcheck:
test: mysql --user=wordpress --password=wordpress -e 'SELECT 1'
timeout: 20s
retries: 10
chrome:
environment:

View 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);
}
}

View File

@@ -55,4 +55,10 @@ class AcceptanceTester extends \Codeception\Actor {
$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']);
}
}

View File

@@ -36,6 +36,4 @@ class FormsCreationCest {
$I->waitForText('Please select a list.');
}
}

View 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);
}
}