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');