-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0c5594
commit a1fd61f
Showing
7 changed files
with
125 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { BeaconPayload } from "../../../src/beacon"; | ||
import { entryTypeSupported } from "../../helpers/browsers"; | ||
import RequestInterceptor from "../../request-interceptor"; | ||
|
||
test.describe("POST beacon LoAF", () => { | ||
test("LoAFs are measured", async ({ page }) => { | ||
const luxRequests = new RequestInterceptor(page).createRequestMatcher("/store/"); | ||
await page.goto("/long-animation-frames.html", { waitUntil: "networkidle" }); | ||
await page.goto("/default.html"); | ||
await luxRequests.waitForMatchingRequest(); | ||
const b = luxRequests.get(0)!.postDataJSON() as BeaconPayload; | ||
const loafSupported = await entryTypeSupported(page, "long-animation-frame"); | ||
|
||
if (loafSupported) { | ||
const loaf = b.loaf!; | ||
expect(loaf.totalBlockingDuration).toBeGreaterThan(0); | ||
expect(loaf.totalDuration).toBeGreaterThan(0); | ||
expect(loaf.totalEntries).toBeGreaterThan(0); | ||
expect(loaf.totalStyleAndLayoutDuration).toBeGreaterThan(0); | ||
expect(loaf.totalWorkDuration).toBeGreaterThan(0); | ||
expect(loaf.entries.length).toBeGreaterThan(0); | ||
expect(loaf.scripts.length).toBeGreaterThan(0); | ||
} else { | ||
expect(b.loaf).toBeUndefined(); | ||
} | ||
}); | ||
|
||
test("LoAFs are collected as INP attribution", async ({ page }) => { | ||
const luxRequests = new RequestInterceptor(page).createRequestMatcher("/store/"); | ||
await page.goto("/long-animation-frames.html", { waitUntil: "networkidle" }); | ||
await page.locator("#create-long-task").click(); | ||
await page.waitForTimeout(1000); | ||
await page.goto("/default.html"); | ||
await luxRequests.waitForMatchingRequest(); | ||
const b = luxRequests.get(0)!.postDataJSON() as BeaconPayload; | ||
const inpSupported = await entryTypeSupported(page, "event"); | ||
const loafSupported = await entryTypeSupported(page, "long-animation-frame"); | ||
const inp = b.inp!; | ||
|
||
if (inpSupported) { | ||
expect(inp.value).toBeGreaterThanOrEqual(0); | ||
} else { | ||
expect(inp).toBeUndefined(); | ||
} | ||
|
||
const loafScripts = inp.attribution!.loafScripts; | ||
|
||
if (loafSupported) { | ||
expect(loafScripts.length).toEqual(1); | ||
|
||
const script = loafScripts[0]; | ||
const sourceUrl = new URL(script.sourceUrl); | ||
const [scriptStartTime, scriptDuration] = script.timings[0]; | ||
|
||
expect(sourceUrl.pathname).toEqual("/long-animation-frames.html"); | ||
expect(script.invoker).toEqual("BUTTON#create-long-task.onclick"); | ||
expect(script.sourceFunctionName).toEqual("globalClickHandler"); | ||
expect(script.totalEntries).toEqual(1); | ||
expect(script.totalDuration).toBeGreaterThanOrEqual(50); | ||
expect(script.totalDuration).toBeLessThan(60); | ||
expect(scriptStartTime).toBeGreaterThanOrEqual(inp.startTime); | ||
expect(scriptDuration).toBeGreaterThanOrEqual(50); | ||
expect(scriptDuration).toBeLessThan(60); | ||
} else { | ||
expect(loafScripts.length).toEqual(0); | ||
} | ||
}); | ||
}); |
28 changes: 0 additions & 28 deletions
28
tests/integration/post-beacon/long-animation-frames.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters