From a47e0e1f51a40db439226b7eb8a79376d8b5c2f0 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Mon, 19 Aug 2024 12:12:50 +0300 Subject: [PATCH 1/4] updated cache clear to assert the notice, removed scroll from the fetch priority feature , renamed the feature and re-organized steps --- src/features/lcp-beacon-image.feature | 16 +++++++--------- src/support/steps/general.ts | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/features/lcp-beacon-image.feature b/src/features/lcp-beacon-image.feature index c66f518..65b1763 100644 --- a/src/features/lcp-beacon-image.feature +++ b/src/features/lcp-beacon-image.feature @@ -6,14 +6,12 @@ Feature: Fetchpriority should be applied to image And plugin is installed 'new_release' And plugin is activated And I go to 'wp-admin/options-general.php?page=wprocket#dashboard' - - Scenario: When I visited a page that has LCP with relative image - When I log out - And I visit page 'lcp_regular_image_template' with browser dimension 1600 x 700 - And I scroll to bottom of page - And I am logged in + And I log out +@test + Scenario: Should add fetchpriority to lcp image + Given I visit page 'lcp_regular_image_template' with browser dimension 1600 x 700 + When I am logged in And I clear cache And I log out - And I visit page 'lcp_regular_image_template' with browser dimension 1600 x 700 - And I scroll to bottom of page - Then lcp image should have fetchpriority \ No newline at end of file + Then I visit page 'lcp_regular_image_template' with browser dimension 1600 x 700 + And lcp image should have fetchpriority \ No newline at end of file diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 55ffa16..ecb486e 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -247,7 +247,7 @@ When('I clear cache', async function (this:ICustomWorld) { this.sections.set('dashboard'); await this.sections.toggle('clearCacheBtn'); - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('WP Rocket: Cache cleared.')).toBeVisible(); }); /** From c382d554902b7ca93a2482510026d75c161ed9d4 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Mon, 19 Aug 2024 21:54:35 +0300 Subject: [PATCH 2/4] update logout to assert on notice instead of waitForLoadState --- utils/page-utils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 8386234..4e0a1fd 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -283,10 +283,8 @@ export class PageUtils { await this.page.locator('#wp-admin-bar-my-account').hover(); await this.page.waitForSelector('#wp-admin-bar-logout'); await this.page.locator('#wp-admin-bar-logout a').click(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); - await this.page.waitForTimeout(3000); - } + await expect(this.page.getByText('You are now logged out.')).toBeVisible(); + } /** * Performs Wordpress login action. From 1bbc2e279dc9e4c5fa898e55ca2990dd36d6776b Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 20 Aug 2024 05:41:15 +0300 Subject: [PATCH 3/4] removed unneeded other waitForLoadState for logout --- src/support/steps/general.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index ecb486e..30cfe75 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -155,7 +155,6 @@ When('I enable all settings', async function (this: ICustomWorld) { */ When('I log out', async function (this: ICustomWorld) { await this.utils.wpAdminLogout(); - await this.page.waitForLoadState('load', { timeout: 30000 }); }); /** From 01c066599c9f2f72c4c8711bb6cd0cdd76515c26 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 20 Aug 2024 06:16:20 +0300 Subject: [PATCH 4/4] removed unnecessary if condition. if we can't logout, we shouldn't call this function --- utils/page-utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 4e0a1fd..3ac1b56 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -277,9 +277,7 @@ export class PageUtils { * @return {Promise} */ public wpAdminLogout = async (): Promise => { - if(! await this.page.locator('#wp-admin-bar-my-account').isVisible()) { - return ; - } + await this.page.locator('#wp-admin-bar-my-account').isVisible(); await this.page.locator('#wp-admin-bar-my-account').hover(); await this.page.waitForSelector('#wp-admin-bar-logout'); await this.page.locator('#wp-admin-bar-logout a').click();