Skip to content

Commit eb9933d

Browse files
test(e2e): assert portfolio readiness without network-idle waits
1 parent be848fe commit eb9933d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎e2e/portfolio-checks.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export async function runPortfolioChecks({ browser, base, backendOrigin }) {
9292
const url = new URL(request.url());
9393
if (/^https?:$/.test(url.protocol) && url.origin !== new URL(base).origin) foreignRequests.add(url.origin);
9494
});
95-
const response = await page.goto(base + "/u/" + username, { waitUntil: "networkidle" });
95+
// Next.js prefetch requests can outlive rendering; assert the loaded page's
96+
// status, content and privacy boundaries instead of waiting for network idle.
97+
const response = await page.goto(base + "/u/" + username, { waitUntil: "load" });
98+
await page.evaluate(() => document.fonts.ready);
9699
assert.equal(response?.status(), expectedStatus, `Public ${username} should return ${expectedStatus}`);
97100
if (expectedStatus === 200) {
98101
assert.equal(await page.locator("h1").count(), 1);
@@ -109,7 +112,7 @@ export async function runPortfolioChecks({ browser, base, backendOrigin }) {
109112
}
110113

111114
async function editor(page) {
112-
const response = await page.goto(base + EDITOR, { waitUntil: "networkidle" });
115+
const response = await page.goto(base + EDITOR, { waitUntil: "load" });
113116
assert.equal(response?.status(), 200);
114117
await page.getByRole("heading", { name: "Portfolio builder", exact: true }).waitFor();
115118
await until(() => page.getByRole("button", { name: "Save draft", exact: true }).isEnabled(), "Authenticated editor did not become ready");
@@ -403,7 +406,7 @@ export async function runPortfolioChecks({ browser, base, backendOrigin }) {
403406

404407
await run("guest", "guests can preview while private APIs and unpublished pages stay protected", async contexts => {
405408
const context = await browser.newContext({ viewport: { width: 390, height: 844 } }); contexts.push(context);
406-
const page = await context.newPage(); await page.goto(base + EDITOR, { waitUntil: "networkidle" });
409+
const page = await context.newPage(); await page.goto(base + EDITOR, { waitUntil: "load" });
407410
await page.getByRole("heading", { name: "Try the editor, then sign in to save", exact: true }).waitFor();
408411
await page.getByLabel("Name", { exact: true }).fill("Guest preview");
409412
assert.equal(await page.getByRole("button", { name: "Save draft", exact: true }).isDisabled(), true);

0 commit comments

Comments
 (0)