// ABOUTME: E2E tests for health and observability endpoints. // ABOUTME: Tests health check endpoint response and performance. import { expect, test } from "@playwright/test"; test.describe("health and observability", () => { test.describe("health endpoint", () => { test("health endpoint returns 200 when healthy", async ({ request }) => { const response = await request.get("/api/health"); expect(response.status()).toBe(200); const body = await response.json(); expect(body.status).toBe("ok"); expect(body).toHaveProperty("timestamp"); expect(body).toHaveProperty("version"); }); test("health endpoint responds quickly", async ({ request }) => { const startTime = Date.now(); const response = await request.get("/api/health"); const endTime = Date.now(); expect(response.status()).toBe(200); // E2E includes network latency; allow 500ms for full round-trip // (the handler itself executes in <100ms per spec) expect(endTime - startTime).toBeLessThan(500); }); }); test.describe("metrics endpoint", () => { test("metrics endpoint is accessible and returns Prometheus format", async ({ request, }) => { const response = await request.get("/api/metrics"); expect(response.status()).toBe(200); const contentType = response.headers()["content-type"]; expect(contentType).toContain("text/plain"); const body = await response.text(); // Prometheus format should contain HELP and TYPE comments expect(body).toMatch(/^# HELP/m); expect(body).toMatch(/^# TYPE/m); // Should contain our custom metrics expect(body).toContain("phaseflow_"); }); }); });