Files
HealthLog/e2e/version.spec.ts
Marc-André Bombeck a23ee61184 test(e2e): route cleanup happens by construction, not per spec
A spec that arms `page.route(...)` in a `beforeEach` and never drops the
handler races its own teardown. The context closes, an async handler is
still awaiting, its next call rejects with "Test ended.", and Playwright
attributes that to the test that had just passed. With `retries: 2` plus
`failOnFlakyTests`, which spec bites is a matter of timing.

`e2e/setup/test.ts` re-exports Playwright's `test` extended with an auto
fixture that unroutes every page and the context after each test, and
clears the page event listeners a spec subscribes to; `expect` rides
along so a spec needs one import. Auto means a spec author cannot forget
it and does not have to know it exists. Every spec now takes `test` from
there, and `e2e-route-cleanup-guard.test.ts` keeps the import boundary
closed with an allowlist that carries its reason.

The per-file `afterEach` on the cycle spec goes away — leaving both would
read as not trusting the fixture.

Not covered: a page inside a context a spec builds itself. Only
`share-documents.spec.ts` does that, and it owns those contexts.
2026-07-25 23:02:03 +02:00

31 lines
1.1 KiB
TypeScript

import { expect, test } from "./setup/test";
/**
* /api/version is the public, unauthenticated endpoint that drives
* the Settings → About surface and acts as the container's healthcheck
* target. If this breaks, every deployed image's healthcheck fails and
* Coolify pulls the container out of rotation.
*/
test.describe("public version endpoint", () => {
test("returns the running version + license", async ({ request }) => {
const res = await request.get("/api/version");
expect(res.status()).toBe(200);
const json = await res.json();
expect(json.data).toBeDefined();
expect(typeof json.data.version).toBe("string");
expect(json.data.version).toMatch(/^\d+\.\d+\.\d+/);
expect(json.data.license).toBeDefined();
});
test("does not require authentication", async ({ request }) => {
// No cookie, no Authorization header — must still respond 200 so
// the docker healthcheck and the in-app "check for updates" button
// both work without a session.
const res = await request.get("/api/version", {
headers: { "X-Client-Type": "anonymous" },
});
expect(res.status()).toBe(200);
});
});