Files
CapaKraken/apps/web/e2e/scenarios.spec.ts
Hartmut 6c7245db93 test(e2e): add Playwright tests for core workflows
Covers auth redirect, resource/project list filtering, timeline render,
sidebar navigation, and staffing panel. Gives deploy confidence for
the main happy paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 19:30:43 +02:00

57 lines
1.9 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test";
async function signIn(page: Page) {
await page.goto("/auth/signin");
await page.fill('input[type="email"]', "admin@capakraken.dev");
await page.fill('input[type="password"]', "admin123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL(/\/(dashboard|resources)/);
}
test.describe("Scenario Planning", () => {
test.beforeEach(async ({ page }) => {
await signIn(page);
await page.goto("/scenarios");
});
test("scenarios page loads with heading", async ({ page }) => {
await page.waitForLoadState("networkidle");
await expect(
page.locator("h1", { hasText: /Scenario Planning/i }),
).toBeVisible({ timeout: 10000 });
});
test("shows scenarios list or empty state", async ({ page }) => {
await page.waitForLoadState("networkidle");
await expect(
page.locator("table")
.or(page.locator("text=No scenarios"))
.or(page.locator("text=Create a project first"))
.or(page.locator("[data-testid]"))
.first(),
).toBeVisible({ timeout: 10000 });
});
test("page subtitle describes what-if staffing scenarios", async ({ page }) => {
await page.waitForLoadState("networkidle");
await expect(
page.locator("text=what-if").or(page.locator("text=staffing scenarios")).first(),
).toBeVisible({ timeout: 10000 });
});
test("no console errors on load", async ({ page }) => {
const consoleErrors: string[] = [];
page.on("console", (msg) => {
if (msg.type() === "error") {
consoleErrors.push(msg.text());
}
});
await page.goto("/scenarios");
await page.waitForLoadState("networkidle");
const appErrors = consoleErrors.filter(
(e) => !e.includes("extension") && !e.includes("favicon"),
);
expect(appErrors, `Unexpected console errors: ${appErrors.join("\n")}`).toHaveLength(0);
});
});