From 56c0eb8cba899d802a27858c50e44ec7d18cd92b Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Tue, 26 Nov 2019 10:47:52 +0100 Subject: [PATCH] Add comments for scroll offsets [MAILPOET-2544] --- tests/_support/AcceptanceTester.php | 4 +++- tests/acceptance/ManageSubscriptionLinkCest.php | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 7a5832dc3c..2e2ead6ff3 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -342,7 +342,9 @@ class AcceptanceTester extends \Codeception\Actor { // phpcs:ignore PSR1.Classes */ public function selectPaymentMethod($method = 'cod') { $I = $this; - $I->scrollTo('#payment_method_' . $method, 0, -40); + // We need to scroll with some negative offset so that the input is not hidden above the top page fold + $approximate_payment_method_input_height = 40; + $I->scrollTo('#payment_method_' . $method, 0, -$approximate_payment_method_input_height); $I->waitForElementNotVisible('.blockOverlay', 30); // wait for payment method loading overlay to disappear $I->click('#payment_method_' . $method); } diff --git a/tests/acceptance/ManageSubscriptionLinkCest.php b/tests/acceptance/ManageSubscriptionLinkCest.php index 24631bf286..eedb52e214 100644 --- a/tests/acceptance/ManageSubscriptionLinkCest.php +++ b/tests/acceptance/ManageSubscriptionLinkCest.php @@ -45,15 +45,16 @@ class ManageSubscriptionLinkCest { $form_status_element = '[data-automation-id="form_status"]'; // set status to unsubscribed + $approximate_save_button_height = 50; // Used for scroll offset to ensure that button is not hidden above the top fold $I->selectOption($form_status_element, 'Unsubscribed'); - $I->scrollTo('[data-automation-id="subscribe-submit-button"]', 0, -50); + $I->scrollTo('[data-automation-id="subscribe-submit-button"]', 0, -$approximate_save_button_height); $I->click('Save'); $I->waitForElement($form_status_element); $I->seeOptionIsSelected($form_status_element, 'Unsubscribed'); // change status back to subscribed $I->selectOption($form_status_element, 'Subscribed'); - $I->scrollTo('[data-automation-id="subscribe-submit-button"]', 0, -50); + $I->scrollTo('[data-automation-id="subscribe-submit-button"]', 0, -$approximate_save_button_height); $I->click('Save'); $I->waitForElement($form_status_element); $I->seeOptionIsSelected($form_status_element, 'Subscribed');