Create forms delete acceptance tests

[MQ-50]
This commit is contained in:
Pavel Dohnal
2018-07-12 11:41:36 +01:00
parent 255422e908
commit 4229ba87f3
5 changed files with 112 additions and 2 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

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