Refactor acceptance tests with unified waiting for select2 to load
This commit is contained in:
@@ -90,6 +90,7 @@ class AcceptanceTester extends \Codeception\Actor {
|
||||
*/
|
||||
public function selectOptionInSelect2($value, $element = 'input.select2-search__field') {
|
||||
$I = $this;
|
||||
$I->waitForElement($element);
|
||||
$I->fillField($element, $value);
|
||||
$I->pressKey($element, \WebDriverKeys::ENTER);
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ class EditExistingNewsletterCest {
|
||||
$send_form_element = '[data-automation-id="newsletter_send_form"]';
|
||||
$I->waitForElement($send_form_element);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
$I->click('Save as draft and close');
|
||||
$I->waitForText('Standard newsletter', 5, '[data-automation-id="listing_item_1"]');
|
||||
|
@@ -9,9 +9,6 @@ require_once __DIR__ . '/../DataFactories/Segment.php';
|
||||
require_once __DIR__ . '/../DataFactories/Subscriber.php';
|
||||
|
||||
class ExportSubscribersCest {
|
||||
function __construct() {
|
||||
$this->search_field_element = 'input.select2-search__field';
|
||||
}
|
||||
function exportSubscribers(\AcceptanceTester $I) {
|
||||
$segment_factory = new Segment();
|
||||
$segment_name = 'Hobbyists';
|
||||
@@ -32,4 +29,4 @@ class ExportSubscribersCest {
|
||||
$I->waitForText('3 subscribers were exported. Get the exported file here.', 20);
|
||||
$I->seeNoJSErrors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -81,7 +81,6 @@ class NewsletterCreationCest {
|
||||
$send_form_element = '[data-automation-id="newsletter_send_form"]';
|
||||
$I->waitForElement($send_form_element);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
$I->click('Send');
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ class ReceiveStandardEmailCest {
|
||||
|
||||
function receiveStandardEmail(\AcceptanceTester $I) {
|
||||
$newsletter_title = 'Receive Test';
|
||||
$search_field_element = 'input.select2-search__field';
|
||||
$standard_template = '[data-automation-id=\'select_template_0\']';
|
||||
$title_element = '[data-automation-id=\'newsletter_title\']';
|
||||
$send_form_element = '[data-automation-id="newsletter_send_form"]';
|
||||
@@ -33,9 +32,7 @@ class ReceiveStandardEmailCest {
|
||||
//Choose list and send
|
||||
$I->waitForElement($send_form_element, 30);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$I->waitForElement($search_field_element, 30);
|
||||
$I->fillField($search_field_element, 'WordPress Users');
|
||||
$I->pressKey($search_field_element, \WebDriverKeys::ENTER);
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
$I->click('Send');
|
||||
$I->waitForElement('.mailpoet_progress_label', 90);
|
||||
//confirm newsletter is received
|
||||
|
@@ -34,7 +34,6 @@ class SaveNewsletterAsDraftCest {
|
||||
$send_form_element = '[data-automation-id="newsletter_send_form"]';
|
||||
$I->waitForElement($send_form_element);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
|
||||
$I->click('Save as draft and close');
|
||||
|
@@ -24,7 +24,6 @@ class SaveNotificationAsDraftCest {
|
||||
$send_form_element = '[data-automation-id="newsletter_send_form"]';
|
||||
$I->waitForElement($send_form_element);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
$I->click('Save as draft and close');
|
||||
$I->waitForElement('[data-automation-id="newsletters_listing_tabs"]', 10);
|
||||
|
@@ -24,10 +24,7 @@ class ScheduleNewsletterCest {
|
||||
// step 4 - Choose list and schedule
|
||||
$I->waitForElement('[data-automation-id="newsletter_send_form"]');
|
||||
$I->seeInCurrentUrl('mailpoet-newsletters#/send/');
|
||||
$search_field_element = 'input.select2-search__field';
|
||||
$I->waitForElement('.select2');
|
||||
$I->fillField($search_field_element, 'WordPress Users');
|
||||
$I->pressKey($search_field_element, \WebDriverKeys::ENTER);
|
||||
$I->selectOptionInSelect2('WordPress Users');
|
||||
$I->checkOption('isScheduled');
|
||||
$I->click('select[name=time]');
|
||||
$I->selectOption('form select[name=time]', '6:00');
|
||||
|
@@ -5,10 +5,6 @@ namespace MailPoet\Test\Acceptance;
|
||||
require_once __DIR__ . '/../_data/MailPoetImportList.csv';
|
||||
|
||||
class SubscriberManageImportExportCest {
|
||||
function __construct() {
|
||||
$this->search_field_element = 'input.select2-search__field';
|
||||
}
|
||||
|
||||
function importUsersToSubscribersViaCSV(\AcceptanceTester $I) {
|
||||
$I->wantTo('Import a subscriber list from CSV');
|
||||
$I->login();
|
||||
@@ -21,7 +17,7 @@ class SubscriberManageImportExportCest {
|
||||
$I->attachFile(['css'=>'#file_local'], 'MailPoetImportList.csv');
|
||||
$I->click(['xpath'=>'//*[@id="method_file"]/div/table/tbody/tr[2]/th/a']);
|
||||
//click is to trigger dropdown to display selections
|
||||
$I->click($this->search_field_element);
|
||||
$I->click('input.select2-search__field');
|
||||
//choose My First List
|
||||
$I->click(['xpath'=>'//*[@id="select2-mailpoet_segments_select-results"]/li[2]']);
|
||||
//click next step
|
||||
@@ -50,4 +46,4 @@ class SubscriberManageImportExportCest {
|
||||
$I->waitForText('iii@example.com', 10);
|
||||
$I->seeNoJSErrors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -96,7 +96,6 @@ class SubscriberManagementCest {
|
||||
$I->waitForText('Subscriber', 30);
|
||||
$I->seeInCurrentUrl('mailpoet-subscribers#/edit/');
|
||||
$I->waitForElementNotVisible('.mailpoet_form_loading');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('Cooking');
|
||||
$I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]');
|
||||
$I->seeNoJSErrors();
|
||||
@@ -113,7 +112,6 @@ class SubscriberManagementCest {
|
||||
$I->waitForText('Subscriber', 10);
|
||||
$I->seeInCurrentUrl('mailpoet-subscribers#/edit/');
|
||||
$I->waitForElementNotVisible('.mailpoet_form_loading');
|
||||
$I->waitForElement('.select2');
|
||||
$I->selectOptionInSelect2('Cooking');
|
||||
$I->click('.select2-selection__choice__remove');
|
||||
$I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]');
|
||||
|
Reference in New Issue
Block a user