Files
clawmates/frontend/tests/e2e/visual.spec.ts
T
Omar Sobh c417097db2
ci / gates (push) Successful in 6s
ci / frontend (push) Successful in 40s
ci / rust (push) Successful in 3m2s
ci / publish (push) Successful in 42s
ci / e2e (push) Failing after 8m53s
LoginForm: restore proper <label> elements + update e2e tests to the single-step flow
The local-mode LoginForm had drifted to using styled <div> elements as
labels. That's an a11y regression — screen readers can't associate the
label text with the input, and it broke every e2e sign-in helper because
playwright's getByLabel needs a real <label htmlFor="…"> (or aria-label)
association. Restore proper <label htmlFor="email"|"password"> with
matching id="…" on the inputs; keeps the current design comp untouched.

The tests were also written for an OLDER two-step flow — enter email →
click "Continue with work email" → enter password → click "Sign in".
The current form is single-step (both fields, one Sign in click). Update
the shared signIn helper in every spec (p0-p8 + visual) to match, and
switch the label selector to "Email address" so it matches the newly
restored <label> text. Drop the stale a11y assertion in p6 that expected
the two-step button.

Also refresh the marketing landing check in p0-shell.spec.ts:20-22 —
"agentic systems" was in the H1 in an older copy pass; today's H1 is
"Deploy agents at any scale." Update the selector.

Together this unblocks ~30 of the 32 e2e failures; the remaining handful
are downstream product/test drift that will need per-test attention.
2026-07-05 21:27:34 -07:00

121 lines
4.6 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test";
// Visual-regression lock (plan P6): pixel baselines for the §2 design
// system on the primary surfaces. Baselines are PER-PLATFORM (rendering
// differs across OSes); CI excludes @visual until linux baselines are
// generated there — see ci.yml. Regenerate intentionally with:
// npx playwright test visual --update-snapshots
const OWNER_EMAIL = "[email protected]";
const OWNER_PASSWORD = "e2e-password";
const SCREENSHOT = {
animations: "disabled" as const,
maxDiffPixelRatio: 0.02,
};
async function signIn(page: Page) {
await page.goto("/login");
await page.getByLabel("Email address").fill(OWNER_EMAIL);
await page.getByLabel("Password").fill(OWNER_PASSWORD);
await page.getByRole("button", { name: "Sign in" }).click();
// Wait for the real workspace home — the login page also has a lowercase
// "clawmates" heading, so confirm navigation and match case-sensitively.
await page.waitForURL((url) => !url.pathname.endsWith("/login"));
await expect(
page.getByRole("heading", { name: "Clawmates", exact: true }),
).toBeVisible();
}
test("login page looks right @visual", async ({ page }) => {
await page.goto("/login");
await expect(page).toHaveScreenshot("login.png", SCREENSHOT);
});
test("workspace home looks right @visual", async ({ page }) => {
await signIn(page);
await expect(page).toHaveScreenshot("workspace-home.png", SCREENSHOT);
});
test("chat welcome and computer panel look right @visual", async ({
page,
}) => {
await signIn(page);
await page.getByRole("link", { name: /Scout/ }).click();
await expect(page).toHaveURL(/\/claws\/.+\/chat\//);
const before = page.url();
await page.getByRole("button", { name: "New" }).click();
await page.waitForURL((url) => url.toString() !== before);
await expect(
page.getByRole("heading", { name: /Hi, I'm Scout/ }),
).toBeVisible();
await expect(page).toHaveScreenshot("chat-welcome.png", SCREENSHOT);
await page.getByRole("button", { name: "Computer" }).click();
const panel = page.getByRole("complementary", { name: "Computer" });
await expect(panel.getByText(/Scout's Computer/)).toBeVisible();
await expect(page).toHaveScreenshot("computer-home.png", SCREENSHOT);
});
test("credits page looks right @visual", async ({ page }) => {
await signIn(page);
await page.getByRole("link", { name: "Credits" }).click();
await expect(page.getByText("Available credits")).toBeVisible();
await expect(page).toHaveScreenshot("credits.png", {
...SCREENSHOT,
// Balance and usage are live numbers — mask them, lock the layout.
// Balance and the whole usage card are live (and the runway line
// appears/disappears with burn) — mask them, lock the layout.
mask: [
page.getByTestId("credit-balance"),
page.getByTestId("usage-card"),
],
});
});
test("marketing landing looks right @visual", async ({ page, context }) => {
await context.clearCookies();
await page.goto("/");
await expect(
page.getByRole("heading", { name: /agentic systems/i }),
).toBeVisible();
// Below-the-fold art is lazy-loaded; scroll the page to trigger every
// loader, then wait for each image to finish before the full-page shot so
// the baseline isn't missing the deeper sections' art.
await page.evaluate(async () => {
for (let y = 0; y < document.body.scrollHeight; y += 600) {
window.scrollTo(0, y);
await new Promise((r) => setTimeout(r, 80));
}
window.scrollTo(0, 0);
const start = performance.now();
while (performance.now() - start < 8000) {
const imgs = Array.from(document.images);
if (imgs.every((i) => i.complete && i.naturalWidth > 0)) break;
await new Promise((r) => setTimeout(r, 100));
}
});
await page.waitForLoadState("networkidle");
await page.evaluate(() =>
Promise.allSettled(document.getAnimations().map((a) => a.finished)),
);
await expect(page).toHaveScreenshot("marketing.png", {
...SCREENSHOT,
fullPage: true,
// The hero backdrop is an animated, randomized canvas — mask it so the
// baseline stays deterministic (the heading is asserted separately above).
mask: [page.locator("[data-hero-ambient]")],
});
});
test("team org chart looks right @visual", async ({ page }) => {
await signIn(page);
await page.getByRole("link", { name: "Team", exact: true }).click();
await page.getByRole("tab", { name: "Claw org chart" }).click();
await expect(page.getByRole("tab", { name: "Claw org chart" })).toHaveAttribute(
"aria-selected",
"true",
);
await expect(page).toHaveScreenshot("team-orgchart.png", SCREENSHOT);
});