test(celilo): cover the health_check smoke path, which had no tests at all #55

Merged
forgejo-admin merged 1 commit from smoke-path-coverage into main 2026-08-18 06:14:15 +00:00

Closes #53. Branched from e9cac92, the same base as #54, and touches no line #54 touches.

Every call site in health-check.test.ts passed secrets: {}, so every test took the !smoketest_bot_password skip branch. mintSmokeToken, runSpaSmoke, runApiSmokeCheck and runWsSmokeCheck had zero unit coverage. That is the code deciding whether a deploy is healthy, so its only proving ground was production.

What the tests cover

The gating, not the three helpers' internals. Each helper records a distinctly-named check (smoke_spa, smoke_api, smoke_ws), so seeing that name is proof the helper was entered. Re-faking playwright's entire surface here would test runSpaSmokeCheck rather than the dispatch logic #53 is about, and the e2e suite already drives those helpers end to end.

scenario asserted
no password skip is logged, no smoke_* check is recorded at all
mint fails smoke_login recorded failed, and the three downstream checks deliberately not run
mint succeeds all three run against the minted token; OIDC redirect_uri, username, and the Bearer header are pinned

The middle one is worth calling out: the code comments claim the three checks are skipped after a mint failure so one cause isn't reported four times. Nothing verified that until now.

Proved each test fails

One targeted mutation per test, each restored afterwards:

mutation result
if (!botPassword)if (false) skip test goes red
if (botToken)if (true) mint-failure test goes red
if (botToken)if (false) happy-path test goes red

The first mutation also reddens three pre-existing tests — which is itself evidence for the premise of #53: those tests do reach the gate, they just take the skip branch, so removing the gate sends them at a live authentik.

The one production change

LunacycleHealthCheckDeps gains an optional mintToken, mirroring the loadChromium override already there and already documented as "Tests pass a stub here". Without a seam, nothing below the password gate is reachable without a live authentik. mintSmokeToken's own logic — the pass/fail addCheck wrapping that test 2 exercises — stays under test.

No network and no live data: the OIDC login, chromium, the API fetch and the WebSocket are all stubbed. runWsSmoke uses globalThis.WebSocket, so the test installs a fake constructor and restores it. The fake dispatches close synchronously from close(), which is what bun does and what runWsSmoke's resolve-before-close ordering exists to survive.

Interaction with #54

