The virtual-authenticator setup and registerUser were copy-pasted into six spec files and had drifted: the auth spec's copy lost the final URL assertion, and the settings spec's variant skipped hydration and the Terms checkbox entirely. Seed-route boilerplate and hardcoded localhost URLs were repeated across three more files. - helpers/auth.ts: setup/removeVirtualAuthenticator, submitRegistration (no outcome assertion, for expected-failure attempts), registerUser (asserts the signed-in redirect), registerFreshUser, logout - helpers/journal.ts: JOURNAL/PLANNER base URLs, seedRoute, routeHasGeom, seedKomootConnection - nine spec files now import the helpers instead of re-deriving them Found while consolidating: settings.test.ts, explore.test.ts, and social.test.ts are not matched by any playwright project and have never run — which is how the settings spec's broken register helper survived. Registering them (and fixing whatever has rotted) is a follow-up; the config now carries a warning so the trap is at least documented. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
2 KiB
TypeScript
48 lines
2 KiB
TypeScript
import { test, expect, waitForHydration, type CDPSession, type Page } from "./fixtures/test";
|
|
import { setupVirtualAuthenticator, registerUser } from "./helpers/auth";
|
|
|
|
async function setProfileVisibility(page: Page, value: "public" | "private") {
|
|
await page.goto("/settings");
|
|
await page.locator(`input[type=radio][name=profileVisibility][value=${value}]`).check();
|
|
await page.getByRole("button", { name: /^Save$/ }).first().click();
|
|
await expect(page.getByText("Profile saved.")).toBeVisible({ timeout: 10000 });
|
|
}
|
|
|
|
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();
|
|
});
|
|
});
|