Files
NuklearRabbit adc2c70c21 ServiceMap: update tests and backend/app (+7 areas)
Public changes compared with the previous published export:
89 files changed.

Affected areas:
- backend/app: 21 files
- dependencies: 5 files
- deployment and CI: 6 files
- documentation: 2 files
- frontend: 3 files
- frontend/src: 20 files
- project files: 1 file
- tests: 30 files
- unraid: 1 file

Changed files:
- Updated: ".env.example"
- Updated: "Dockerfile.unraid"
- Updated: "README.md"
- Updated: "backend/Dockerfile"
- Added: "backend/app/alerts.py"
- Updated: "backend/app/auth.py"
- Added: "backend/app/backups.py"
- Updated: "backend/app/config_io.py"
- Updated: "backend/app/demo.py"
- Updated: "backend/app/discovery.py"
- Updated: "backend/app/discovery_store.py"
- Updated: "backend/app/docker_discovery.py"
- Updated: "backend/app/events.py"
- Updated: "backend/app/evidence.py"
- Updated: "backend/app/health.py"
- Updated: "backend/app/incidents.py"
- Added: "backend/app/loops.py"
- Updated: "backend/app/main.py"
- Updated: "backend/app/models.py"
- Updated: "backend/app/observation.py"
- Updated: "backend/app/probes.py"
- Added: "backend/app/response_cache.py"
- Updated: "backend/app/scheduler.py"
- Updated: "backend/app/semantic.py"
- Updated: "backend/app/store.py"
- Updated: "backend/pyproject.toml"
- Updated: "backend/tests/test_api.py"
- Updated: "backend/tests/test_config_io.py"
- Updated: "backend/tests/test_demo.py"
- Updated: "backend/tests/test_discovery_v120.py"
- Updated: "backend/tests/test_health.py"
- Updated: "backend/tests/test_probes.py"
- Updated: "backend/tests/test_scheduler.py"
- Updated: "backend/tests/test_v130_probe_reachability.py"
- Updated: "backend/tests/test_v160_evidence_changes.py"
- Added: "backend/tests/test_v163_alerts.py"
- Added: "backend/tests/test_v163_backups.py"
- Added: "backend/tests/test_v163_data_integrity.py"
- Added: "backend/tests/test_v163_efficiency.py"
- Added: "backend/tests/test_v163_health_performance.py"
- Added: "backend/tests/test_v163_loops.py"
- Added: "backend/tests/test_v163_management.py"
- Added: "backend/tests/test_v163_realtime.py"
- Added: "backend/tests/test_v163_security.py"
- Added: "backend/tests/test_v163_semantic_etag.py"
- Added: "compose.demo.yaml"
- Updated: "compose.yaml"
- Added: "docker-compose.broker.yml"
- Updated: "docker-compose.yml"
- Updated: "docs/ARCHITECTURE.md"
- Added: "frontend/e2e/a11y.spec.ts"
- Updated: "frontend/e2e/demo.spec.ts"
- Updated: "frontend/index.html"
- Updated: "frontend/nginx.conf"
- Updated: "frontend/package-lock.json"
- Updated: "frontend/package.json"
- Updated: "frontend/playwright.config.ts"
- Updated: "frontend/src/App.tsx"
- Updated: "frontend/src/LivingEdge.tsx"
- Added: "frontend/src/activityView.test.ts"
- Added: "frontend/src/activityView.ts"
- Updated: "frontend/src/api.ts"
- Added: "frontend/src/apiAuth.test.ts"
- Added: "frontend/src/components/ActionsMenu.tsx"
- Added: "frontend/src/components/ConfirmDialog.test.tsx"
- Added: "frontend/src/components/ConfirmDialog.tsx"
- Added: "frontend/src/components/StatusIcon.tsx"
- Updated: "frontend/src/demo/DemoWalkthrough.test.ts"
- Updated: "frontend/src/demo/DemoWalkthrough.tsx"
- Added: "frontend/src/elk-worker-url.d.ts"
- Added: "frontend/src/labels.ts"
- Updated: "frontend/src/main.tsx"
- Added: "frontend/src/realtime/refreshPlan.test.ts"
- Added: "frontend/src/realtime/refreshPlan.ts"
- Updated: "frontend/src/realtime/useRealtimeEvents.ts"
- Added: "frontend/src/routing/urlState.test.ts"
- Added: "frontend/src/routing/urlState.ts"
- Updated: "frontend/src/styles.css"
- Added: "frontend/src/topology/GraphListView.test.tsx"
- Added: "frontend/src/topology/GraphListView.tsx"
- Updated: "frontend/src/topology/ServiceNode.tsx"
- Updated: "frontend/src/topology/TopologyCommandBar.tsx"
- Added: "frontend/src/topology/semanticGraph.test.ts"
- Updated: "frontend/src/topology/semanticGraph.ts"
- Added: "frontend/src/topologyLayout.test.ts"
- Updated: "frontend/src/topologyLayout.ts"
- Updated: "package-lock.json"
- Updated: "package.json"
- Updated: "unraid/my-servicemap.xml"

