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
Check · Review · Land · Live done — Landed and live in production.
`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
Sign in to join this conversation.
new above
offline
src/client/hud.test.tsis new: thirteen tests and 107 assertions that drivedrawHudwith a recordingPaint— 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 asmag / reservewith "reloading" appearing only while the reload is running, the clock reading--:--inoverandmatch_overand turning#ff6b5bthe moment the bomb is planted, the crosshair gap at4 + spread * 14with the number asked ofinaccuracyrather than written down, the use bar's fraction trackinguseProgressfor 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
Paintis the HUD's own, not the engine's, and that is the thing to look at:hud.tstypes its stylesstringwheresrc/engine/overlay.tstypes themunknown, so a recorder declared as the engine'sPaintcannot be handed todrawHudtoday — while the HUD-typed recorder here can be handed tooverlay(), which is what #18 needs. The recorder is this file's own rather than the one instage.test-helper.tsbecause 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 withcreateWorld(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.tsis 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 ofspread * 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 exactyof any row, and the call at age exactly 8.0 (it happens at alpha 0, which is nothing a player sees, andoverlay.textskips it — pinning it would fail the move for a no-op).main.test.tsalready covered two things about the HUD — that the first call of a frame isclearRectand that the texts contain$800— and nothing here duplicates that beyond the clear.bun test: 443 pass, 0 fail. The README'shudparagraph now names what the test pins.🤖 Generated with Claude Code
Closes #64