Skip to content

Commit

Permalink
Closes #72: Change the way we load the page for LCP (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld authored May 10, 2024
1 parent 3223b03 commit d8abcb9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/support/steps/lcp-beacon-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ Given('I visit the following urls in {string}', async function (this: ICustomWor
for (const row of data) {
const url: string = `${WP_BASE_URL}/${row[0]}`;
await this.utils.visitPage(row[0]);
// Wait for 2 seconds before fetching from DB.
await this.page.waitForTimeout(2000);
// Wait the beacon to add an attribute `beacon-complete` to true before fetching from DB.
await this.page.waitForFunction(() => {
const beacon = document.querySelector('[data-name="wpr-lcp-beacon"]');
return beacon && beacon.getAttribute('beacon-completed') === 'true';
});

// Get the LCP/ATF from the DB
sql = `SELECT lcp, viewport FROM ${tablePrefix}wpr_above_the_fold WHERE url LIKE "%${row[0]}%"`;
Expand Down

0 comments on commit d8abcb9

Please sign in to comment.