62 lines
2.4 KiB
TypeScript
62 lines
2.4 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test.describe.configure({ mode: "serial" });
|
|
|
|
test("public health and HTTPS-facing shell are available", async ({ page, request, baseURL }) => {
|
|
const readiness = await request.get("/health/ready");
|
|
expect(readiness.ok()).toBeTruthy();
|
|
expect(await readiness.json()).toMatchObject({ status: "ready", database: "up" });
|
|
|
|
await page.goto("/login");
|
|
await expect(page).toHaveTitle(/Fleet Ops/);
|
|
await expect(page.getByRole("button", { name: "Verken als Operationsmanager" })).toBeVisible();
|
|
if (baseURL?.startsWith("https://")) {
|
|
expect(page.url()).toMatch(/^https:\/\//);
|
|
}
|
|
});
|
|
|
|
test("non-destructive operator canary covers routes and grounded knowledge", async ({ page }) => {
|
|
const pageErrors: string[] = [];
|
|
const serverErrors: string[] = [];
|
|
page.on("pageerror", (error) => pageErrors.push(error.message));
|
|
page.on("response", (response) => {
|
|
if (response.status() >= 500) serverErrors.push(`${response.status()} ${response.url()}`);
|
|
});
|
|
|
|
await page.goto("/login");
|
|
await page.getByRole("button", { name: "Verken als Operationsmanager" }).click();
|
|
await expect(page).toHaveURL(/\/dashboard$/);
|
|
if (pageErrors.some((message) => message.toLowerCase().includes("dynamically imported module"))) {
|
|
// A deploy can replace the SPA between loading index.html and its lazy
|
|
// dashboard chunk. One clean reload must recover; a persistent chunk or
|
|
// server error is collected again and still fails the canary below.
|
|
pageErrors.length = 0;
|
|
await page.reload({ waitUntil: "domcontentloaded" });
|
|
await expect(page).toHaveURL(/\/dashboard$/);
|
|
await expect(page.locator("main")).toBeVisible();
|
|
}
|
|
|
|
for (const [path, heading] of [
|
|
["/vehicles", "Wagenpark"],
|
|
["/bookings", "Boekingen"],
|
|
["/data-quality", "Datakwaliteit"],
|
|
["/automation", "Integratiebeheer"],
|
|
["/audit", "Auditgeschiedenis"],
|
|
] as const) {
|
|
await page.goto(path);
|
|
await expect(page.getByRole("heading", { name: heading }).first()).toBeVisible();
|
|
}
|
|
|
|
await page.goto("/knowledge");
|
|
await page
|
|
.getByRole("textbox", { name: "Vraag" })
|
|
.fill("Wat moet ik doen wanneer een voertuig terugkomt met schade?");
|
|
await page.getByRole("button", { name: "Vraag stellen" }).click();
|
|
await expect(page.getByText("Onderbouwd met geciteerde procedures")).toBeVisible({
|
|
timeout: 20_000,
|
|
});
|
|
|
|
expect(pageErrors).toEqual([]);
|
|
expect(serverErrors).toEqual([]);
|
|
});
|