Public: anyone can read this; the crew can change it.

forked from trevato/cs · proposes · 4 behind

The HUD is pinned before it moves: src/client/hud.test.ts says what a player sees today #71

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`src/client/hud.test.ts` is new: thirteen tests and 107 assertions that drive `drawHud` with a recording `Paint` — no canvas, no document, no browser. It pins what a player reads rather than how the drawing is arranged: health white above thirty and red at thirty and below, ammo as `mag / reserve` with "reloading" appearing only while the reload is running, the clock reading `--:--` in `over` and…

shipped production is serving it deploy ae07c2d

opened this

src/client/hud.test.ts is new: thirteen tests and 107 assertions that drive drawHud with a recording Paint — no canvas, no document, no browser. It pins what a player reads rather than how the drawing is arranged: health white above thirty and red at thirty and below, ammo as mag / reserve with "reloading" appearing only while the reload is running, the clock reading --:-- in over and match_over and turning #ff6b5b the moment the bomb is planted, the crosshair gap at 4 + spread * 14 with the number asked of inaccuracy rather than written down, the use bar's fraction tracking useProgress for a plant, a defuse and a defuse with a kit, a kill named with its gun and fading out over eight seconds (readable at 7.5 s, nothing readable at 8, no call at all at 8.1), the scoreboard sorted by kills then damage with your row white and the dead dimmed, the scoreboard's scrim drawn after the health it covers, and a dead player told they are watching until the match itself is over. Both ends of the screen are checked at 360×640 and 1920×1080: nothing is drawn outside the canvas, the fonts are 21/13/11 px and 42/27/21 px, and the same world draws the same lines and the same calls in the same order at both.

The Paint is the HUD's own, not the engine's, and that is the thing to look at: hud.ts types its styles string where src/engine/overlay.ts types them unknown, so a recorder declared as the engine's Paint cannot be handed to drawHud today — while the HUD-typed recorder here can be handed to overlay(), which is what #18 needs. The recorder is this file's own rather than the one in stage.test-helper.ts because it writes down the brush (fill, stroke, font, align, alpha) at each call, and colour is half of what is pinned; neither existing recorder keeps it. One world is built once for the suite with createWorld(SHORT, "you", "ct", 5, 64), and each test draws a cheap copy of it so a test that kills a bot does not reach the next one.

No wrongness found, so hud.ts is untouched. To show the pin is not vacuous I ran six mutants against it — swapped health colours, a feed that lingers to nine seconds, a gap of spread * 16, a planted clock left white, a scoreboard sorted by kills ascending, and an unclamped scale — and each failed exactly one test; two more that moved the health line and the kill feed off the edge were caught by the layout test. What I left out: coordinates of panels, the exact y of any row, and the call at age exactly 8.0 (it happens at alpha 0, which is nothing a player sees, and overlay.text skips it — pinning it would fail the move for a no-op). main.test.ts already covered two things about the HUD — that the first call of a frame is clearRect and that the texts contain $800 — and nothing here duplicates that beyond the clear. bun test: 443 pass, 0 fail. The README's hud paragraph now names what the test pins.

🤖 Generated with Claude Code

Closes #64

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs