From 28f497ec615f72f9efdba19741e639e9e96ccdee Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Fri, 20 May 2022 17:07:04 +0200 Subject: [PATCH] Improve ManageSubscribers acceptance test stability The test was randomly failing when asserting subscriber state within subscriber edit form and was also failing when attempting to click inactive subscribers filter in subscribers listing. I found that both these issues were related to the web driver clicking too early when the form or the list was still being rendered by React. In this commit, I fixed those by adding some waiting on some elements and making sure the subscriber edit form is already rendered. The failures were flaky, and I could not identify what exactly caused these tests to start failing. It is possible that some changes on the backend slightly affected API requests duration and the change in timing of rendering was big enough to cause the flakiness. [MAILPOET-4274] --- .../tests/acceptance/Subscribers/ManageSubscribersCest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mailpoet/tests/acceptance/Subscribers/ManageSubscribersCest.php b/mailpoet/tests/acceptance/Subscribers/ManageSubscribersCest.php index cdc242acfa..0c686ad313 100644 --- a/mailpoet/tests/acceptance/Subscribers/ManageSubscribersCest.php +++ b/mailpoet/tests/acceptance/Subscribers/ManageSubscribersCest.php @@ -199,12 +199,14 @@ class ManageSubscribersCest { $i->waitForElementVisible('[data-automation-id="listing_item_1"]'); $i->clickItemRowActionByItemName($newSubscriberEmail, 'Edit'); $i->waitForText('Subscriber'); + $i->waitForElementNotVisible('.mailpoet_form_loading'); $i->seeOptionIsSelected('[data-automation-id="subscriber-status"]', 'Unsubscribed'); $i->see('Unsubscribed at', $unsubscribedMessage); // tag is visible $i->see('My tag'); $i->selectOptionInSelect2('Cooking'); $i->selectOptionInSelect2('Camping'); + $i->waitForElementClickable('[data-automation-id="subscriber-status"]'); $i->selectOption('[data-automation-id="subscriber-status"]', 'Subscribed'); // remove tag $i->click(Locator::firstElement('.mailpoet-form-field-tags button[aria-label="Remove item"]')); @@ -227,19 +229,20 @@ class ManageSubscribersCest { $i->amOnMailPoetPage ('Subscribers'); // Filter inactive subscribers + $i->waitForElement('[data-automation-id="filters_inactive"]'); $i->click('[data-automation-id="filters_inactive"]'); $i->waitForListingItemsToLoad(); $i->seeNumberOfElements('[data-automation-id^="listing_item_"]', self::INACTIVE_SUBSCRIBERS_COUNT); // Check inactive status in subscriber detail $i->click('@example.com'); - $i->waitForText('Subscriber'); + $i->waitForElementNotVisible('.mailpoet_form_loading'); $i->seeOptionIsSelected('[data-automation-id="subscriber-status"]', 'Inactive'); // Check correct list counts $i->amOnMailpoetPage('Lists'); $i->waitForListingItemsToLoad(); - $i->see(self::INACTIVE_LIST_NAME); + $i->waitForText(self::INACTIVE_LIST_NAME); $this->seeListCountByStatus($i, self::INACTIVE_SUBSCRIBERS_COUNT, self::INACTIVE_LIST_NAME, 'Inactive'); $this->seeListCountByStatus($i, self::ACTIVE_SUBSCRIBERS_COUNT, self::INACTIVE_LIST_NAME, 'Subscribed'); }