Verified rather than assumed, since we're deliberately running these in parallel:

  • No shared production line. #54 edits scripts/smoke/api-smoke.ts, celilo/scripts/package.json, the root package.json and four test files. #53 edits celilo/scripts/health-check.ts, which #54 does not touch at all.
  • They merge cleanly. git merge-tree reports no conflicts; health-check.test.ts auto-merges (#54 edits existing call sites in the first 160 lines, #53 appends a new describe at the end).
  • The merged tree is green under #54's new gate. Merged the two locally and ran the combined result: typecheck exit 0 with #54's celilo/scripts project included, 65 hook tests pass, lint exit 0.

Gates

  • lint — exit 0
  • typecheck — exit 0
  • test:hooks — 65 pass, 0 fail (was 62)
  • test:unit — 117 pass, 0 fail, 3 todo
  • test:seed — 1 pass, 0 fail

Also confirmed this branch adds no type errors: 18 before and 18 after, on the base branch's ad-hoc typecheck — the same pre-existing set #54 clears.

🤖 Generated with Claude Code

Closes #53. Branched from `e9cac92`, the same base as #54, and touches no line #54 touches. Every call site in `health-check.test.ts` passed `secrets: {}`, so every test took the `!smoketest_bot_password` skip branch. `mintSmokeToken`, `runSpaSmoke`, `runApiSmokeCheck` and `runWsSmokeCheck` had **zero** unit coverage. That is the code deciding whether a deploy is healthy, so its only proving ground was production. ## What the tests cover The **gating**, not the three helpers' internals. Each helper records a distinctly-named check (`smoke_spa`, `smoke_api`, `smoke_ws`), so seeing that name is proof the helper was entered. Re-faking playwright's entire surface here would test `runSpaSmokeCheck` rather than the dispatch logic #53 is about, and the e2e suite already drives those helpers end to end. | scenario | asserted | |---|---| | no password | skip is logged, **no** `smoke_*` check is recorded at all | | mint fails | `smoke_login` recorded failed, and the three downstream checks deliberately **not** run | | mint succeeds | all three run against the minted token; OIDC `redirect_uri`, `username`, and the `Bearer` header are pinned | The middle one is worth calling out: the code comments claim the three checks are skipped after a mint failure so one cause isn't reported four times. Nothing verified that until now. ## Proved each test fails One targeted mutation per test, each restored afterwards: | mutation | result | |---|---| | `if (!botPassword)` → `if (false)` | skip test goes red | | `if (botToken)` → `if (true)` | mint-failure test goes red | | `if (botToken)` → `if (false)` | happy-path test goes red | The first mutation also reddens three **pre-existing** tests — which is itself evidence for the premise of #53: those tests do reach the gate, they just take the skip branch, so removing the gate sends them at a live authentik. ## The one production change `LunacycleHealthCheckDeps` gains an optional `mintToken`, mirroring the `loadChromium` override already there and already documented as "Tests pass a stub here". Without a seam, nothing below the password gate is reachable without a live authentik. `mintSmokeToken`'s own logic — the pass/fail `addCheck` wrapping that test 2 exercises — stays under test. No network and no live data: the OIDC login, chromium, the API fetch and the WebSocket are all stubbed. `runWsSmoke` uses `globalThis.WebSocket`, so the test installs a fake constructor and restores it. The fake dispatches `close` synchronously from `close()`, which is what bun does and what `runWsSmoke`'s resolve-before-close ordering exists to survive. ## Interaction with #54 Verified rather than assumed, since we're deliberately running these in parallel: - **No shared production line.** #54 edits `scripts/smoke/api-smoke.ts`, `celilo/scripts/package.json`, the root `package.json` and four test files. #53 edits `celilo/scripts/health-check.ts`, which #54 does not touch at all. - **They merge cleanly.** `git merge-tree` reports no conflicts; `health-check.test.ts` auto-merges (#54 edits existing call sites in the first 160 lines, #53 appends a new `describe` at the end). - **The merged tree is green under #54's new gate.** Merged the two locally and ran the combined result: `typecheck` exit 0 with #54's `celilo/scripts` project included, 65 hook tests pass, lint exit 0. ## Gates - `lint` — exit 0 - `typecheck` — exit 0 - `test:hooks` — 65 pass, 0 fail (was 62) - `test:unit` — 117 pass, 0 fail, 3 todo - `test:seed` — 1 pass, 0 fail Also confirmed this branch adds no type errors: 18 before and 18 after, on the base branch's ad-hoc typecheck — the same pre-existing set #54 clears. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test(celilo): cover the health_check smoke path, which had no tests at all
All checks were successful
pr-validate / validate (pull_request) Successful in 39s
490010c295
Every call site in health-check.test.ts passed `secrets: {}`, so every test took
the `!smoketest_bot_password` skip branch and nothing below it was ever entered.
mintSmokeToken, runSpaSmoke, runApiSmokeCheck and runWsSmokeCheck had zero unit
coverage — and that is the code deciding whether a deploy is healthy, so its
only proving ground was production.

Three tests, covering the GATING rather than the three helpers' internals. Each
helper records a distinctly-named check, so seeing that name is proof it was
entered; re-faking playwright's whole surface here would test runSpaSmokeCheck
instead of the dispatch logic this is about, and the e2e suite already drives
those helpers end to end.

  - no password        -> skip logged, no smoke_* checks at all
  - mint fails         -> smoke_login recorded failed, and the three downstream
                          checks deliberately NOT run (the code comments claim
                          this; nothing verified it)
  - mint succeeds      -> all three run against the minted token, and the OIDC
                          redirect_uri / username / bearer token are pinned

Adds a `mintToken` dependency override on LunacycleHealthCheckDeps, mirroring
the `loadChromium` one already there and documented as a test seam. Without it
nothing below the password gate is reachable without a live authentik.

Proved each test fails, one targeted mutation each:
  - `if (!botPassword)` -> `if (false)`: the skip test goes red (and so do three
    pre-existing tests, which is itself evidence they reach the gate and take
    the skip branch)
  - `if (botToken)` -> `if (true)`:  the mint-failure test goes red
  - `if (botToken)` -> `if (false)`: the happy-path test goes red
All restored; 65 hook tests green.

Refs #53

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.