Files
clawmates/frontend/tests/e2e/p0-shell.spec.ts
T
Omar SobhandClaude Fable 5 fc173f170d P0 exit: e2e harness, Playwright shell journeys green, deploy skeleton
- teamclaw-server e2e mode (TEAMCLAW_MODE=e2e): idempotent deterministic
  seed through the real registration paths
- Playwright suite (6 journeys) against the real backend + prod Next build:
  login redirect, bad-password error, shell/roster/online-dot, team members,
  seeded credits, sign-out revocation — P0 exit criterion met
- Dockerfiles: musl-static server -> distroless, Next standalone -> distroless
  node (multi-arch via TARGETARCH)
- Air-gapped compose topology with edge/core/sandbox_net/secrets_net
  segmentation (engine-validated in CI), config-file + env-overlay pattern
- CI: compose validation + e2e job with trace upload

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-09 22:48:28 -05:00

82 lines
2.9 KiB
TypeScript

import { expect, test } from "@playwright/test";
// P0 exit criterion (spec §17): an authenticated empty shell against the
// real backend. Seed data comes from teamclaw-server's e2e mode.
const OWNER_EMAIL = "[email protected]";
const OWNER_PASSWORD = "e2e-password";
async function signIn(page: import("@playwright/test").Page) {
await page.goto("/login");
await page.getByLabel("Email").fill(OWNER_EMAIL);
await page.getByLabel("Password").fill(OWNER_PASSWORD);
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByRole("heading", { name: "TeamClaw" })).toBeVisible();
}
test("unauthenticated visitors are redirected to login", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveURL(/\/login$/);
await expect(page.getByRole("button", { name: "Sign in" })).toBeVisible();
});
test("wrong password shows an error and stays on login", async ({ page }) => {
await page.goto("/login");
await page.getByLabel("Email").fill(OWNER_EMAIL);
await page.getByLabel("Password").fill("wrong-password");
await page.getByRole("button", { name: "Sign in" }).click();
// Next.js's route announcer is also role="alert"; scope to the form's.
await expect(
page.getByRole("alert").filter({ hasText: "Invalid" }),
).toHaveText("Invalid email or password.");
await expect(page).toHaveURL(/\/login$/);
});
test("signing in reveals the shell: rail, roster, and current user", async ({
page,
}) => {
await signIn(page);
const rail = page.getByRole("complementary");
await expect(rail.getByText("teamclaw")).toBeVisible();
await expect(
rail.getByRole("list", { name: "Your claws" }).getByText("Scout"),
).toBeVisible();
await expect(
rail.getByRole("status", { name: "Scout is online" }),
).toBeVisible();
await expect(rail.getByText("Avery Owner")).toBeVisible();
});
test("team page lists workspace members from the real API", async ({
page,
}) => {
await signIn(page);
await page.getByRole("link", { name: "Team" }).click();
await expect(
page.getByRole("heading", { name: "Team", exact: true }),
).toBeVisible();
await expect(page.getByText("1 member in your workspace")).toBeVisible();
const row = page.getByRole("row").filter({ hasText: "Avery Owner" });
await expect(row.getByText(OWNER_EMAIL)).toBeVisible();
await expect(row.getByText("Owner", { exact: true })).toBeVisible();
});
test("credits page shows the seeded balance", async ({ page }) => {
await signIn(page);
await page.getByRole("link", { name: "Credits" }).click();
await expect(
page.getByRole("heading", { name: "Credits", exact: true }),
).toBeVisible();
await expect(page.getByText("1,250")).toBeVisible();
});
test("signing out returns to login and revokes the session", async ({
page,
}) => {
await signIn(page);
await page.getByRole("button", { name: "Sign out" }).click();
await expect(page).toHaveURL(/\/login$/);
await page.goto("/");
await expect(page).toHaveURL(/\/login$/);
});