Diagnosis (reproduced by looping cold-server runs): the recurring "cold start" failures in the auth/follow specs were a hydration race, not a Vite dep-reload (the server.warmup config already handles that — no reload events in the logs). FollowButton is an onClick button, and Playwright considers it actionable (visible + enabled) before React attaches the handler on a freshly-navigated page. A click in that window is dropped (or triggers a native form submit), so the expected state change never happens — e.g. notifications.test.ts:59 clicked "Request to follow" with no hydration wait and the button never flipped to "Requested". The existing waitForHydration guard was applied per-interaction and so was easy to forget (test 1 had it, test 3 didn't). Fix it at the navigation instead: - add gotoHydrated(page, url) = goto + waitForHydration, documented as the default for "navigate then interact with a React control" - use it before every FollowButton interaction in notifications + social - consolidate the setProfileVisibility helper (copy-pasted in three specs, two missing the hydration wait) into e2e/helpers/profile.ts, built on gotoHydrated Validation against a fresh Postgres, cold servers: notifications 0/10 failures (was the proven flaker); notifications+social+explore 0/5 (55 tests); planner unaffected (25/25). Note: two other "cold-start"-attributed flakes are NOT this race and are out of scope here — planner map-load latency (mitigated by warmup + CI retries) and the /explore directory assertion (a local artifact of the scratch DB accumulating >20 public users; CI's fresh DB stays under the page size, so it doesn't bite there). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { test, expect, type CDPSession } from "./fixtures/test";
|
|
import { setupVirtualAuthenticator, registerUser } from "./helpers/auth";
|
|
import { setProfileVisibility } from "./helpers/profile";
|
|
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
test.describe("/explore", () => {
|
|
test("anonymous visitor can load /explore", async ({ page }) => {
|
|
const resp = await page.goto("/explore");
|
|
expect(resp?.status()).toBe(200);
|
|
await expect(page.getByRole("heading", { name: "Explore" })).toBeVisible();
|
|
});
|
|
|
|
test("private profile is excluded from the directory", async ({ page, browser }) => {
|
|
const cdp = await page.context().newCDPSession(page);
|
|
await setupVirtualAuthenticator(cdp);
|
|
|
|
const stamp = Date.now();
|
|
// A: signed-in viewer (public, default in test below)
|
|
const aEmail = `ex-a-${stamp}@example.com`;
|
|
const aUsername = `exa${stamp}`;
|
|
await registerUser(page, aEmail, aUsername);
|
|
await setProfileVisibility(page, "public");
|
|
|
|
// B: a separate user who stays at the default `private`
|
|
const bCtx = await browser.newContext();
|
|
const bPage = await bCtx.newPage();
|
|
const bCdp = await bPage.context().newCDPSession(bPage);
|
|
await setupVirtualAuthenticator(bCdp);
|
|
const bEmail = `ex-b-${stamp}@example.com`;
|
|
const bUsername = `exb${stamp}`;
|
|
await registerUser(bPage, bEmail, bUsername);
|
|
// B stays private — should NOT appear on /explore.
|
|
|
|
// A loads /explore — the directory should include A but not B.
|
|
await page.goto("/explore");
|
|
await expect(page.getByText(`@${aUsername}`)).toBeVisible({ timeout: 5000 });
|
|
await expect(page.getByText(`@${bUsername}`)).toHaveCount(0);
|
|
|
|
await bCtx.close();
|
|
});
|
|
});
|