diff --git a/RoboFile.php b/RoboFile.php index 27b4be4a3a..1ece58a07d 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -299,7 +299,7 @@ class RoboFile extends \Robo\Tasks { '--standard=./tasks/code_sniffer/MailPoet '. '--runtime-set testVersion 5.5-7.2 '. '--ignore=./tests/unit/_bootstrap.php '. - 'tests/unit/ '. + 'tests/unit/ tests/acceptance tests/DataFactories '. $severityFlag ) ->run(); diff --git a/tests/DataFactories/Newsletter.php b/tests/DataFactories/Newsletter.php index cf067fb6d3..452c8c3cb0 100644 --- a/tests/DataFactories/Newsletter.php +++ b/tests/DataFactories/Newsletter.php @@ -55,9 +55,11 @@ class Newsletter { } /** + * @param array $options + * * @return Newsletter */ - public function withPostNoticationOptions(array $options = [ + public function withPostNotificationOptions(array $options = [ 8 => 'daily', # intervalType 9 => '0', # timeOfDay 10 => '1', # intervalType @@ -69,10 +71,11 @@ class Newsletter { } /** + * @param array $options + * * @return Newsletter */ - public function withOptions(array $options) - { + public function withOptions(array $options) { $this->options = array_merge($this->options, $options); return $this; } @@ -90,7 +93,7 @@ class Newsletter { */ public function create() { $newsletter = \MailPoet\Models\Newsletter::createOrUpdate($this->data); - foreach ($this->options as $option_id => $option_value) { + foreach($this->options as $option_id => $option_value) { \MailPoet\Models\NewsletterOption::createOrUpdate( [ 'newsletter_id' => $newsletter->id, @@ -101,4 +104,4 @@ class Newsletter { } return $newsletter; } -} \ No newline at end of file +} diff --git a/tests/acceptance/ConfirmNewsletterAutosaveCest.php b/tests/acceptance/ConfirmNewsletterAutosaveCest.php index dedabf1512..01a32c21d8 100644 --- a/tests/acceptance/ConfirmNewsletterAutosaveCest.php +++ b/tests/acceptance/ConfirmNewsletterAutosaveCest.php @@ -1,31 +1,35 @@ -wantTo('Confirm autosave works as advertised'); - - $newsletter_title = 'Autosave Test ' . \MailPoet\Util\Security::generateRandomString(); - - $I->login(); - $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); - - // step 1 - select notification type - $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_standard\']'); - - // step 2 - select template - $standard_template = '[data-automation-id=\'select_template_0\']'; - $I->waitForElement($standard_template); - $I->see('Newsletters', ['css' => 'a.current']); - $I->seeInCurrentUrl('#/template'); - $I->click($standard_template); - - // step 3 - Add subject, wait for Autosave - $title_element = '[data-automation-id=\'newsletter_title\']'; - $I->waitForElement($title_element); - $I->seeInCurrentUrl('mailpoet-newsletter-editor'); - $I->fillField($title_element, $newsletter_title); - $I->waitForText('Autosaved', 20); - } -} +wantTo('Confirm autosave works as advertised'); + + $newsletter_title = 'Autosave Test ' . \MailPoet\Util\Security::generateRandomString(); + + $I->login(); + $I->amOnMailpoetPage('Emails'); + $I->click('[data-automation-id="new_email"]'); + + // step 1 - select notification type + $I->seeInCurrentUrl('#/new'); + $I->click('[data-automation-id="create_standard"]'); + + // step 2 - select template + $standard_template = '[data-automation-id="select_template_0"]'; + $I->waitForElement($standard_template); + $I->see('Newsletters', ['css' => 'a.current']); + $I->seeInCurrentUrl('#/template'); + $I->click($standard_template); + + // step 3 - Add subject, wait for Autosave + $title_element = '[data-automation-id="newsletter_title"]'; + $I->waitForElement($title_element); + $I->seeInCurrentUrl('mailpoet-newsletter-editor'); + $I->fillField($title_element, $newsletter_title); + $I->waitForText('Autosaved', 20); + } + +} diff --git a/tests/acceptance/ConfirmNotificationAutosaveCest.php b/tests/acceptance/ConfirmNotificationAutosaveCest.php index c607054ca9..509a0a3779 100644 --- a/tests/acceptance/ConfirmNotificationAutosaveCest.php +++ b/tests/acceptance/ConfirmNotificationAutosaveCest.php @@ -7,23 +7,25 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class ConfirmNotificationAutosaveCest { + function confirmNotificationAutosave(\AcceptanceTester $I) { $I->wantTo('Confirm Post Notification Autosave'); $newsletter_title = 'Notification Autosave Test'; // step 1 - Prepare post notification data $newsletter = new Newsletter(); $newsletter = $newsletter->withSubject($newsletter_title) - ->withType('notification') - ->withPostNoticationOptions() - ->create(); + ->withType('notification') + ->withPostNotificationOptions() + ->create(); // step 2 - Go to editor $I->login(); - $I->amEditingNewsletter($newsletter->id); + $I->amEditingNewsletter($newsletter->id); // step 3 - Add subject, wait for Autosave - $title_element = '[data-automation-id=\'newsletter_title\']'; + $title_element = '[data-automation-id="newsletter_title"]'; $I->waitForElement($title_element); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); $I->fillField($title_element, $newsletter_title); $I->waitForText('Autosaved', 20); } + } diff --git a/tests/acceptance/DeleteNewsletterCest.php b/tests/acceptance/DeleteNewsletterCest.php index 62603f0d96..b1e85d6da8 100644 --- a/tests/acceptance/DeleteNewsletterCest.php +++ b/tests/acceptance/DeleteNewsletterCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class DeleteNewsletterCest { + function moveNewsletterToTrash(\AcceptanceTester $I) { $newsletter_name = 'Trash Newsletter'; $newsletter = new Newsletter(); @@ -20,6 +21,7 @@ class DeleteNewsletterCest { $I->click('[data-automation-id="filters_trash"]'); $I->waitForText($newsletter_name); } + function restoreFormFromTrash(\AcceptanceTester $I) { $newsletter_name = 'Restore Trashed Newsletter'; $newsletter = new Newsletter(); @@ -34,6 +36,7 @@ class DeleteNewsletterCest { $I->click('[data-automation-id="filters_all"]'); $I->waitForText($newsletter_name); } + function deleteFormPermanently(\AcceptanceTester $I) { $newsletter_name = 'Goodbye Forever Newsletter'; $newsletter = new Newsletter(); @@ -48,4 +51,4 @@ class DeleteNewsletterCest { $I->waitForText('permanently deleted.'); $I->waitForElementNotVisible($newsletter_name); } -} \ No newline at end of file +} diff --git a/tests/acceptance/DeleteNotificationCest.php b/tests/acceptance/DeleteNotificationCest.php index 2745a19089..f2ea1a3c69 100644 --- a/tests/acceptance/DeleteNotificationCest.php +++ b/tests/acceptance/DeleteNotificationCest.php @@ -7,14 +7,15 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class DeleteNotificationCest { + function deleteNotification(\AcceptanceTester $I) { // step 1 - Prepare post notification data $I->wantTo('delete a notification'); $newsletter_name = 'Deletion Test Post Notification'; $factory = new Newsletter(); - $newsletter = $factory->withSubject($newsletter_name) + $factory->withSubject($newsletter_name) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->create(); // step 2 - Open list of post notifications $I->login(); @@ -33,9 +34,9 @@ class DeleteNotificationCest { $I->wantTo('Restore a newsletter from trash'); $newsletter_name = 'Restore from Trash Test Post Notification'; $factory = new Newsletter(); - $newsletter = $factory->withSubject($newsletter_name) + $factory->withSubject($newsletter_name) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->withDeleted() ->create(); // step 2 - Open list of post notifications @@ -57,9 +58,9 @@ class DeleteNotificationCest { $I->wantTo('Permanently delete a notification'); $newsletter_name = 'Goodbye Forever Notification Test'; $factory = new Newsletter(); - $newsletter = $factory->withSubject($newsletter_name) + $factory->withSubject($newsletter_name) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->withDeleted() ->create(); // step 2 - Open list of post notifications @@ -74,4 +75,4 @@ class DeleteNotificationCest { $I->waitForText('permanently deleted.'); $I->waitForElementNotVisible($newsletter_name); } -} \ No newline at end of file +} diff --git a/tests/acceptance/DuplicateNewsletterCest.php b/tests/acceptance/DuplicateNewsletterCest.php index 571f3e01a2..7d57c06ed0 100644 --- a/tests/acceptance/DuplicateNewsletterCest.php +++ b/tests/acceptance/DuplicateNewsletterCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class DuplicateNewsletterCest { + function duplicateNewsletter(\AcceptanceTester $I) { $newsletter_name = 'Duplicate Newsletter'; $newsletter = new Newsletter(); @@ -18,5 +19,5 @@ class DuplicateNewsletterCest { $I->clickItemRowActionByItemName($newsletter_name, 'Duplicate'); $I->waitForText('Copy of ' . $newsletter_name); } - -} \ No newline at end of file + +} diff --git a/tests/acceptance/DuplicatePostNotificationCest.php b/tests/acceptance/DuplicatePostNotificationCest.php index 32687b4bf7..8967bfb3b2 100644 --- a/tests/acceptance/DuplicatePostNotificationCest.php +++ b/tests/acceptance/DuplicatePostNotificationCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class DuplicatePostNotificationCest { + function duplicatePostNotification(\AcceptanceTester $I) { $I->wantTo('Duplicate post notification email'); @@ -14,9 +15,9 @@ class DuplicatePostNotificationCest { $newsletter_title = 'Post Notification Duplicate Test'; $newsletter_factory = new Newsletter(); $newsletter_factory->withSubject($newsletter_title) - ->withType('notification') - ->withPostNoticationOptions() - ->create(); + ->withType('notification') + ->withPostNotificationOptions() + ->create(); // step 2 - Open list of post notifications $I->login(); @@ -32,4 +33,5 @@ class DuplicatePostNotificationCest { $I->clickItemRowActionByItemName('Copy of ' . $newsletter_title, 'Edit'); $I->waitForElement('[data-automation-id="newsletter_title"]'); } + } diff --git a/tests/acceptance/EditExistingNewsletterCest.php b/tests/acceptance/EditExistingNewsletterCest.php index 173101e193..0787d63036 100644 --- a/tests/acceptance/EditExistingNewsletterCest.php +++ b/tests/acceptance/EditExistingNewsletterCest.php @@ -1,49 +1,48 @@ -wantTo('Edit a standard newsletter'); - - $newsletter_title = 'Testing Newsletter ' . \MailPoet\Util\Security::generateRandomString(); - - $I->login(); - $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); - - // step 1 - select notification type - $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_standard\']'); - - // step 2 - select template - $standard_template = '[data-automation-id=\'select_template_0\']'; - $I->waitForElement($standard_template); - $I->see('Newsletters', ['css' => 'a.current']); - $I->seeInCurrentUrl('#/template'); - $I->click($standard_template); - - // step 3 - design newsletter (update subject) - $title_element = '[data-automation-id=\'newsletter_title\']'; - $I->waitForElement($title_element); - $I->seeInCurrentUrl('mailpoet-newsletter-editor'); - $I->fillField($title_element, $newsletter_title); - $I->click('Next'); - - // step 4 - Choose list and save - $send_form_element = '[data-automation-id="newsletter_send_form"]'; - $I->waitForElement($send_form_element); - $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); - $I->click('Save as draft and close'); - $I->waitForText('Standard newsletter', 5, '[data-automation-id="listing_item_1"]'); - - // step 5 - Edit this newsletter! - $I->moveMouseOver(['css' => '.mailpoet_listing_table *[data-automation-id="listing_item_1"]']); - $I->makeScreenshot('after_mouse_over'); - $I->click('Edit', ['css' => '.mailpoet_listing_table *[data-automation-id="listing_item_1"]']); - $I->seeInCurrentUrl('page=mailpoet-newsletter-editor'); - } -} +wantTo('Edit a standard newsletter'); + + $newsletter_title = 'Testing Newsletter ' . \MailPoet\Util\Security::generateRandomString(); + + $I->login(); + $I->amOnMailpoetPage('Emails'); + $I->click('[data-automation-id="new_email"]'); + + // step 1 - select notification type + $I->seeInCurrentUrl('#/new'); + $I->click('[data-automation-id="create_standard"]'); + + // step 2 - select template + $standard_template = '[data-automation-id="select_template_0"]'; + $I->waitForElement($standard_template); + $I->see('Newsletters', ['css' => 'a.current']); + $I->seeInCurrentUrl('#/template'); + $I->click($standard_template); + + // step 3 - design newsletter (update subject) + $title_element = '[data-automation-id="newsletter_title"]'; + $I->waitForElement($title_element); + $I->seeInCurrentUrl('mailpoet-newsletter-editor'); + $I->fillField($title_element, $newsletter_title); + $I->click('Next'); + + // step 4 - Choose list and save + $send_form_element = '[data-automation-id="newsletter_send_form"]'; + $I->waitForElement($send_form_element); + $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); + $I->selectOptionInSelect2('WordPress Users'); + $I->click('Save as draft and close'); + $I->waitForText('Standard newsletter', 5, '[data-automation-id="listing_item_1"]'); + + // step 5 - Edit this newsletter! + $I->moveMouseOver(['css' => '.mailpoet_listing_table *[data-automation-id="listing_item_1"]']); + $I->makeScreenshot('after_mouse_over'); + $I->click('Edit', ['css' => '.mailpoet_listing_table *[data-automation-id="listing_item_1"]']); + $I->seeInCurrentUrl('page=mailpoet-newsletter-editor'); + } +} diff --git a/tests/acceptance/EditExistingPostNotificationEmailCest.php b/tests/acceptance/EditExistingPostNotificationEmailCest.php index 3ff5af0a9f..8f03da45a1 100644 --- a/tests/acceptance/EditExistingPostNotificationEmailCest.php +++ b/tests/acceptance/EditExistingPostNotificationEmailCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class EditExistingPostNotificationEmailCest { + function editSubjectAndSchedule(\AcceptanceTester $I) { $I->wantTo('Edit existing post notification email'); @@ -17,7 +18,7 @@ class EditExistingPostNotificationEmailCest { $form = new Newsletter(); $newsletter = $form->withSubject($newsletter_title) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->create(); // step 2 - Open list of post notifications @@ -41,10 +42,11 @@ class EditExistingPostNotificationEmailCest { $I->waitForElement('input.select2-search__field'); $I->seeInCurrentUrl('#/send'); $I->selectOption('[data-automation-id="newsletter_interval_type"]', 'Weekly on...'); - $I->selectOptionInSelect2( 'WordPress Users'); + $I->selectOptionInSelect2('WordPress Users'); $newsletter_listing_element = '[data-automation-id="listing_item_' . basename($I->getCurrentUrl()) . '"]'; $I->click('Activate'); $I->waitForElement($newsletter_listing_element); $I->see($newsletter_edited_title, $newsletter_listing_element); } + } diff --git a/tests/acceptance/FormsCreationCest.php b/tests/acceptance/FormsCreationCest.php index 191533c505..de5a6ce62e 100644 --- a/tests/acceptance/FormsCreationCest.php +++ b/tests/acceptance/FormsCreationCest.php @@ -13,9 +13,7 @@ class FormsCreationCest { $I->click('[data-automation-id="create_new_form"]'); $I->waitForElement('[data-automation-id="mailpoet_form_name_input"]'); $I->fillField('[data-automation-id="mailpoet_form_name_input"]', 'My new form'); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'My First List'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('My First List'); $I->click('[data-automation-id="save_form"]'); $I->click('[data-automation-id="mailpoet_form_go_back"]'); diff --git a/tests/acceptance/FormsDeletingCest.php b/tests/acceptance/FormsDeletingCest.php index cc1333dc33..05f62bf0ed 100644 --- a/tests/acceptance/FormsDeletingCest.php +++ b/tests/acceptance/FormsDeletingCest.php @@ -66,5 +66,4 @@ class FormsDeletingCest { $I->waitForElementNotVisible($form_name); } - } diff --git a/tests/acceptance/FormsListingCest.php b/tests/acceptance/FormsListingCest.php index 4d6945d254..dc1853108b 100644 --- a/tests/acceptance/FormsListingCest.php +++ b/tests/acceptance/FormsListingCest.php @@ -3,6 +3,7 @@ namespace MailPoet\Test\Acceptance; class FormsListingCest { + function formsListing(\AcceptanceTester $I) { $I->wantTo('Open forms listings page'); @@ -11,4 +12,5 @@ class FormsListingCest { $I->waitForText('Test Form', 5, '[data-automation-id="listing_item_1"]'); } + } diff --git a/tests/acceptance/ListsListingCest.php b/tests/acceptance/ListsListingCest.php index f94665b365..9be5a3c29c 100644 --- a/tests/acceptance/ListsListingCest.php +++ b/tests/acceptance/ListsListingCest.php @@ -3,6 +3,7 @@ namespace MailPoet\Test\Acceptance; class ListsListingCest { + function listsListing(\AcceptanceTester $I) { $I->wantTo('Open lists listings page'); @@ -12,4 +13,5 @@ class ListsListingCest { $I->waitForText('WordPress Users', 5, '[data-automation-id="listing_item_1"]'); $I->see('My First List', '[data-automation-id="listing_item_2"]'); } -} \ No newline at end of file + +} diff --git a/tests/acceptance/ManageSubscriptionLinkCest.php b/tests/acceptance/ManageSubscriptionLinkCest.php index c79de96d7b..31a6cbd613 100644 --- a/tests/acceptance/ManageSubscriptionLinkCest.php +++ b/tests/acceptance/ManageSubscriptionLinkCest.php @@ -5,6 +5,7 @@ namespace MailPoet\Test\Acceptance; use Codeception\Util\Locator; class ManageSubscriptionLinkCest { + function __construct() { $this->newsletter_title = 'Subscription links Email ' . \MailPoet\Util\Security::generateRandomString(); } @@ -14,20 +15,20 @@ class ManageSubscriptionLinkCest { $I->login(); $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); + $I->click('[data-automation-id="new_email"]'); // step 1 - select type $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_standard\']'); + $I->click('[data-automation-id="create_standard"]'); // step 2 - select template - $first_template_element = '[data-automation-id=\'select_template_0\']'; + $first_template_element = '[data-automation-id="select_template_0"]'; $I->waitForElement($first_template_element); $I->seeInCurrentUrl('#/template'); $I->click($first_template_element); // step 3 - design newsletter (update subject) - $title_element ='[data-automation-id=\'newsletter_title\']'; + $title_element ='[data-automation-id="newsletter_title"]'; $I->waitForElement($title_element); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); $I->fillField($title_element, $this->newsletter_title); @@ -37,8 +38,7 @@ class ManageSubscriptionLinkCest { $search_field_element = 'input.select2-search__field'; $I->waitForElement($search_field_element); $I->seeInCurrentUrl('#/send'); - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('WordPress Users'); $I->click('Send'); $I->waitForText('Sent to 1 of 1', 60); } @@ -49,14 +49,16 @@ class ManageSubscriptionLinkCest { $I->amOnUrl('http://mailhog:8025'); $I->click(Locator::contains('span.subject', $this->newsletter_title)); $I->switchToIframe('preview-html'); - $I->waitForElementChange(\Codeception\Util\Locator::contains('a', 'Manage subscription'), function($el) { - return $el->getAttribute('target') === "_blank"; - }, 100); + $I->waitForElementChange( + \Codeception\Util\Locator::contains('a', 'Manage subscription'), function ($el) { + return $el->getAttribute('target') === "_blank"; + }, 100 + ); $I->click('Manage subscription'); $I->switchToNextTab(); $I->waitForText('Manage your subscription'); - $form_status_element = '[data-automation-id=\'form_status\']'; + $form_status_element = '[data-automation-id="form_status"]'; // set status to unsubscribed $I->selectOption($form_status_element, 'Unsubscribed'); @@ -75,14 +77,16 @@ class ManageSubscriptionLinkCest { function unsubscribeLink(\AcceptanceTester $I) { $I->wantTo('Verify that "unsubscribe" link works and subscriber status is set to unsubscribed'); - $form_status_element = '[data-automation-id=\'form_status\']'; + $form_status_element = '[data-automation-id="form_status"]'; $I->amOnUrl('http://mailhog:8025'); $I->click(Locator::contains('span.subject', $this->newsletter_title)); $I->switchToIframe('preview-html'); - $I->waitForElementChange(\Codeception\Util\Locator::contains('a', 'Unsubscribe'), function($el) { - return $el->getAttribute('target') === "_blank"; - }, 100); + $I->waitForElementChange( + \Codeception\Util\Locator::contains('a', 'Unsubscribe'), function ($el) { + return $el->getAttribute('target') === "_blank"; + }, 100 + ); $I->click('Unsubscribe'); $I->switchToNextTab(); $I->waitForText('You are now unsubscribed'); @@ -90,4 +94,4 @@ class ManageSubscriptionLinkCest { $I->seeOptionIsSelected($form_status_element, 'Unsubscribed'); $I->seeNoJSErrors(); } -} \ No newline at end of file +} diff --git a/tests/acceptance/NewsletterCreationCest.php b/tests/acceptance/NewsletterCreationCest.php index 1c917dae8b..1f389b788e 100644 --- a/tests/acceptance/NewsletterCreationCest.php +++ b/tests/acceptance/NewsletterCreationCest.php @@ -3,6 +3,7 @@ namespace MailPoet\Test\Acceptance; class NewsletterCreationCest { + function createPostNotification(\AcceptanceTester $I) { $I->wantTo('Create and configure post notification email'); @@ -10,11 +11,11 @@ class NewsletterCreationCest { $I->login(); $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); + $I->click('[data-automation-id="new_email"]'); // step 1 - select notification type $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_notification\']'); + $I->click('[data-automation-id="create_notification"]'); // step 2 - configure schedule $I->waitForText('Latest Post Notifications'); @@ -23,14 +24,14 @@ class NewsletterCreationCest { $I->click('Next'); // step 3 - select template - $post_notification_template = '[data-automation-id=\'select_template_0\']'; + $post_notification_template = '[data-automation-id="select_template_0"]'; $I->waitForElement($post_notification_template); $I->see('Post Notifications', ['css' => 'a.current']); $I->seeInCurrentUrl('#/template'); $I->click($post_notification_template); // step 4 - design newsletter (update subject) - $title_element = '[data-automation-id=\'newsletter_title\']'; + $title_element = '[data-automation-id="newsletter_title"]'; $I->waitForElement($title_element); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); $I->fillField($title_element, $newsletter_title); @@ -42,8 +43,7 @@ class NewsletterCreationCest { $I->seeInCurrentUrl('#/send'); $I->see('Select a frequency'); $newsletter_listing_element = '[data-automation-id="listing_item_' . basename($I->getCurrentUrl()) . '"]'; - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('WordPress Users'); $I->click('Activate'); $I->waitForElement($newsletter_listing_element); $I->see($newsletter_title, $newsletter_listing_element); @@ -57,21 +57,21 @@ class NewsletterCreationCest { $I->login(); $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); + $I->click('[data-automation-id="new_email"]'); // step 1 - select notification type $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_standard\']'); + $I->click('[data-automation-id="create_standard"]'); // step 2 - select template - $standard_template = '[data-automation-id=\'select_template_0\']'; + $standard_template = '[data-automation-id="select_template_0"]'; $I->waitForElement($standard_template); $I->see('Newsletters', ['css' => 'a.current']); $I->seeInCurrentUrl('#/template'); $I->click($standard_template); // step 3 - design newsletter (update subject) - $title_element = '[data-automation-id=\'newsletter_title\']'; + $title_element = '[data-automation-id="newsletter_title"]'; $I->waitForElement($title_element); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); $I->fillField($title_element, $newsletter_title); @@ -81,9 +81,8 @@ class NewsletterCreationCest { $send_form_element = '[data-automation-id="newsletter_send_form"]'; $I->waitForElement($send_form_element); $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('WordPress Users'); $I->click('Send'); } + } diff --git a/tests/acceptance/NewslettersListingCest.php b/tests/acceptance/NewslettersListingCest.php index 9f66e99a8e..02ba823e9b 100644 --- a/tests/acceptance/NewslettersListingCest.php +++ b/tests/acceptance/NewslettersListingCest.php @@ -3,6 +3,7 @@ namespace MailPoet\Test\Acceptance; class NewslettersListingCest { + function newslettersListing(\AcceptanceTester $I) { $I->wantTo('Open newsletters listings page'); @@ -44,4 +45,5 @@ class NewslettersListingCest { $I->waitForText('Subject', 5); $I->see('Opened, Clicked'); } + } diff --git a/tests/acceptance/SaveNewsletterAsDraftCest.php b/tests/acceptance/SaveNewsletterAsDraftCest.php index f55dccc231..ec90acba08 100644 --- a/tests/acceptance/SaveNewsletterAsDraftCest.php +++ b/tests/acceptance/SaveNewsletterAsDraftCest.php @@ -1,42 +1,43 @@ -wantTo('Create standard newsletter and save as a draft'); - - $newsletter_title = 'Testing Newsletter ' . \MailPoet\Util\Security::generateRandomString(); - - $I->login(); - $I->amOnMailpoetPage('Emails'); - $I->click('[data-automation-id=\'new_email\']'); - - // step 1 - select notification type - $I->seeInCurrentUrl('#/new'); - $I->click('[data-automation-id=\'create_standard\']'); - - // step 2 - select template - $standard_template = '[data-automation-id=\'select_template_0\']'; - $I->waitForElement($standard_template); - $I->see('Newsletters', ['css' => 'a.current']); - $I->seeInCurrentUrl('#/template'); - $I->click($standard_template); - - // step 3 - design newsletter (update subject) - $title_element = '[data-automation-id=\'newsletter_title\']'; - $I->waitForElement($title_element); - $I->seeInCurrentUrl('mailpoet-newsletter-editor'); - $I->fillField($title_element, $newsletter_title); - $I->click('Next'); - // step 4 - Choose list and send - $send_form_element = '[data-automation-id="newsletter_send_form"]'; - $I->waitForElement($send_form_element); - $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); - $I->click('Save as draft and close'); - $I->waitForText('Standard newsletter', 5, '[data-automation-id="listing_item_1"]'); - } -} +wantTo('Create standard newsletter and save as a draft'); + + $newsletter_title = 'Testing Newsletter ' . \MailPoet\Util\Security::generateRandomString(); + + $I->login(); + $I->amOnMailpoetPage('Emails'); + $I->click('[data-automation-id="new_email"]'); + + // step 1 - select notification type + $I->seeInCurrentUrl('#/new'); + $I->click('[data-automation-id="create_standard"]'); + + // step 2 - select template + $standard_template = '[data-automation-id="select_template_0"]'; + $I->waitForElement($standard_template); + $I->see('Newsletters', ['css' => 'a.current']); + $I->seeInCurrentUrl('#/template'); + $I->click($standard_template); + + // step 3 - design newsletter (update subject) + $title_element = '[data-automation-id="newsletter_title"]'; + $I->waitForElement($title_element); + $I->seeInCurrentUrl('mailpoet-newsletter-editor'); + $I->fillField($title_element, $newsletter_title); + $I->click('Next'); + // step 4 - Choose list and send + $send_form_element = '[data-automation-id="newsletter_send_form"]'; + $I->waitForElement($send_form_element); + $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); + $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/SaveNewsletterAsTemplateCest.php b/tests/acceptance/SaveNewsletterAsTemplateCest.php index 614414f649..a272c4321e 100644 --- a/tests/acceptance/SaveNewsletterAsTemplateCest.php +++ b/tests/acceptance/SaveNewsletterAsTemplateCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class SaveNewsletterAsTemplateCest { + function saveStandardNewsletterAsTemplate(\AcceptanceTester $I) { $I->wantTo('Create standard newsletter and save as a template'); @@ -17,13 +18,13 @@ class SaveNewsletterAsTemplateCest { // step 1 - Prepare post notification data $newsletterFactory = new Newsletter(); $newsletter = $newsletterFactory->withSubject($newsletter_title) - ->withType('standard') - ->create(); - + ->withType('standard') + ->create(); + // step 2 - Go to editor $I->login(); $I->amEditingNewsletter($newsletter->id); - + //step 3 - save as a template $I->click('[data-automation-id="newsletter_save_options_toggle"]'); $I->click('[data-automation-id="newsletter_save_as_template_option"]'); @@ -31,7 +32,7 @@ class SaveNewsletterAsTemplateCest { $I->fillField(['name' => 'template_description'], $template_description); $I->click('[data-automation-id="newsletter_save_as_template_button"]'); $I->waitForText('Template has been saved', 20); - + //step 4 - confirm template can be used $I->amOnMailpoetPage('Emails'); $I->click('[data-automation-id="new_email"]'); @@ -39,11 +40,12 @@ class SaveNewsletterAsTemplateCest { $I->click('[data-automation-id=\'create_standard\']'); $I->waitForText('Newsletters'); $I->seeInCurrentUrl('#/template'); - + $I->waitForElement('[data-automation-id="select_template_0"]'); $I->see('Magical Unicorn Test Template'); $I->click(['xpath' => '//*[text()="' . $template_name . '"]//ancestor::*[@data-automation-id="select_template_box"]//*[starts-with(@data-automation-id,"select_template_")]']); $I->waitForElement('[data-automation-id="newsletter_title"]'); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); - } -} \ No newline at end of file + } + +} diff --git a/tests/acceptance/SaveNotificationAsDraftCest.php b/tests/acceptance/SaveNotificationAsDraftCest.php index 2f7362762a..4f60e53274 100644 --- a/tests/acceptance/SaveNotificationAsDraftCest.php +++ b/tests/acceptance/SaveNotificationAsDraftCest.php @@ -6,7 +6,8 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; -class SaveNotificationAsDraftCest  { +class SaveNotificationAsDraftCest { + function saveNotificationAsDraft(\AcceptanceTester $I) { // step 1 - Prepare post notification data $I->wantTo('Save post notification email as draft'); @@ -14,7 +15,7 @@ class SaveNotificationAsDraftCest  { $newsletterFactory = new Newsletter(); $newsletter = $newsletterFactory->withSubject($newsletter_title) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->create(); // step 2 - Go to editor $I->login(); @@ -24,12 +25,11 @@ class SaveNotificationAsDraftCest  { $send_form_element = '[data-automation-id="newsletter_send_form"]'; $I->waitForElement($send_form_element); $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'WordPress Users'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('WordPress Users'); $I->click('Save as draft and close'); $I->waitForElement('[data-automation-id="newsletters_listing_tabs"]', 10); $I->seeInCurrentUrl('/wp-admin/admin.php?page=mailpoet-newsletters#/notification'); $I->waitForText('Draft Test Post Notification'); } + } diff --git a/tests/acceptance/SavePostNotificationEmailAsTemplateCest.php b/tests/acceptance/SavePostNotificationEmailAsTemplateCest.php index db4823acf7..33501ace54 100644 --- a/tests/acceptance/SavePostNotificationEmailAsTemplateCest.php +++ b/tests/acceptance/SavePostNotificationEmailAsTemplateCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class SavePostNotificationEmailAsTemplateCest { + function saveAsTemplate(\AcceptanceTester $I) { $I->wantTo('Save post notification email as template'); @@ -17,9 +18,9 @@ class SavePostNotificationEmailAsTemplateCest { // step 1 - Prepare post notification data $newsletterFactory = new Newsletter(); $newsletter = $newsletterFactory->withSubject($newsletter_title) - ->withType('notification') - ->withPostNoticationOptions() - ->create(); + ->withType('notification') + ->withPostNotificationOptions() + ->create(); // step 2 - Go to editor $I->login(); @@ -51,4 +52,5 @@ class SavePostNotificationEmailAsTemplateCest { $I->waitForElement('[data-automation-id="newsletter_title"]'); $I->seeInCurrentUrl('mailpoet-newsletter-editor'); } + } diff --git a/tests/acceptance/ScheduleNewsletterCest.php b/tests/acceptance/ScheduleNewsletterCest.php index 89b1f37a0e..4b3ca82383 100644 --- a/tests/acceptance/ScheduleNewsletterCest.php +++ b/tests/acceptance/ScheduleNewsletterCest.php @@ -6,6 +6,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class ScheduleNewsletterCest { + function scheduleStandardNewsletter(\AcceptanceTester $I) { $I->wantTo('Schedule a newsletter'); $newsletter_title = 'Schedule Test Newsletter'; @@ -15,12 +16,12 @@ class ScheduleNewsletterCest { $newsletter = $newsletterFactory->withSubject($newsletter_title) ->withType('standard') ->create(); - + // step 2 - Go to editor $I->login(); $I->amEditingNewsletter($newsletter->id); $I->click('Next'); - + // step 4 - Choose list and schedule $I->waitForElement('[data-automation-id="newsletter_send_form"]'); $I->seeInCurrentUrl('mailpoet-newsletters#/send/'); @@ -33,6 +34,7 @@ class ScheduleNewsletterCest { $I->click('Schedule'); $I->waitForElement('[data-automation-id="newsletters_listing_tabs"]', 20); $I->seeInCurrentUrl('mailpoet-newsletters'); - + } + } diff --git a/tests/acceptance/SearchForNotificationCest.php b/tests/acceptance/SearchForNotificationCest.php index 5e4a2afc08..1dedf57e5f 100644 --- a/tests/acceptance/SearchForNotificationCest.php +++ b/tests/acceptance/SearchForNotificationCest.php @@ -7,15 +7,16 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class SearchForNotificationCest { + function searchForStandardNotification(\AcceptanceTester $I) { $I->wantTo('Successfully search for an existing notification'); $newsletter_title = 'Search Test Notification'; $failure_condition_newsletter = 'Not Actually Real'; // step 1 - Prepare newsletter data $newsletterFactory = new Newsletter(); - $newsletter = $newsletterFactory->withSubject($newsletter_title) + $newsletterFactory->withSubject($newsletter_title) ->withType('notification') - ->withPostNoticationOptions() + ->withPostNotificationOptions() ->create(); // step 2 - Search $I->login(); @@ -30,5 +31,5 @@ class SearchForNotificationCest { $I->click('Search'); $I->waitForText($newsletter_title, 10); } - + } diff --git a/tests/acceptance/SearchForStandardNewsletterCest.php b/tests/acceptance/SearchForStandardNewsletterCest.php index d2a7b2f948..6c61c18821 100644 --- a/tests/acceptance/SearchForStandardNewsletterCest.php +++ b/tests/acceptance/SearchForStandardNewsletterCest.php @@ -7,6 +7,7 @@ use MailPoet\Test\DataFactories\Newsletter; require_once __DIR__ . '/../DataFactories/Newsletter.php'; class SearchForStandardNewsletterCest { + function searchForStandardNewsletter(\AcceptanceTester $I) { $I->wantTo('Successfully search for an existing newsletter'); @@ -17,19 +18,19 @@ class SearchForStandardNewsletterCest { // step 1 - Prepare newsletter data $newsletterFactory = new Newsletter(); $newsletter = $newsletterFactory->withSubject($newsletter_title) - ->withType('standard') - ->create(); - + ->withType('standard') + ->create(); + // step 2 - Search $I->login(); $I->amOnMailpoetPage('Emails'); $I->fillField('#search_input', $failure_condition_newsletter); $I->click('Search'); $I->wait(5); - $I->dontSee($newsletter_title); + $I->dontSee($newsletter_title); $I->fillField('#search_input', $newsletter_title); $I->click('Search'); $I->waitForText($newsletter_title, 20); } - -} \ No newline at end of file + +} diff --git a/tests/acceptance/SubscribersListingCest.php b/tests/acceptance/SubscribersListingCest.php index c2fcc867ae..1dcdd67b16 100644 --- a/tests/acceptance/SubscribersListingCest.php +++ b/tests/acceptance/SubscribersListingCest.php @@ -3,6 +3,7 @@ namespace MailPoet\Test\Acceptance; class SubscribersListingCest { + function subscribersListing(\AcceptanceTester $I) { $I->wantTo('Open subscribers listings page'); @@ -12,4 +13,5 @@ class SubscribersListingCest { $I->waitForText('wp@example.com', 5, '[data-automation-id="listing_item_1"]'); $I->see('subscriber@example.com', '[data-automation-id="listing_item_2"]'); } -} \ No newline at end of file + +} diff --git a/tests/acceptance/SubscriptionFormCest.php b/tests/acceptance/SubscriptionFormCest.php index f37319bc36..4327047aae 100644 --- a/tests/acceptance/SubscriptionFormCest.php +++ b/tests/acceptance/SubscriptionFormCest.php @@ -1,78 +1,82 @@ -subscriber_email = 'test-form@example.com'; - } - - function subscriptionFormWidget(\AcceptanceTester $I) { - $form_name = 'Subscription Acceptance Test Form'; - $form_factory = new Form(); - $form = $form_factory->withName($form_name)->create(); - $I->wantTo('Subscribe using form widget'); - - $I->cli('widget add mailpoet_form sidebar-1 2 --form=' . $form->id . ' --title="Subscribe to Our Newsletter" --allow-root'); - - $I->amOnPage('/'); - $I->fillField('[data-automation-id=\'form_email\']', $this->subscriber_email); - $I->click('.mailpoet_submit'); - $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); - $I->seeNoJSErrors(); - - $I->cli('widget reset sidebar-1 --allow-root'); - } - - function subscriptionFormShortcode(\AcceptanceTester $I) { - $I->wantTo('Subscribe using form shortcode'); - - $I->amOnPage('/form-test'); - $I->fillField('[data-automation-id=\'form_email\']', $this->subscriber_email); - $I->click('.mailpoet_submit'); - $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); - $I->seeNoJSErrors(); - $I->seeCurrentUrlEquals('/form-test/'); - } - - function subscriptionFormIframe(\AcceptanceTester $I) { - $I->wantTo('Subscribe using iframe form'); - - $I->amOnPage('/form-test'); - $I->switchToIframe('mailpoet_form_iframe'); - $I->fillField('[data-automation-id=\'form_email\']', $this->subscriber_email); - $I->click('.mailpoet_submit'); - $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); - $I->seeNoJSErrors(); - } - - /** - * @depends subscriptionFormWidget - */ - function subscriptionConfirmation(\AcceptanceTester $I) { - $I->amOnUrl('http://mailhog:8025'); - $I->click(Locator::contains('span.subject', 'Confirm your subscription')); - $I->switchToIframe('preview-html'); - $I->click('Click here to confirm your subscription'); - $I->switchToNextTab(); - $I->see('You have subscribed'); - $I->seeNoJSErrors(); - - $I->amOnUrl('http://wordpress'); - $I->login(); - $I->amOnMailpoetPage('Subscribers'); - $I->waitForText($this->subscriber_email); - $I->see('Subscribed', Locator::contains('tr', $this->subscriber_email)); - } - - function _after(\AcceptanceTester $I) { - $I->cli('db query "TRUNCATE TABLE mp_mailpoet_subscriber_ips" --allow-root'); - } -} +subscriber_email = 'test-form@example.com'; + } + + function subscriptionFormWidget(\AcceptanceTester $I) { + $form_name = 'Subscription Acceptance Test Form'; + $form_factory = new Form(); + $form = $form_factory->withName($form_name)->create(); + $I->wantTo('Subscribe using form widget'); + + $I->cli('widget add mailpoet_form sidebar-1 2 --form=' . $form->id . ' --title="Subscribe to Our Newsletter" --allow-root'); + + $I->amOnPage('/'); + $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); + $I->click('.mailpoet_submit'); + $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); + $I->seeNoJSErrors(); + + $I->cli('widget reset sidebar-1 --allow-root'); + } + + function subscriptionFormShortcode(\AcceptanceTester $I) { + $I->wantTo('Subscribe using form shortcode'); + + $I->amOnPage('/form-test'); + $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); + $I->click('.mailpoet_submit'); + $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); + $I->seeNoJSErrors(); + $I->seeCurrentUrlEquals('/form-test/'); + } + + function subscriptionFormIframe(\AcceptanceTester $I) { + $I->wantTo('Subscribe using iframe form'); + + $I->amOnPage('/form-test'); + $I->switchToIframe('mailpoet_form_iframe'); + $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); + $I->click('.mailpoet_submit'); + $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); + $I->seeNoJSErrors(); + } + + /** + * @depends subscriptionFormWidget + */ + function subscriptionConfirmation(\AcceptanceTester $I) { + $I->amOnUrl('http://mailhog:8025'); + $I->click(Locator::contains('span.subject', 'Confirm your subscription')); + $I->switchToIframe('preview-html'); + $I->click('Click here to confirm your subscription'); + $I->switchToNextTab(); + $I->see('You have subscribed'); + $I->seeNoJSErrors(); + + $I->amOnUrl('http://wordpress'); + $I->login(); + $I->amOnMailpoetPage('Subscribers'); + $I->waitForText($this->subscriber_email); + $I->see('Subscribed', Locator::contains('tr', $this->subscriber_email)); + } + + function _after(\AcceptanceTester $I) { + $I->cli('db query "TRUNCATE TABLE mp_mailpoet_subscriber_ips" --allow-root'); + } +} diff --git a/tests/acceptance/SubscriptionFormEditCest.php b/tests/acceptance/SubscriptionFormEditCest.php index b0c507d3e9..bfa6c893c4 100644 --- a/tests/acceptance/SubscriptionFormEditCest.php +++ b/tests/acceptance/SubscriptionFormEditCest.php @@ -9,12 +9,12 @@ require_once __DIR__ . '/../DataFactories/Form.php'; class SubscriptionFormEditCest { function editForm(\AcceptanceTester $I) { - + //Step one - create form from factory $form_name = 'Testing Form Edit'; $form_edited_name = 'Testing Form Edited'; $form_factory = new Form(); - $form = $form_factory->withName($form_name)->create(); + $form_factory->withName($form_name)->create(); //Step two - Edit the form title $I->wantTo('Edit a form'); $I->login(); @@ -25,13 +25,12 @@ class SubscriptionFormEditCest { $I->waitForElement($title_element, 10); $I->seeInCurrentUrl('mailpoet-form-editor'); $I->fillField($title_element, $form_edited_name); - $search_field_element = 'input.select2-search__field'; - $I->fillField($search_field_element, 'My First List'); - $I->pressKey($search_field_element, \WebDriverKeys::ENTER); + $I->selectOptionInSelect2('My First List'); $I->click('[data-automation-id="save_form"]'); //Step three - assertions $I->waitForText('Saved! Add this form to a widget.', 10); $I->amOnMailpoetPage('Forms'); $I->waitForText($form_edited_name); - } -} \ No newline at end of file + } + +} diff --git a/tests/acceptance/SubscriptionFormMultipleListsCest.php b/tests/acceptance/SubscriptionFormMultipleListsCest.php index f95ad886a1..edd615a455 100644 --- a/tests/acceptance/SubscriptionFormMultipleListsCest.php +++ b/tests/acceptance/SubscriptionFormMultipleListsCest.php @@ -53,4 +53,5 @@ class SubscriptionFormMultipleListsCest { $I->waitForText($subscriber_email); $I->see('Subscribed', Locator::contains('tr', $subscriber_email)); } + }