test(celilo): cover the health_check smoke path, which had no tests at all #55
No reviewers
Labels
No labels
area/auth
area/backend
area/ci
area/deploy
area/e2e
area/frontend
area/shared
blocked
good-first-issue
needs-info
priority/high
priority/low
priority/medium
type/bug
type/chore
type/docs
type/feature
type/tech-debt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
celilo/lunacycle!55
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "smoke-path-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #53. Branched from
e9cac92, the same base as #54, and touches no line #54 touches.Every call site in
health-check.test.tspassedsecrets: {}, so every test took the!smoketest_bot_passwordskip branch.mintSmokeToken,runSpaSmoke,runApiSmokeCheckandrunWsSmokeCheckhad 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 testrunSpaSmokeCheckrather than the dispatch logic #53 is about, and the e2e suite already drives those helpers end to end.smoke_*check is recorded at allsmoke_loginrecorded failed, and the three downstream checks deliberately not runredirect_uri,username, and theBearerheader are pinnedThe 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:
if (!botPassword)→if (false)if (botToken)→if (true)if (botToken)→if (false)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
LunacycleHealthCheckDepsgains an optionalmintToken, mirroring theloadChromiumoverride 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/failaddCheckwrapping 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.
runWsSmokeusesglobalThis.WebSocket, so the test installs a fake constructor and restores it. The fake dispatchesclosesynchronously fromclose(), which is what bun does and whatrunWsSmoke's resolve-before-close ordering exists to survive.Interaction with #54
Verified rather than assumed, since we're deliberately running these in parallel:
scripts/smoke/api-smoke.ts,celilo/scripts/package.json, the rootpackage.jsonand four test files. #53 editscelilo/scripts/health-check.ts, which #54 does not touch at all.git merge-treereports no conflicts;health-check.test.tsauto-merges (#54 edits existing call sites in the first 160 lines, #53 appends a newdescribeat the end).typecheckexit 0 with #54'scelilo/scriptsproject included, 65 hook tests pass, lint exit 0.Gates
lint— exit 0typecheck— exit 0test:hooks— 65 pass, 0 fail (was 62)test:unit— 117 pass, 0 fail, 3 todotest:seed— 1 pass, 0 failAlso 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
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>