Files
phaseflow/e2e/health.spec.ts
Petru Paler 54b57d5160
All checks were successful
Deploy / deploy (push) Successful in 1m41s
Add 36 new E2E tests across 5 test files
New E2E test files:
- e2e/health.spec.ts: 3 tests for health/observability endpoints
- e2e/history.spec.ts: 7 tests for history page
- e2e/plan.spec.ts: 7 tests for exercise plan page
- e2e/decision-engine.spec.ts: 8 tests for decision display and overrides
- e2e/cycle.spec.ts: 11 tests for cycle tracking, settings, and period logging

Total E2E tests: 100 (up from 64)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 17:37:34 +00:00

50 lines
1.7 KiB
TypeScript

// 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_");
});
});
});