From 5d14bb42409f00967c18a70e2777cfacdd4bb631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 11 Dec 2018 20:25:28 +0100 Subject: [PATCH 01/18] Fix DuplicatePostNotificationCest - wait for table to finish loading --- tests/acceptance/DuplicatePostNotificationCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/DuplicatePostNotificationCest.php b/tests/acceptance/DuplicatePostNotificationCest.php index 46be5cc183..28c4fa4d47 100644 --- a/tests/acceptance/DuplicatePostNotificationCest.php +++ b/tests/acceptance/DuplicatePostNotificationCest.php @@ -27,6 +27,7 @@ class DuplicatePostNotificationCest { $I->waitForText($newsletter_title, 10); $I->clickItemRowActionByItemName($newsletter_title, 'Duplicate'); $I->waitForText('Copy of ' . $newsletter_title); + $I->waitForElementNotVisible('.mailpoet_listing_loading'); // step 5 - Open Editor $I->clickItemRowActionByItemName('Copy of ' . $newsletter_title, 'Edit'); From f0b65721db6504d411f58e4e5fc5de62bf37ef69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 11 Dec 2018 21:19:40 +0100 Subject: [PATCH 02/18] Fix EditExistingNewsletterCest - wait for select2 to render before selecting value --- tests/acceptance/EditExistingNewsletterCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/EditExistingNewsletterCest.php b/tests/acceptance/EditExistingNewsletterCest.php index 0787d63036..5b5e366439 100644 --- a/tests/acceptance/EditExistingNewsletterCest.php +++ b/tests/acceptance/EditExistingNewsletterCest.php @@ -35,6 +35,7 @@ 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"]'); From cf9f38cdb4eda8c608ef42ac0eeee85c0d8b253c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 11 Dec 2018 21:19:52 +0100 Subject: [PATCH 03/18] Fix NewsletterCreationCest - wait for select2 to render before selecting value --- tests/acceptance/NewsletterCreationCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/NewsletterCreationCest.php b/tests/acceptance/NewsletterCreationCest.php index 1f389b788e..890974e827 100644 --- a/tests/acceptance/NewsletterCreationCest.php +++ b/tests/acceptance/NewsletterCreationCest.php @@ -81,6 +81,7 @@ 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'); } From 83f18493285e41001532c00a08ac47f7843b464f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 11 Dec 2018 21:28:14 +0100 Subject: [PATCH 04/18] Fix SaveNewsletterAsDraftCest - wait for select2 to render before selecting value --- tests/acceptance/SaveNewsletterAsDraftCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/SaveNewsletterAsDraftCest.php b/tests/acceptance/SaveNewsletterAsDraftCest.php index ec90acba08..fb2c59f981 100644 --- a/tests/acceptance/SaveNewsletterAsDraftCest.php +++ b/tests/acceptance/SaveNewsletterAsDraftCest.php @@ -34,6 +34,7 @@ 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'); From 64f6e8c88f4ebf9ddd0c88461e510e02413419bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Tue, 11 Dec 2018 21:32:47 +0100 Subject: [PATCH 05/18] Fix SaveNotificationAsDraftCest - wait for select2 to render before selecting value --- tests/acceptance/SaveNotificationAsDraftCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/SaveNotificationAsDraftCest.php b/tests/acceptance/SaveNotificationAsDraftCest.php index a83a8ec1c7..7a179a8218 100644 --- a/tests/acceptance/SaveNotificationAsDraftCest.php +++ b/tests/acceptance/SaveNotificationAsDraftCest.php @@ -24,6 +24,7 @@ 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); From 1bc31c092742a49615c3f8fffcbdf3ff046e3ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 08:56:59 +0100 Subject: [PATCH 06/18] Fix ScheduleNewsletterCest - wait for select2 to render before selecting value --- tests/acceptance/ScheduleNewsletterCest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/ScheduleNewsletterCest.php b/tests/acceptance/ScheduleNewsletterCest.php index 2dc220250e..37949562e4 100644 --- a/tests/acceptance/ScheduleNewsletterCest.php +++ b/tests/acceptance/ScheduleNewsletterCest.php @@ -25,6 +25,7 @@ class ScheduleNewsletterCest { $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->checkOption('isScheduled'); From 090fd092cbf9250a484504a6829d0f540a0db925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 09:51:17 +0100 Subject: [PATCH 07/18] Fix SubscriberManagementCest - wait for subscribers to finish loading before assessing --- tests/acceptance/SubscriberManagementCest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/SubscriberManagementCest.php b/tests/acceptance/SubscriberManagementCest.php index bb10dadd21..b3c125bec1 100644 --- a/tests/acceptance/SubscriberManagementCest.php +++ b/tests/acceptance/SubscriberManagementCest.php @@ -45,6 +45,7 @@ class SubscriberManagementCest { function viewSubscriberList(\AcceptanceTester $I) { $I->wantTo('View list of subscribers'); $this->generateWPUsersList($I); + $I->wait(2); $I->fillField('#search_input', 'Alec Saunders'); $I->click('Search'); $I->waitForText('Alec Saunders', 10); @@ -74,7 +75,8 @@ class SubscriberManagementCest { $new_subscriber_email = 'deleteglobaluser99@fakemail.fake'; $this->generateSingleSubscriber('deleteglobaluser99@fakemail.fake', 'Delete', 'ThisGlobalUser'); $I->login(); - $I->amOnMailPoetPage ('Subscribers'); + $I->amOnMailPoetPage('Subscribers'); + $I->waitForElementNotVisible('.mailpoet_listing_loading'); $I->clickItemRowActionByItemName($new_subscriber_email, 'Move to trash'); $I->waitForElement('[data-automation-id="filters_trash"]'); $I->click('[data-automation-id="filters_trash"]'); @@ -92,6 +94,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('addtolistuser99@fakemail.fake', 'Add', 'ToAList'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); + $I->waitForElementNotVisible('.mailpoet_listing_loading'); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 30); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); @@ -106,6 +109,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('deletefromlistuser99@fakemail.fake', 'Delete', 'FromAList'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); + $I->waitForElementNotVisible('.mailpoet_listing_loading'); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 10); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); @@ -121,6 +125,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('editglobaluser99@fakemail.fake', 'Edit', 'ThisGlobalUser'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); + $I->waitForElementNotVisible('.mailpoet_listing_loading'); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 10); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); From 4260960b59072f4180729d4b9d2b4dbb2e06a734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 16:00:41 +0100 Subject: [PATCH 08/18] Fix typos - subsciber => subscriber --- lib/Models/StatisticsClicks.php | 2 +- lib/Models/StatisticsNewsletters.php | 2 +- .../PersonalDataExporters/NewsletterClicksExporter.php | 2 +- .../PersonalDataExporters/NewslettersExporter.php | 4 ++-- lib/Subscription/Pages.php | 8 ++++---- tests/acceptance/SubscriberManagementCest.php | 2 +- .../Subscribers/ImportExport/ImportExportFactoryTest.php | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Models/StatisticsClicks.php b/lib/Models/StatisticsClicks.php index e74fa37801..6beb47443b 100644 --- a/lib/Models/StatisticsClicks.php +++ b/lib/Models/StatisticsClicks.php @@ -25,7 +25,7 @@ class StatisticsClicks extends Model { return $statistics->save(); } - static function getAllForSubsciber(Subscriber $subscriber) { + static function getAllForSubscriber(Subscriber $subscriber) { return static::table_alias('clicks') ->select('clicks.id', 'id') ->select('newsletter_rendered_subject') diff --git a/lib/Models/StatisticsNewsletters.php b/lib/Models/StatisticsNewsletters.php index 7e28d716cb..d332ea35e8 100644 --- a/lib/Models/StatisticsNewsletters.php +++ b/lib/Models/StatisticsNewsletters.php @@ -30,7 +30,7 @@ class StatisticsNewsletters extends Model { ); } - static function getAllForSubsciber(Subscriber $subscriber) { + static function getAllForSubscriber(Subscriber $subscriber) { return static::table_alias('statistics') ->select('statistics.newsletter_id', 'newsletter_id') ->select('newsletter_rendered_subject') diff --git a/lib/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporter.php b/lib/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporter.php index 2404d78419..463115e01d 100644 --- a/lib/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporter.php +++ b/lib/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporter.php @@ -22,7 +22,7 @@ class NewsletterClicksExporter { $result = array(); - $statistics = StatisticsClicks::getAllForSubsciber($subscriber) + $statistics = StatisticsClicks::getAllForSubscriber($subscriber) ->limit(self::LIMIT) ->offset(self::LIMIT * ($page - 1)) ->findArray(); diff --git a/lib/Subscribers/ImportExport/PersonalDataExporters/NewslettersExporter.php b/lib/Subscribers/ImportExport/PersonalDataExporters/NewslettersExporter.php index d70e6a6ecf..466140c7ed 100644 --- a/lib/Subscribers/ImportExport/PersonalDataExporters/NewslettersExporter.php +++ b/lib/Subscribers/ImportExport/PersonalDataExporters/NewslettersExporter.php @@ -24,7 +24,7 @@ class NewslettersExporter { $result = array(); - $statistics = StatisticsNewsletters::getAllForSubsciber($subscriber) + $statistics = StatisticsNewsletters::getAllForSubscriber($subscriber) ->limit(self::LIMIT) ->offset(self::LIMIT * ($page - 1)) ->findArray(); @@ -99,4 +99,4 @@ class NewslettersExporter { return $result; } -} \ No newline at end of file +} diff --git a/lib/Subscription/Pages.php b/lib/Subscription/Pages.php index f89e3dda0d..2e54ac2d55 100644 --- a/lib/Subscription/Pages.php +++ b/lib/Subscription/Pages.php @@ -84,17 +84,17 @@ class Pages { if($this->subscriber->getErrors() === false) { // send welcome notification - $subsciber_segments = $this->subscriber->segments()->findMany(); - if($subsciber_segments) { + $subscriber_segments = $this->subscriber->segments()->findMany(); + if($subscriber_segments) { Scheduler::scheduleSubscriberWelcomeNotification( $this->subscriber->id, array_map(function ($segment) { return $segment->get('id'); - }, $subsciber_segments) + }, $subscriber_segments) ); } - $this->new_subscriber_notification_sender->send($this->subscriber, $subsciber_segments); + $this->new_subscriber_notification_sender->send($this->subscriber, $subscriber_segments); // update subscriber from stored data after confirmation if(!empty($subscriber_data)) { diff --git a/tests/acceptance/SubscriberManagementCest.php b/tests/acceptance/SubscriberManagementCest.php index b3c125bec1..2651eba8a1 100644 --- a/tests/acceptance/SubscriberManagementCest.php +++ b/tests/acceptance/SubscriberManagementCest.php @@ -88,7 +88,7 @@ class SubscriberManagementCest { } function addSubscriberToList(\AcceptanceTester $I) { - $I->wantTo('Add a subsciber to a list'); + $I->wantTo('Add a subscriber to a list'); $new_subscriber_email = 'addtolistuser99@fakemail.fake'; $this->generateMultipleLists(); $this->generateSingleSubscriber('addtolistuser99@fakemail.fake', 'Add', 'ToAList'); diff --git a/tests/integration/Subscribers/ImportExport/ImportExportFactoryTest.php b/tests/integration/Subscribers/ImportExport/ImportExportFactoryTest.php index bbad3e8619..20bcd28107 100644 --- a/tests/integration/Subscribers/ImportExport/ImportExportFactoryTest.php +++ b/tests/integration/Subscribers/ImportExport/ImportExportFactoryTest.php @@ -122,7 +122,7 @@ class ImportExportFactoryTest extends \MailPoetTest { } } - function testItCanFormatSubsciberFields() { + function testItCanFormatSubscriberFields() { $formattedSubscriberFields = $this->importFactory->formatSubscriberFields( $this->importFactory->getSubscriberFields() @@ -140,7 +140,7 @@ class ImportExportFactoryTest extends \MailPoetTest { expect($formattedSubscriberFields[0]['custom'])->false(); } - function testItCanGetSubsciberCustomFields() { + function testItCanGetSubscriberCustomFields() { $subscriberCustomFields = $this->importFactory ->getSubscriberCustomFields(); @@ -148,7 +148,7 @@ class ImportExportFactoryTest extends \MailPoetTest { ->equals('date'); } - function testItCanFormatSubsciberCustomFields() { + function testItCanFormatSubscriberCustomFields() { $formattedSubscriberCustomFields = $this->importFactory->formatSubscriberCustomFields( $this->importFactory->getSubscriberCustomFields() From f6e9601e04a86a4bad4d76a93dab41b2d2fa11cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 16:00:55 +0100 Subject: [PATCH 09/18] Fix SubscriberManagementCest - wait for select2 to render and add more specific selector for Save button (was failing randomly) --- assets/js/src/subscribers/form.jsx | 1 + tests/acceptance/SubscriberManagementCest.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/src/subscribers/form.jsx b/assets/js/src/subscribers/form.jsx index 6d417db9aa..ebdc1461ea 100644 --- a/assets/js/src/subscribers/form.jsx +++ b/assets/js/src/subscribers/form.jsx @@ -186,6 +186,7 @@ class SubscriberForm extends React.Component { // eslint-disable-line react/pref
fillField(['name' => 'first_name'], 'New'); $I->fillField(['name' => 'last_name'], 'GlobalUser'); $I->selectOptionInSelect2($this->segment->get('name')); - $I->click('Save'); + $I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]'); $I->amOnMailPoetPage ('Subscribers'); $I->fillField('#search_input', 'newglobaluser99@fakemail.fake'); $I->click('Search'); @@ -98,8 +98,10 @@ class SubscriberManagementCest { $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 30); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); + $I->waitForElementNotVisible('.mailpoet_form_loading'); + $I->waitForElement('.select2'); $I->selectOptionInSelect2('Cooking'); - $I->click('Save'); + $I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]'); $I->seeNoJSErrors(); } @@ -113,9 +115,11 @@ class SubscriberManagementCest { $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $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('Save'); + $I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]'); $I->waitForText('Subscriber was updated', 10); } From c1262283529ce6913241aa8042ca59e91b43603b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 16:02:54 +0100 Subject: [PATCH 10/18] Unify selecting emails in EnableAndDisableSignupConfirmationCest --- tests/acceptance/EnableAndDisableSignupConfirmationCest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php index e7ff41d1dc..7cb3c2d893 100644 --- a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php +++ b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php @@ -42,10 +42,7 @@ class EnableAndDisableSignupConfirmationCest { private function countConfirmationEmails(AcceptanceTester $I) { $I->amOnUrl(AcceptanceTester::MAIL_URL); - $subjects = $I->grabMultiple('span.subject'); - $confirmation_emails = array_filter($subjects, function($subject) { - return strpos($subject, 'Confirm your subscription') !== false; - }); + $confirmation_emails = $I->grabMultiple(Locator::contains('span.subject', 'Confirm your subscription')); return count($confirmation_emails); } From b9ceb2a9062c3c7173ef350e2550f9744b57f385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 16:53:30 +0100 Subject: [PATCH 11/18] Fix EnableAndDisableSignupConfirmationCest - wait for list of mails to render before checking number of them --- tests/acceptance/EnableAndDisableSignupConfirmationCest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php index 7cb3c2d893..8b1ca8f9be 100644 --- a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php +++ b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php @@ -42,12 +42,14 @@ class EnableAndDisableSignupConfirmationCest { private function countConfirmationEmails(AcceptanceTester $I) { $I->amOnUrl(AcceptanceTester::MAIL_URL); + $I->waitForElement('.messages.ng-scope'); // ensure that angular is loaded $confirmation_emails = $I->grabMultiple(Locator::contains('span.subject', 'Confirm your subscription')); return count($confirmation_emails); } private function seeConfirmationEmailsCountIs(AcceptanceTester $I, $n) { $I->amOnUrl(AcceptanceTester::MAIL_URL); + $I->waitForElement('.messages.ng-scope'); // ensure that angular is loaded $I->seeNumberOfElements(Locator::contains('span.subject', 'Confirm your subscription'), $n); } } From ed1152886830dabd60f49dcb436228124a2eb5fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Wed, 12 Dec 2018 17:23:32 +0100 Subject: [PATCH 12/18] Fix EnableAndDisableSignupConfirmationCest - remove all emails before running tests --- .../EnableAndDisableSignupConfirmationCest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php index 8b1ca8f9be..78d6117b64 100644 --- a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php +++ b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php @@ -6,6 +6,19 @@ use AcceptanceTester; use Codeception\Util\Locator; class EnableAndDisableSignupConfirmationCest { + + function removeAllEmails(AcceptanceTester $I) { + // Remove all mails, because when there is more mails than paging allows it causes + // problems with counting ones, which would be moved to other page after adding more mails + $I->amOnUrl(AcceptanceTester::MAIL_URL); + $I->waitForElement(Locator::contains('a', 'Delete all messages'), 10); + $I->click(Locator::contains('a', 'Delete all messages')); + $I->waitForElement('.modal-footer'); + $I->wait(2); // Wait for modal fade-in animation to finish + $I->click(Locator::contains('.btn', 'Delete all messages')); + $I->waitForElementNotVisible('.modal'); + } + function disableSignupConfirmation(AcceptanceTester $I) { $I->wantTo('Disable signup confirmation'); $I->login(); @@ -13,6 +26,7 @@ class EnableAndDisableSignupConfirmationCest { $confirmation_emails_count = $this->countConfirmationEmails($I); $I->createFormAndSubscribe(); $this->seeConfirmationEmailsCountIs($I, $confirmation_emails_count); + $I->cli('widget reset sidebar-1 --allow-root'); } function enableSignupConfirmation(AcceptanceTester $I) { @@ -22,9 +36,6 @@ class EnableAndDisableSignupConfirmationCest { $confirmation_emails_count = $this->countConfirmationEmails($I); $I->createFormAndSubscribe(); $this->seeConfirmationEmailsCountIs($I, $confirmation_emails_count + 1); - } - - function _after(AcceptanceTester $I) { $I->cli('widget reset sidebar-1 --allow-root'); } From a662329edf253ed62080cde81902130be3f74718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Sat, 15 Dec 2018 13:08:13 +0100 Subject: [PATCH 13/18] Fix SearchForStandardNewsletterCest - wait for search input to be visible before filling value --- tests/acceptance/SearchForStandardNewsletterCest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/acceptance/SearchForStandardNewsletterCest.php b/tests/acceptance/SearchForStandardNewsletterCest.php index fc591ac31c..9e80b9e88c 100644 --- a/tests/acceptance/SearchForStandardNewsletterCest.php +++ b/tests/acceptance/SearchForStandardNewsletterCest.php @@ -22,6 +22,8 @@ class SearchForStandardNewsletterCest { // step 2 - Search $I->login(); $I->amOnMailpoetPage('Emails'); + $I->waitForElement('#search_input'); + $I->wait(2); $I->fillField('#search_input', $failure_condition_newsletter); $I->click('Search'); $I->wait(5); From c835feea165d270f86049b9dc0ad191040da93ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Sat, 15 Dec 2018 13:08:22 +0100 Subject: [PATCH 14/18] Fix SubscribersListingCest - wait for search input to be visible before filling value --- tests/acceptance/SubscribersListingCest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/acceptance/SubscribersListingCest.php b/tests/acceptance/SubscribersListingCest.php index 2eb79b7846..bf8dbd0977 100644 --- a/tests/acceptance/SubscribersListingCest.php +++ b/tests/acceptance/SubscribersListingCest.php @@ -9,6 +9,8 @@ class SubscribersListingCest { $I->login(); $I->amOnMailpoetPage('Subscribers'); + $I->waitForElement('#search_input'); + $I->wait(2); $I->fillField('#search_input', 'wp@example.com'); $I->click('Search'); $I->waitForText('wp@example.com', 10); From eea62cd4f74d83f3cc0256725215b08fe23ad968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 17 Dec 2018 17:25:02 +0100 Subject: [PATCH 15/18] Create helper for waiting for list to load --- tests/_support/AcceptanceTester.php | 5 +++++ tests/acceptance/DuplicatePostNotificationCest.php | 2 +- tests/acceptance/SubscriberManagementCest.php | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 38a393a24d..961801248e 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -113,4 +113,9 @@ class AcceptanceTester extends \Codeception\Actor { $I->seeNoJSErrors(); } + public function waitForListingItemsToLoad() { + $I = $this; + $I->waitForElementNotVisible('.mailpoet_listing_loading'); + } + } diff --git a/tests/acceptance/DuplicatePostNotificationCest.php b/tests/acceptance/DuplicatePostNotificationCest.php index 28c4fa4d47..d7fbc37ba2 100644 --- a/tests/acceptance/DuplicatePostNotificationCest.php +++ b/tests/acceptance/DuplicatePostNotificationCest.php @@ -27,7 +27,7 @@ class DuplicatePostNotificationCest { $I->waitForText($newsletter_title, 10); $I->clickItemRowActionByItemName($newsletter_title, 'Duplicate'); $I->waitForText('Copy of ' . $newsletter_title); - $I->waitForElementNotVisible('.mailpoet_listing_loading'); + $I->waitForListingItemsToLoad(); // step 5 - Open Editor $I->clickItemRowActionByItemName('Copy of ' . $newsletter_title, 'Edit'); diff --git a/tests/acceptance/SubscriberManagementCest.php b/tests/acceptance/SubscriberManagementCest.php index 4a292afa3a..8c2c8afe13 100644 --- a/tests/acceptance/SubscriberManagementCest.php +++ b/tests/acceptance/SubscriberManagementCest.php @@ -76,7 +76,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('deleteglobaluser99@fakemail.fake', 'Delete', 'ThisGlobalUser'); $I->login(); $I->amOnMailPoetPage('Subscribers'); - $I->waitForElementNotVisible('.mailpoet_listing_loading'); + $I->waitForListingItemsToLoad(); $I->clickItemRowActionByItemName($new_subscriber_email, 'Move to trash'); $I->waitForElement('[data-automation-id="filters_trash"]'); $I->click('[data-automation-id="filters_trash"]'); @@ -94,7 +94,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('addtolistuser99@fakemail.fake', 'Add', 'ToAList'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); - $I->waitForElementNotVisible('.mailpoet_listing_loading'); + $I->waitForListingItemsToLoad(); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 30); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); @@ -111,7 +111,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('deletefromlistuser99@fakemail.fake', 'Delete', 'FromAList'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); - $I->waitForElementNotVisible('.mailpoet_listing_loading'); + $I->waitForListingItemsToLoad(); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 10); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); @@ -129,7 +129,7 @@ class SubscriberManagementCest { $this->generateSingleSubscriber('editglobaluser99@fakemail.fake', 'Edit', 'ThisGlobalUser'); $I->login(); $I->amOnMailPoetPage ('Subscribers'); - $I->waitForElementNotVisible('.mailpoet_listing_loading'); + $I->waitForListingItemsToLoad(); $I->clickItemRowActionByItemName($new_subscriber_email, 'Edit'); $I->waitForText('Subscriber', 10); $I->seeInCurrentUrl('mailpoet-subscribers#/edit/'); From 38aaed77d87882ceab46387557f9472ff2779cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 17 Dec 2018 17:25:36 +0100 Subject: [PATCH 16/18] Create helper to load mailhog app and wait for angular to load --- tests/_support/AcceptanceTester.php | 12 +++++++++++- tests/acceptance/EditSignUpConfirmationEmailCest.php | 2 +- .../EnableAndDisableSignupConfirmationCest.php | 8 +++----- tests/acceptance/ManageSubscriptionLinkCest.php | 4 ++-- tests/acceptance/ReceivePostNotificationCest.php | 2 +- tests/acceptance/ReceiveStandardEmailCest.php | 2 +- tests/acceptance/SubscribeToMultipleListsCest.php | 2 +- tests/acceptance/SubscriptionFormCest.php | 2 +- 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 961801248e..f9dc0c6121 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -66,6 +66,16 @@ class AcceptanceTester extends \Codeception\Actor { $I->waitForText($page, 5); } + /** + * Navigate to Mailhog page and wait for angular to load + */ + public function amOnMailboxAppPage() { + $I = $this; + $I->amOnUrl(self::MAIL_URL); + // ensure that angular is loaded by checking angular specific class + $I->waitForElement('.messages.ng-scope'); + } + public function clickItemRowActionByItemName($item_name, $link) { $I = $this; $I->moveMouseOver(['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']); @@ -106,7 +116,7 @@ class AcceptanceTester extends \Codeception\Actor { $I->cli('widget add mailpoet_form sidebar-1 2 --form=' . $form->id . ' --title="Subscribe to Our Newsletter" --allow-root'); // subscribe - $I->amOnUrl(\AcceptanceTester::WP_URL); + $I->amOnUrl(self::WP_URL); $I->fillField('[data-automation-id="form_email"]', 'subscriber@example.com'); $I->click('[data-automation-id="subscribe-submit-button"]'); $I->waitForText('Check your inbox or spam folder to confirm your subscription.', 30, '.mailpoet_validate_success'); diff --git a/tests/acceptance/EditSignUpConfirmationEmailCest.php b/tests/acceptance/EditSignUpConfirmationEmailCest.php index 25dfecfb4a..767c0ab12f 100644 --- a/tests/acceptance/EditSignUpConfirmationEmailCest.php +++ b/tests/acceptance/EditSignUpConfirmationEmailCest.php @@ -29,7 +29,7 @@ class EditSignUpConfirmationEmailCest { $I->createFormAndSubscribe(); // check the received email - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->waitForText('Confirmation email subject'); $I->click(Locator::contains('span.subject', 'Confirmation email subject')); diff --git a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php index 78d6117b64..389f1e9adc 100644 --- a/tests/acceptance/EnableAndDisableSignupConfirmationCest.php +++ b/tests/acceptance/EnableAndDisableSignupConfirmationCest.php @@ -10,7 +10,7 @@ class EnableAndDisableSignupConfirmationCest { function removeAllEmails(AcceptanceTester $I) { // Remove all mails, because when there is more mails than paging allows it causes // problems with counting ones, which would be moved to other page after adding more mails - $I->amOnUrl(AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->waitForElement(Locator::contains('a', 'Delete all messages'), 10); $I->click(Locator::contains('a', 'Delete all messages')); $I->waitForElement('.modal-footer'); @@ -52,15 +52,13 @@ class EnableAndDisableSignupConfirmationCest { } private function countConfirmationEmails(AcceptanceTester $I) { - $I->amOnUrl(AcceptanceTester::MAIL_URL); - $I->waitForElement('.messages.ng-scope'); // ensure that angular is loaded + $I->amOnMailboxAppPage(); $confirmation_emails = $I->grabMultiple(Locator::contains('span.subject', 'Confirm your subscription')); return count($confirmation_emails); } private function seeConfirmationEmailsCountIs(AcceptanceTester $I, $n) { - $I->amOnUrl(AcceptanceTester::MAIL_URL); - $I->waitForElement('.messages.ng-scope'); // ensure that angular is loaded + $I->amOnMailboxAppPage(); $I->seeNumberOfElements(Locator::contains('span.subject', 'Confirm your subscription'), $n); } } diff --git a/tests/acceptance/ManageSubscriptionLinkCest.php b/tests/acceptance/ManageSubscriptionLinkCest.php index a22ebd8b7a..d015c0674c 100644 --- a/tests/acceptance/ManageSubscriptionLinkCest.php +++ b/tests/acceptance/ManageSubscriptionLinkCest.php @@ -46,7 +46,7 @@ class ManageSubscriptionLinkCest { function manageSubscriptionLink(\AcceptanceTester $I) { $I->wantTo('Verify that "manage subscription" link works and subscriber status can be updated'); - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->click(Locator::contains('span.subject', $this->newsletter_title)); $I->switchToIframe('preview-html'); $I->waitForElementChange( @@ -79,7 +79,7 @@ class ManageSubscriptionLinkCest { $form_status_element = '[data-automation-id="form_status"]'; - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->click(Locator::contains('span.subject', $this->newsletter_title)); $I->switchToIframe('preview-html'); $I->waitForElementChange( diff --git a/tests/acceptance/ReceivePostNotificationCest.php b/tests/acceptance/ReceivePostNotificationCest.php index 72e224ea7a..10fda85445 100644 --- a/tests/acceptance/ReceivePostNotificationCest.php +++ b/tests/acceptance/ReceivePostNotificationCest.php @@ -62,7 +62,7 @@ class ReceivePostNotificationCest { $I->waitForText('Sent to 1 of 1', 90); // confirm newsletter is received - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->waitForText($newsletter_subject, 90); $I->click(Locator::contains('span.subject', $newsletter_subject)); $I->switchToIframe('preview-html'); diff --git a/tests/acceptance/ReceiveStandardEmailCest.php b/tests/acceptance/ReceiveStandardEmailCest.php index d9e06303df..9707e27a32 100644 --- a/tests/acceptance/ReceiveStandardEmailCest.php +++ b/tests/acceptance/ReceiveStandardEmailCest.php @@ -39,7 +39,7 @@ class ReceiveStandardEmailCest { $I->click('Send'); $I->waitForElement('.mailpoet_progress_label', 90); //confirm newsletter is received - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->waitForText($newsletter_title, 90); $I->click(Locator::contains('span.subject', $newsletter_title)); } diff --git a/tests/acceptance/SubscribeToMultipleListsCest.php b/tests/acceptance/SubscribeToMultipleListsCest.php index 98c097d432..7ebbba682b 100644 --- a/tests/acceptance/SubscribeToMultipleListsCest.php +++ b/tests/acceptance/SubscribeToMultipleListsCest.php @@ -30,7 +30,7 @@ class SubscribeToMultipleListsCest { //Add this form to a widget $I->createFormAndSubscribe($form); //Subscribe via that form - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->click(Locator::contains('span.subject', 'Confirm your subscription')); $I->switchToIframe('preview-html'); $I->click('Click here to confirm your subscription'); diff --git a/tests/acceptance/SubscriptionFormCest.php b/tests/acceptance/SubscriptionFormCest.php index 8cd8c62536..a7fe94a968 100644 --- a/tests/acceptance/SubscriptionFormCest.php +++ b/tests/acceptance/SubscriptionFormCest.php @@ -62,7 +62,7 @@ class SubscriptionFormCest { * @depends subscriptionFormWidget */ function subscriptionConfirmation(\AcceptanceTester $I) { - $I->amOnUrl(\AcceptanceTester::MAIL_URL); + $I->amOnMailboxAppPage(); $I->click(Locator::contains('span.subject', 'Confirm your subscription')); $I->switchToIframe('preview-html'); $I->click('Click here to confirm your subscription'); From a0fa3c6a0d67f88e347c2261f7617c224117f3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 17 Dec 2018 17:26:30 +0100 Subject: [PATCH 17/18] Create helper for searching, which handle waiting for element, filling input and clicking button --- tests/_support/AcceptanceTester.php | 10 +++++++ tests/acceptance/CreateWelcomeEmailCest.php | 3 +-- tests/acceptance/ManageWelcomeEmailCest.php | 6 ++--- .../acceptance/SearchForNotificationCest.php | 6 ++--- .../SearchForStandardNewsletterCest.php | 8 ++---- .../SubscriberManageImportExportCest.php | 27 +++++++------------ tests/acceptance/SubscriberManagementCest.php | 7 ++--- tests/acceptance/SubscribersListingCest.php | 5 +--- 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index f9dc0c6121..423e0956f9 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -128,4 +128,14 @@ class AcceptanceTester extends \Codeception\Actor { $I->waitForElementNotVisible('.mailpoet_listing_loading'); } + public function searchFor($query, $delay = 0, $element = '#search_input', $button = 'Search') { + $I = $this; + $I->waitForElement($element); + if ($delay) { + $I->wait($delay); + } + $I->fillField($element, $query); + $I->click($button); + } + } diff --git a/tests/acceptance/CreateWelcomeEmailCest.php b/tests/acceptance/CreateWelcomeEmailCest.php index d41ed8624a..4df9409ccc 100644 --- a/tests/acceptance/CreateWelcomeEmailCest.php +++ b/tests/acceptance/CreateWelcomeEmailCest.php @@ -30,8 +30,7 @@ class CreateWelcomeEmailCest { $I->seeInCurrentUrl('mailpoet-newsletters'); $I->click('Welcome Emails'); $I->seeInCurrentUrl('mailpoet-newsletters#/welcome'); - $I->fillField('#search_input', $newsletter_title); - $I->click('Search'); + $I->searchFor($newsletter_title, 2); $I->waitForText($newsletter_title, 10); $I->seeNoJSErrors(); } diff --git a/tests/acceptance/ManageWelcomeEmailCest.php b/tests/acceptance/ManageWelcomeEmailCest.php index 13be97fbad..8a3c1bf442 100644 --- a/tests/acceptance/ManageWelcomeEmailCest.php +++ b/tests/acceptance/ManageWelcomeEmailCest.php @@ -111,12 +111,10 @@ class ManageWelcomeEmailCest { $I->amOnMailpoetPage('Emails'); $I->click('Welcome Emails', '[data-automation-id="newsletters_listing_tabs"]'); $I->waitForText($newsletter_title, 20); - $I->fillField('#search_input', $failure_condition_newsletter); - $I->click('Search'); + $I->searchFor($failure_condition_newsletter, 2); $I->wait(5); $I->waitForElement('tr.no-items', 10); - $I->fillField('#search_input', $newsletter_title); - $I->click('Search'); + $I->searchFor($newsletter_title); $I->waitForText($newsletter_title, 10); } diff --git a/tests/acceptance/SearchForNotificationCest.php b/tests/acceptance/SearchForNotificationCest.php index d5c93ae2a6..b487f360f0 100644 --- a/tests/acceptance/SearchForNotificationCest.php +++ b/tests/acceptance/SearchForNotificationCest.php @@ -22,12 +22,10 @@ class SearchForNotificationCest { $I->amOnMailpoetPage('Emails'); $I->click('Post Notifications', '[data-automation-id="newsletters_listing_tabs"]'); $I->waitForText('Post notification', 5); - $I->fillField('#search_input', $failure_condition_newsletter); - $I->click('Search'); + $I->searchFor($failure_condition_newsletter, 2); $I->wait(5); $I->waitForElement('tr.no-items', 10); - $I->fillField('#search_input', $newsletter_title); - $I->click('Search'); + $I->searchFor($newsletter_title); $I->waitForText($newsletter_title, 10); } diff --git a/tests/acceptance/SearchForStandardNewsletterCest.php b/tests/acceptance/SearchForStandardNewsletterCest.php index 9e80b9e88c..7a73770694 100644 --- a/tests/acceptance/SearchForStandardNewsletterCest.php +++ b/tests/acceptance/SearchForStandardNewsletterCest.php @@ -22,14 +22,10 @@ class SearchForStandardNewsletterCest { // step 2 - Search $I->login(); $I->amOnMailpoetPage('Emails'); - $I->waitForElement('#search_input'); - $I->wait(2); - $I->fillField('#search_input', $failure_condition_newsletter); - $I->click('Search'); + $I->searchFor($failure_condition_newsletter, 2); $I->wait(5); $I->dontSee($newsletter_title); - $I->fillField('#search_input', $newsletter_title); - $I->click('Search'); + $I->searchFor($newsletter_title); $I->waitForText($newsletter_title, 20); } diff --git a/tests/acceptance/SubscriberManageImportExportCest.php b/tests/acceptance/SubscriberManageImportExportCest.php index 4e7481b534..6cabf9ba09 100644 --- a/tests/acceptance/SubscriberManageImportExportCest.php +++ b/tests/acceptance/SubscriberManageImportExportCest.php @@ -30,32 +30,23 @@ class SubscriberManageImportExportCest { //confirm subscribers from import list were added $I->amOnMailPoetPage ('Subscribers'); $I->seeInCurrentUrl('mailpoet-subscribers#'); - $I->fillField('#search_input', 'aaa@example.com'); - $I->click('Search'); + $I->searchFor('aaa@example.com', 2); $I->waitForText('aaa@example.com', 10); - $I->fillField('#search_input', 'bbb@example.com'); - $I->click('Search'); + $I->searchFor('bbb@example.com'); $I->waitForText('bbb@example.com', 10); - $I->fillField('#search_input', 'ccc@example.com'); - $I->click('Search'); + $I->searchFor('ccc@example.com'); $I->waitForText('ccc@example.com', 10); - $I->fillField('#search_input', 'ddd@example.com'); - $I->click('Search'); + $I->searchFor('ddd@example.com'); $I->waitForText('ddd@example.com', 10); - $I->fillField('#search_input', 'eee@example.com'); - $I->click('Search'); + $I->searchFor('eee@example.com'); $I->waitForText('eee@example.com', 10); - $I->fillField('#search_input', 'fff@example.com'); - $I->click('Search'); + $I->searchFor('fff@example.com'); $I->waitForText('fff@example.com', 10); - $I->fillField('#search_input', 'ggg@example.com'); - $I->click('Search'); + $I->searchFor('ggg@example.com'); $I->waitForText('ggg@example.com', 10); - $I->fillField('#search_input', 'hhh@example.com'); - $I->click('Search'); + $I->searchFor('hhh@example.com'); $I->waitForText('hhh@example.com', 10); - $I->fillField('#search_input', 'iii@example.com'); - $I->click('Search'); + $I->searchFor('iii@example.com'); $I->waitForText('iii@example.com', 10); $I->seeNoJSErrors(); } diff --git a/tests/acceptance/SubscriberManagementCest.php b/tests/acceptance/SubscriberManagementCest.php index 8c2c8afe13..e60b7ceea6 100644 --- a/tests/acceptance/SubscriberManagementCest.php +++ b/tests/acceptance/SubscriberManagementCest.php @@ -45,9 +45,7 @@ class SubscriberManagementCest { function viewSubscriberList(\AcceptanceTester $I) { $I->wantTo('View list of subscribers'); $this->generateWPUsersList($I); - $I->wait(2); - $I->fillField('#search_input', 'Alec Saunders'); - $I->click('Search'); + $I->searchFor('Alec Saunders', 2); $I->waitForText('Alec Saunders', 10); $I->seeNoJSErrors(); } @@ -64,8 +62,7 @@ class SubscriberManagementCest { $I->selectOptionInSelect2($this->segment->get('name')); $I->click('[data-automation-id="subscriber_edit_form"] input[type="submit"]'); $I->amOnMailPoetPage ('Subscribers'); - $I->fillField('#search_input', 'newglobaluser99@fakemail.fake'); - $I->click('Search'); + $I->searchFor('newglobaluser99@fakemail.fake', 2); $I->waitForText('newglobaluser99@fakemail.fake', 10); $I->seeNoJSErrors(); } diff --git a/tests/acceptance/SubscribersListingCest.php b/tests/acceptance/SubscribersListingCest.php index bf8dbd0977..4035f10163 100644 --- a/tests/acceptance/SubscribersListingCest.php +++ b/tests/acceptance/SubscribersListingCest.php @@ -9,10 +9,7 @@ class SubscribersListingCest { $I->login(); $I->amOnMailpoetPage('Subscribers'); - $I->waitForElement('#search_input'); - $I->wait(2); - $I->fillField('#search_input', 'wp@example.com'); - $I->click('Search'); + $I->searchFor('wp@example.com', 2); $I->waitForText('wp@example.com', 10); } From 140d2e98dd84923f96e4b338fb1d35d67642d392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 17 Dec 2018 18:52:50 +0100 Subject: [PATCH 18/18] Refactor acceptance tests with unified waiting for select2 to load --- tests/_support/AcceptanceTester.php | 1 + tests/acceptance/EditExistingNewsletterCest.php | 1 - tests/acceptance/ExportSubscribersCest.php | 5 +---- tests/acceptance/NewsletterCreationCest.php | 1 - tests/acceptance/ReceiveStandardEmailCest.php | 5 +---- tests/acceptance/SaveNewsletterAsDraftCest.php | 1 - tests/acceptance/SaveNotificationAsDraftCest.php | 1 - tests/acceptance/ScheduleNewsletterCest.php | 5 +---- tests/acceptance/SubscriberManageImportExportCest.php | 8 ++------ tests/acceptance/SubscriberManagementCest.php | 2 -- 10 files changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 423e0956f9..583ae42d92 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -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); } diff --git a/tests/acceptance/EditExistingNewsletterCest.php b/tests/acceptance/EditExistingNewsletterCest.php index 5b5e366439..0787d63036 100644 --- a/tests/acceptance/EditExistingNewsletterCest.php +++ b/tests/acceptance/EditExistingNewsletterCest.php @@ -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"]'); diff --git a/tests/acceptance/ExportSubscribersCest.php b/tests/acceptance/ExportSubscribersCest.php index 03b3878dc5..3f1612c836 100644 --- a/tests/acceptance/ExportSubscribersCest.php +++ b/tests/acceptance/ExportSubscribersCest.php @@ -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(); } -} \ No newline at end of file +} diff --git a/tests/acceptance/NewsletterCreationCest.php b/tests/acceptance/NewsletterCreationCest.php index 890974e827..1f389b788e 100644 --- a/tests/acceptance/NewsletterCreationCest.php +++ b/tests/acceptance/NewsletterCreationCest.php @@ -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'); } diff --git a/tests/acceptance/ReceiveStandardEmailCest.php b/tests/acceptance/ReceiveStandardEmailCest.php index 9707e27a32..d73d8898b9 100644 --- a/tests/acceptance/ReceiveStandardEmailCest.php +++ b/tests/acceptance/ReceiveStandardEmailCest.php @@ -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 diff --git a/tests/acceptance/SaveNewsletterAsDraftCest.php b/tests/acceptance/SaveNewsletterAsDraftCest.php index fb2c59f981..ec90acba08 100644 --- a/tests/acceptance/SaveNewsletterAsDraftCest.php +++ b/tests/acceptance/SaveNewsletterAsDraftCest.php @@ -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'); diff --git a/tests/acceptance/SaveNotificationAsDraftCest.php b/tests/acceptance/SaveNotificationAsDraftCest.php index 7a179a8218..a83a8ec1c7 100644 --- a/tests/acceptance/SaveNotificationAsDraftCest.php +++ b/tests/acceptance/SaveNotificationAsDraftCest.php @@ -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); diff --git a/tests/acceptance/ScheduleNewsletterCest.php b/tests/acceptance/ScheduleNewsletterCest.php index 37949562e4..06eb806053 100644 --- a/tests/acceptance/ScheduleNewsletterCest.php +++ b/tests/acceptance/ScheduleNewsletterCest.php @@ -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'); diff --git a/tests/acceptance/SubscriberManageImportExportCest.php b/tests/acceptance/SubscriberManageImportExportCest.php index 6cabf9ba09..30468cc0f3 100644 --- a/tests/acceptance/SubscriberManageImportExportCest.php +++ b/tests/acceptance/SubscriberManageImportExportCest.php @@ -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(); } -} \ No newline at end of file +} diff --git a/tests/acceptance/SubscriberManagementCest.php b/tests/acceptance/SubscriberManagementCest.php index e60b7ceea6..12231a9adc 100644 --- a/tests/acceptance/SubscriberManagementCest.php +++ b/tests/acceptance/SubscriberManagementCest.php @@ -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"]');