Skip to content

Commit

Permalink
Merge pull request #285 from GoogleChrome/missing-prerender-tests
Browse files Browse the repository at this point in the history
Add missing prerender tests
  • Loading branch information
philipwalton committed Nov 15, 2022
2 parents 89affdf + be1df46 commit e03e92e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/e2e/onCLS-test.js
Expand Up @@ -632,6 +632,28 @@ describe('onCLS()', async function() {
assert.strictEqual(cls.navigationType, 'back-forward-cache');
});

it('reports prerender as nav type for prerender', async function() {
if (!browserSupportsCLS) this.skip();

await browser.url('/test/cls?prerender=1');

// Wait until all images are loaded and rendered, then change to hidden.
await imagesPainted();
await stubVisibilityChange('hidden');


await beaconCountIs(1);
const [cls] = await getBeacons();

assert(cls.value >= 0);
assert(cls.id.match(/^v3-\d+-\d+$/));
assert.strictEqual(cls.name, 'CLS');
assert.strictEqual(cls.value, cls.delta);
assert.strictEqual(cls.rating, 'good');
assert.strictEqual(cls.entries.length, 2);
assert.strictEqual(cls.navigationType, 'prerender');
});

it('reports restore as nav type for wasDiscarded', async function() {
if (!browserSupportsCLS) this.skip();

Expand Down
21 changes: 21 additions & 0 deletions test/e2e/onFID-test.js
Expand Up @@ -194,6 +194,27 @@ describe('onFID()', async function() {
assert.match(fid2.entries[0].name, /(mouse|pointer)down/);
});

it('reports prerender as nav type for prerender', async function() {
if (!browserSupportsFID) this.skip();

await browser.url('/test/fid?prerender=1');

// Click on the <h1>.
const h1 = await $('h1');
await h1.click();

await beaconCountIs(1);

const [fid] = await getBeacons();
assert(fid.value >= 0);
assert(fid.id.match(/^v3-\d+-\d+$/));
assert.strictEqual(fid.name, 'FID');
assert.strictEqual(fid.value, fid.delta);
assert.strictEqual(fid.rating, 'good');
assert.strictEqual(fid.navigationType, 'prerender');
assert.match(fid.entries[0].name, /(mouse|pointer)down/);
});

it('reports restore as nav type for wasDiscarded', async function() {
if (!browserSupportsFID) this.skip();

Expand Down
25 changes: 25 additions & 0 deletions test/e2e/onINP-test.js
Expand Up @@ -316,6 +316,31 @@ describe('onINP()', async function() {
assert.strictEqual(beacons.length, 0);
});

it('reports prerender as nav type for prerender', async function() {
if (!browserSupportsINP) this.skip();

await browser.url('/test/inp?click=100&prerender=1');


const h1 = await $('h1');
await h1.click();

await stubVisibilityChange('hidden');

await beaconCountIs(1);

const [inp] = await getBeacons();
assert(inp.value >= 0);
assert(inp.id.match(/^v3-\d+-\d+$/));
assert.strictEqual(inp.name, 'INP');
assert.strictEqual(inp.value, inp.delta);
assert.strictEqual(inp.rating, 'good');
assert(containsEntry(inp.entries, 'click', 'h1'));
assert(interactionIDsMatch(inp.entries));
assert(inp.entries[0].interactionId > 0);
assert.strictEqual(inp.navigationType, 'prerender');
});

it('reports restore as nav type for wasDiscarded', async function() {
if (!browserSupportsINP) this.skip();

Expand Down

0 comments on commit e03e92e

Please sign in to comment.