Skip to content

Commit

Permalink
Merge pull request #135 from wp-media/enhancement/refactor-clear-cache
Browse files Browse the repository at this point in the history
Refactor cache clear step and logout
  • Loading branch information
Mai-Saad authored Aug 20, 2024
2 parents 4b9d7bc + 01c0665 commit 6f98cf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
16 changes: 7 additions & 9 deletions src/features/lcp-beacon-image.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Then I visit page 'lcp_regular_image_template' with browser dimension 1600 x 700
And lcp image should have fetchpriority
3 changes: 1 addition & 2 deletions src/support/steps/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});

/**
Expand Down Expand Up @@ -247,7 +246,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();
});

/**
Expand Down
10 changes: 3 additions & 7 deletions utils/page-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,12 @@ export class PageUtils {
* @return {Promise<void>}
*/
public wpAdminLogout = async (): Promise<void> => {
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();

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.
Expand Down

0 comments on commit 6f98cf7

Please sign in to comment.