Skip to content

Commit

Permalink
:chore: Add scenario and step for relative lcp image template -- #85 (#…
Browse files Browse the repository at this point in the history
…86)

* Closes #71: Use results file instead of API for lcps

* Comply feedback

* Fix bugs + Update tests results

* Updates expected results
Add is_mobile is sql query
Accept array for lcps

* Comply linter

* Comply feedback

* Updated fixture

* Updated hardcoded atf urls to relative (#81)

* Closes #70 Add scenario for pages without LCP/ATF (#76)

* Add scenario for no lcp/atf, add plugin deactivation function #70 :closes:

* fixed lint

* minor fix

* Add step to activate and deactivate mobile plugin

* update gitignore file

* PR modifications

* Add new command function, pr modifications --#70

* minor modifications

* Add beacon check for lcp pages

* deactivate plugin, modify json

* Add missing step

* change steps

* Closes #82: LCP test not failing with no result in db (#84)

* Make tests fail when no result in db

* Fail tests early

* Make log red

* :chore: Add scenario and step for relative lcp image template -- #85

* PR modifications

---------

Co-authored-by: Gael Robin <[email protected]>
Co-authored-by: Michael Lee <[email protected]>
Co-authored-by: Michael Lee <[email protected]>
  • Loading branch information
4 people authored May 29, 2024
1 parent fb0c0e6 commit 0b38b11
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/features/lcp-beacon-image.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@lcp @setup
Feature: Fetchpriority should be applied to image

Background:
Given I am logged in
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
Then lcp image in 'lcp_regular_image_template' has fetchpriority
26 changes: 26 additions & 0 deletions src/support/steps/lcp-beacon-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,29 @@ Then('lcp and atf should be as expected for {string}', async function (this: ICu
expect(truthy).toBeTruthy();
});

Then('lcp image in {string} has fetchpriority', async function (this: ICustomWorld, page) {
await this.page.setViewportSize({
width: 1600,
height: 700
});
truthy= false;

await this.utils.visitPage(page);
await this.utils.scrollDownBottomOfAPage();

const imageWithFetchPriority = await this.page.evaluate(() => {
const images = document.querySelectorAll('img');
return Array.from(images).map(img => ({
src: img.getAttribute('src'),
fetchpriority: img.getAttribute('fetchpriority') || false
}));
});

for (const image of imageWithFetchPriority) {
if(image.src === '/wp-content/rocket-test-data/images/600px-Mapang-test.gif' && image.fetchpriority !== false) {
truthy = true
}
}

expect(truthy).toBeTruthy();
});

0 comments on commit 0b38b11

Please sign in to comment.