Files
MobilityOps/frontend/e2e/demo-legibility.spec.ts
NuklearRabbit 81e3fd63bd
MobilityOps acceptance / backend (push) Failing after 19s
MobilityOps acceptance / frontend (push) Successful in 25s
MobilityOps acceptance / e2e (push) Skipped
M54: harden operations and demo resilience
2026-08-24 03:31:03 +02:00

85 lines
4.4 KiB
TypeScript

import { expect, test, type APIRequestContext } from "@playwright/test";
async function resetDemoData(request: APIRequestContext) {
const login = await request.post("/api/v1/demo/login", { data: { role: "operations_manager" } });
expect(login.ok()).toBeTruthy();
const reset = await request.post("/api/v1/demo/reset");
expect(reset.ok()).toBeTruthy();
}
test.describe.configure({ mode: "serial" });
test("return flow pre-fills the suspicious odometer reading and explains why", async ({ page, request }) => {
await resetDemoData(request);
await page.goto("/login");
await page.getByRole("button", { name: "Verken als Operationsmanager" }).click();
await expect(page).toHaveURL(/\/dashboard$/);
await page.goto("/bookings/BK-DEMO-RETURN");
await expect(page.getByText("Demonstratiescenario: afwijkende kilometerstand")).toBeVisible();
const odometerInput = page.getByLabel("Eindkilometerstand (km)");
await expect(odometerInput).not.toHaveValue("");
const prefilled = Number(await odometerInput.inputValue());
expect(prefilled).toBeGreaterThan(0);
await page.getByRole("button", { name: "Retour nakijken" }).click();
await expect(page.getByText(/laatst bevestigde stand/)).toBeVisible();
await page.getByRole("button", { name: "Retour bevestigen" }).click();
await expect(page.getByRole("heading", { name: "Retour geregistreerd" })).toBeVisible();
await expect(page.getByRole("link", { name: "Automatiseringsstatus bekijken" })).toBeVisible();
await expect(page.getByRole("link", { name: "Volledige verwerking volgen" })).toBeVisible();
});
test("data quality issue detail explains what's wrong and why it matters", async ({ page }) => {
await page.goto("/login");
await page.getByRole("button", { name: "Verken als Operationsmanager" }).click();
await expect(page).toHaveURL(/\/dashboard$/);
await page.goto("/data-quality/DQ-DEMO-DUPLICATE");
await expect(page.getByText("Wat is er mis")).toBeVisible();
await expect(page.getByText("Waarom dit belangrijk is")).toBeVisible();
await expect(page.getByText(/waarschijnlijk dezelfde persoon/)).toBeVisible();
});
test("data quality list can filter to demo scenarios only", async ({ page }) => {
await page.goto("/login");
await page.getByRole("button", { name: "Verken als Operationsmanager" }).click();
await expect(page).toHaveURL(/\/dashboard$/);
await page.goto("/data-quality");
await expect(page.locator(".data-table tbody tr").first()).toBeVisible();
const allRows = await page.locator(".data-table tbody tr").count();
// The URL-driven filter update can replace the controlled checkbox immediately after
// its click. Assert against the newly rendered control instead of asking `check()` to
// verify the detached pre-navigation node.
await page.getByRole("checkbox", { name: "Enkel demoscenario's" }).click();
await expect(page).toHaveURL(/demo=true/);
await expect(page.getByRole("checkbox", { name: "Enkel demoscenario's" })).toBeChecked();
const filteredRows = await page.locator(".data-table tbody tr").count();
expect(filteredRows).toBeGreaterThan(0);
expect(filteredRows).toBeLessThanOrEqual(allRows);
const refs = await page.locator(".data-table tbody tr th a").allTextContents();
for (const ref of refs) {
expect(ref.startsWith("DQ-DEMO-")).toBeTruthy();
}
});
test("knowledge page suggested question returns a grounded, honestly-labelled answer", async ({ page }) => {
await page.goto("/login");
await page.getByRole("button", { name: "Verken als Operationsmanager" }).click();
await expect(page).toHaveURL(/\/dashboard$/);
await page.goto("/knowledge");
// The status badge must name the actual active provider once its check settles.
await expect(page.locator(".knowledge-status strong")).toHaveText(/RAGcore|de demokennisbank/);
await page.getByRole("button", { name: "Wie beoordeelt een ongewone kilometerstand?" }).click();
await expect(page.getByText("Onderbouwd met geciteerde procedures")).toBeVisible({ timeout: 15_000 });
const sources = page.locator(".exchange").first().locator(".source-card");
expect(await sources.count()).toBeLessThanOrEqual(3);
const titles = await sources.locator(".source-title").allTextContents();
expect(new Set(titles.map((title) => title.trim().toLocaleLowerCase())).size).toBe(titles.length);
await page.getByRole("button", { name: "Ja" }).first().click();
await expect(page.getByText("Feedback opgeslagen")).toBeVisible();
});