Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing prerender tests #285

Merged
merged 3 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/e2e/onCLS-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,27 @@ 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');

const activationStart = await browser.execute(() => {
tunetheweb marked this conversation as resolved.
Show resolved Hide resolved
return performance.getEntriesByType('navigation')[0].activationStart;
});

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
25 changes: 25 additions & 0 deletions test/e2e/onFID-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,31 @@ 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');

const activationStart = await browser.execute(() => {
return performance.getEntriesByType('navigation')[0].activationStart;
});

// 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
29 changes: 29 additions & 0 deletions test/e2e/onINP-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,35 @@ 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 activationStart = await browser.execute(() => {
return performance.getEntriesByType('navigation')[0].activationStart;
});


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