Export provenance/manifests refreshed; excluded from the change summary.

Publish curated ServiceMap source from af46f684e468dffd3a5190e28d3b572d4c26bfd7
2026-11-20 13:51:46 +01:00

174 lines
7.8 KiB
TypeScript

import { expect, test } from "@playwright/test";
type ServiceSnapshot = {
service: {
id: string;
name: string;
depends_on: string[];
};
latest_probe: { status: string } | null;
effective_status: string;
};
const topologyOf = (snapshots: ServiceSnapshot[]) =>
snapshots
.map(({ service }) => ({
id: service.id,
name: service.name,
depends_on: [...service.depends_on].sort(),
}))
.sort((left, right) => left.id.localeCompare(right.id));
const isDemoMutation = (path: string) =>
(response: {
url: () => string;
request: () => { method: () => string };
}) =>
response.url().endsWith(path) && response.request().method() === "POST";
test("Explore demo exposes evidence-backed root cause and reset-safe exit", async ({ page, request }) => {
test.setTimeout(60_000);
// The Playwright server uses a persistent temporary database, so restore any
// session left by an interrupted run before taking this test's baseline.
const cleanup = await request.post("/api/v1/demo/exit");
expect(cleanup.ok()).toBeTruthy();
const baselineResponse = await request.get("/api/v1/services");
expect(baselineResponse.ok()).toBeTruthy();
const baselineTopology = topologyOf(await baselineResponse.json());
await page.goto("/");
// Secondary actions live in the header's overflow menu.
await page.getByRole("button", { name: "Meer acties" }).click();
const explore = page.getByRole("button", { name: "Demo verkennen", exact: true });
await expect(explore).toBeEnabled({ timeout: 30_000 });
const loadResponsePromise = page.waitForResponse(isDemoMutation("/api/v1/demo"));
await explore.click();
if (baselineTopology.length > 0) {
const confirmation = page
.getByRole("dialog", { name: /vervangt deze topologie tijdelijk/ });
await expect(confirmation).toBeVisible();
await confirmation.getByRole("button", { name: "Snapshot maken en verkennen", exact: true }).click();
}
const loadResponse = await loadResponsePromise;
expect(loadResponse.ok()).toBeTruthy();
expect(await loadResponse.json()).toMatchObject({
active: true,
synthetic: true,
scenario_name: "Northstar Platform",
service_count: 9,
total: 9,
root_cause_service_name: "PostgreSQL",
affected_count: 5,
});
const demoServicesResponse = await request.get("/api/v1/services");
expect(demoServicesResponse.ok()).toBeTruthy();
const demoServices: ServiceSnapshot[] = await demoServicesResponse.json();
expect(demoServices).toHaveLength(9);
const postgres = demoServices.find(({ service }) => service.name === "PostgreSQL");
expect(postgres).toBeDefined();
expect(postgres!.latest_probe?.status).toBe("down");
expect(postgres!.effective_status).toBe("down");
const [incidentsResponse, historyResponse, availabilityResponse] =
await Promise.all([
request.get("/api/v1/incidents"),
request.get(`/api/v1/services/${postgres!.service.id}/history?limit=50`),
request.get(`/api/v1/services/${postgres!.service.id}/availability?hours=24`),
]);
expect(incidentsResponse.ok()).toBeTruthy();
const incident = (await incidentsResponse.json()) as {
active: boolean;
candidates: Array<{
service_name: string;
affected_service_ids: string[];
}>;
};
expect(incident.active).toBe(true);
expect(incident.candidates[0]?.service_name).toBe("PostgreSQL");
expect(incident.candidates[0]?.affected_service_ids).toHaveLength(5);
expect(historyResponse.ok()).toBeTruthy();
expect(await historyResponse.json()).toHaveLength(24);
expect(availabilityResponse.ok()).toBeTruthy();
expect(await availabilityResponse.json()).toMatchObject({
total_checks: 24,
down_checks: 2,
uptime_percent: 91.67,
});
const demoBanner = page.getByRole("status", { name: "Demoscenario verkennen" });
await expect(demoBanner).toBeVisible();
await expect(demoBanner).toHaveAttribute("aria-busy", "false", { timeout: 30_000 });
await expect(page.getByText("Demoscenario", { exact: false })).toBeVisible();
await expect(page.getByText("PostgreSQL", { exact: true }).first()).toBeVisible();
await expect(page.getByText("Waarschijnlijke hoofdoorzaak", { exact: true })).toBeVisible();
await expect(page.getByText("Gezondheidsbewijs", { exact: true })).toBeVisible();
const workspaces = page.getByRole("navigation", { name: "ServiceMap-werkruimtes" });
await workspaces.getByRole("button", { name: "Overzicht" }).click();
await expect(page.getByRole("heading", { name: "9/9 met actueel gezondheidsbewijs" })).toBeVisible();
await expect(page.getByRole("button", { name: "Onopgeloste nakijken" })).toBeDisabled();
await page.locator(".overview-lead").getByRole("button", { name: /1 uitgevallen/i }).click();
await expect(page.getByRole("combobox", { name: "Status", exact: true })).toHaveValue("down");
await workspaces.getByRole("button", { name: "Incidenten" }).click();
await expect(
page.getByRole("heading", { name: "Actieve en eerdere incidenten" }),
).toBeVisible();
await page.getByLabel("Incidenten zoeken").fill("does not exist");
await expect(page.getByText("Geen incidenten voor deze filters.")).toBeVisible();
await page.getByLabel("Incidenten zoeken").fill("");
await workspaces.getByRole("button", { name: "Topologie", exact: true }).click();
await expect(page.getByRole("region", { name: "Topologieopdrachten" })).toBeVisible();
await page.getByRole("region", { name: "Topologieopdrachten" }).locator("summary").filter({ hasText: "Filters" }).click();
await expect(page.getByRole("combobox", { name: "Topologie filteren op status" })).toBeVisible();
const inspector = page.getByRole("complementary");
await expect(inspector.getByRole("heading", { name: "PostgreSQL" })).toBeVisible();
await expect(inspector.getByText("Waarschijnlijke hoofdoorzaak", { exact: true })).toBeVisible();
await expect(inspector.getByText("Gezondheidsbewijs", { exact: true })).toBeVisible();
await page.getByRole("button", { name: "Meer acties" }).click();
const reset = page.locator("header").getByRole("button", { name: "Demo opnieuw starten" });
const resetResponsePromise = page.waitForResponse(isDemoMutation("/api/v1/demo/reset"));
await reset.click();
const resetResponse = await resetResponsePromise;
expect(resetResponse.ok()).toBeTruthy();
expect(await resetResponse.json()).toMatchObject({
active: true,
root_cause_service_name: "PostgreSQL",
});
// A rendered PostgreSQL node can be left over from before Reset completed.
// Wait for the demo region to leave its busy state before attempting Exit.
await expect(demoBanner).toHaveAttribute("aria-busy", "false", { timeout: 30_000 });
await expect(page.getByText("PostgreSQL", { exact: true }).first()).toBeVisible();
const exit = page.getByRole("button", { name: "Demo afsluiten", exact: true });
await expect(exit).toBeEnabled();
const exitResponsePromise = page.waitForResponse(isDemoMutation("/api/v1/demo/exit"));
await exit.click();
const exitResponse = await exitResponsePromise;
expect(exitResponse.ok()).toBeTruthy();
expect(await exitResponse.json()).toMatchObject({ active: false, restored: true });
await expect(demoBanner).toBeHidden({ timeout: 30_000 });
await expect(
page.getByText("Demo afgesloten. Je vorige topologie is hersteld.", { exact: true }),
).toBeVisible();
await page.getByRole("button", { name: "Meer acties" }).click();
await expect(
page.getByRole("button", { name: "Demo verkennen", exact: true }),
).toBeEnabled({ timeout: 30_000 });
const restoredDemoResponse = await request.get("/api/v1/demo");
expect(restoredDemoResponse.ok()).toBeTruthy();
expect(await restoredDemoResponse.json()).toMatchObject({ active: false });
const restoredServicesResponse = await request.get("/api/v1/services");
expect(restoredServicesResponse.ok()).toBeTruthy();
expect(topologyOf(await restoredServicesResponse.json())).toEqual(baselineTopology);
});