2fc71883d7
The shell had no way to end a session on shared booth machines; the new button signs out and returns to the login page. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
86 lines
2.8 KiB
TypeScript
86 lines
2.8 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { signInAs, BASE } from "./dev";
|
|
|
|
const TAB_LABELS = [
|
|
"Home",
|
|
"Schedule",
|
|
"Events",
|
|
"Media",
|
|
"Roster",
|
|
"Training",
|
|
"Announcements",
|
|
"Settings",
|
|
];
|
|
|
|
test.describe("app shell", () => {
|
|
test("renders the shell with 8 nav tabs at a 360px viewport", async ({ page }) => {
|
|
await page.setViewportSize({ width: 360, height: 780 });
|
|
await signInAs(page, `e2e-mobile-${Date.now()}@example.com`);
|
|
|
|
await page.goto(`${BASE}/schedule`);
|
|
await expect(page).toHaveURL(`${BASE}/schedule`);
|
|
|
|
// Header + page title.
|
|
await expect(page.getByRole("heading", { name: "Schedule", level: 1 })).toBeVisible();
|
|
|
|
// One tab per primary destination.
|
|
for (const label of TAB_LABELS) {
|
|
await expect(page.getByRole("link", { name: label, exact: true })).toBeVisible();
|
|
}
|
|
|
|
// The current tab is marked active.
|
|
await expect(page.getByRole("link", { name: "Schedule" })).toHaveAttribute(
|
|
"aria-current",
|
|
"page",
|
|
);
|
|
|
|
// The schedule grid renders (unit D7): role columns and an instance row.
|
|
await expect(page.getByText("Audio")).toBeVisible();
|
|
await expect(page.getByText("Livestream")).toBeVisible();
|
|
await expect(page.getByText("Slides")).toBeVisible();
|
|
});
|
|
|
|
test("shows the desktop rail inside the shell at desktop width", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1024, height: 768 });
|
|
await signInAs(page, `e2e-desktop-${Date.now()}@example.com`);
|
|
|
|
await page.goto(`${BASE}/roster`);
|
|
for (const label of TAB_LABELS) {
|
|
await expect(page.getByRole("link", { name: label, exact: true })).toBeVisible();
|
|
}
|
|
// Active tab follows the route.
|
|
await expect(page.getByRole("link", { name: "Roster" })).toHaveAttribute(
|
|
"aria-current",
|
|
"page",
|
|
);
|
|
});
|
|
|
|
test("signs out and locks the shell again", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1024, height: 768 });
|
|
await signInAs(page, `e2e-signout-${Date.now()}@example.com`);
|
|
|
|
await page.goto(`${BASE}/home`);
|
|
await page.getByRole("button", { name: "Sign out" }).click();
|
|
await expect(page).toHaveURL(`${BASE}/login`);
|
|
|
|
// The session cookie is gone, so the guarded shell bounces back to login.
|
|
await page.goto(`${BASE}/home`);
|
|
await expect(page).toHaveURL(`${BASE}/login`);
|
|
});
|
|
|
|
test("redirects unauthenticated users away from the shell", async ({ page }) => {
|
|
await page.setViewportSize({ width: 360, height: 780 });
|
|
await page.goto(`${BASE}/schedule`);
|
|
await expect(page).toHaveURL(`${BASE}/login`);
|
|
});
|
|
});
|
|
|
|
test.describe("health", () => {
|
|
test("/api/health returns ok", async ({ request }) => {
|
|
const res = await request.get(`${BASE}/api/health`);
|
|
expect(res.ok()).toBe(true);
|
|
const body = (await res.json()) as { status: string };
|
|
expect(body.status).toBe("ok");
|
|
});
|
|
});
|