Skip to content

test(ui): cover render bridge overlays (zeus pings/modules, blasts, trails, death heatmap) - #589

Merged
smitt14ua merged 3 commits into
mainfrom
claude/coverage-render-bridge
Oct 25, 2026
Merged

smitt14ua merged 3 commits into
mainfrom
claude/coverage-render-bridge

Conversation

@fank

@fank fank commented Oct 25, 2026

Copy link
Copy Markdown
Member

What

Test-only coverage for useRenderBridge.ts, the largest remaining gap in the UI at 57.8% (125 uncovered lines). It is the effect layer that turns engine state into map visuals, and most of it had never run: the Zeus ping overlay, Zeus module overlay, explosion blast circles, movement trails, and the death heatmap were all essentially untested. No production code changed.

Changes

ui/src/pages/recording-playback/__tests__/useRenderBridgeOverlays.test.tsx (new, 36 tests) — drives the real PlaybackEngine + MarkerManager against MockRenderer, spying on the briefing/entity marker API so assertions are on what the map is actually told to draw:

  • Zeus pings — icon + label drawn while live and removed exactly when the 180-frame lifetime expires; the label is rebuilt (not merely updated) when a second ping joins the group, since the text is baked into the divIcon; pings from the same player that land outside the 25 m radius stay as two groups rather than collapsing to one; changing the time mode rebuilds the label; alpha fades toward the end of life
  • XSS — the recorded unit name is escaped before it reaches the divIcon HTML (<img src=x onerror=…> renders as text, never as a tag), and module curator/display/attached names are escaped too
  • Labelling fallbacks — unnamed pinger → Unit <id>; unnamed curator → Zeus <id> with no dangling separator; unknown side → the #ffcc00 default colour
  • Zeus modules — labelled with curator, module name and attached target, positioned at the placement, removed past the 30 s lifetime, and measurably faded between frame 10 and 37
  • Explosions — a circle sized by the ammo's own indirectHitRange (size: [radius, radius]), the three radius colour classes (ff9d3d / ff5c2d / ff2d2d), peak alpha 0.3 decaying as the playhead passes, removal after 6 s, and one circle per blast in a barrage
  • Movement trails — nothing drawn while off; one trail per on-foot player (riders excluded) in players mode; followed mode draws only the follow target and stops when it is cleared; turning the mode off releases existing handles; a single resolvable sample is never drawn as a degenerate one-point polyline; and advancing one frame reuses the cached samples and updates the existing handle instead of creating a second marker
  • Death heatmap — nothing while hidden, blobs drawn per death cell once shown (colour ff3b3b, positive radius), growing with the playhead, and every blob released when hidden again
  • Entity/vehicle popups — a vehicle with a player crew member becomes a player marker with crew naming only the player, a vehicle with no player crew does not, and a unit past its endFrame has its marker handle released
  • Plumbing — the smoothing interval tracks capture delay and speed (0.1 s at the default 10x, 1 s at 1x, 1/60 s at 60x, clamped so it is never zero-length), dragging the map releases the follow lock, and the CSS --leaflet-left-offset follows the side panel

Coverage impact

Target before after
useRenderBridge.ts lines 57.77% 94.59%
useRenderBridge.ts branches — 84.76%
UI overall lines 93.56% 94.62%

Verification

Adds useRenderBridgeOverlays.test.tsx (36 tests) covering the previously
untested effect layer: zeus ping overlay (lifetime add/remove, label rebuild on
group growth and time-mode change, group radius separation, HTML escaping of
recorded names, side-colour and label fallbacks, fade), zeus module overlay
(curator/module/attached-target labelling, 30s lifetime, fade, escaping),
explosion blast circles (radius-sized ellipse, radius colour classes, peak-then
fade alpha, 6s removal, barrages), movement trails (off/players/followed,
rider exclusion, degenerate single-point rejection, sample-cache reuse), the
death heatmap (hidden/shown/removed, blob growth), vehicle crew popup
attribution, expired-entity marker release, smoothing interval, drag-to-
unfollow and the panel offset.

useRenderBridge.ts 57.8% -> 94.6% lines; UI overall 93.6% -> 94.6%.
@fank
fank requested a review from smitt14ua October 25, 2026 10:14
@fank
fank marked this pull request as ready for review October 25, 2026 10:14
@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Coverage Report for ui

Status Category Percentage Covered / Total
🔵 Lines 94.67%
⬆️ +1.11 pp
9793 / 10344
🔵 Statements 92.34%
⬆️ +0.90 pp
13593 / 14720
🔵 Functions 90.85%
⬆️ +0.29 pp
3793 / 4175
🔵 Branches 81.97%
⬆️ +1.11 pp
5111 / 6235
File CoverageNo changed files found.
Generated in workflow #216 for commit fe7bdc5 by the Vitest Coverage Report Action

@smitt14ua smitt14ua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big coverage win and most tests are solid (the XSS ones especially). But three tests don't check what their names say — I broke the matching code and they still passed. Please tighten them before merge. Details below.

Technical details

Verified locally: npx vitest run on the new file — 36/36 pass, also after merging current main. Mutations below were applied to ui/src/pages/recording-playback/useRenderBridge.ts, each one alone; all 36 tests still passed.

1. (blocking) "marks a unit hit on the current frame for the renderer" — useRenderBridgeOverlays.test.tsx:738

Mutation: hit: hitEntityIds.has(id), → hit: false, (line 216) — passes. The test only checks the victim's marker exists. Fix: spy on renderer.updateEntityMarker and assert the victim's update has hit: true on frame 8 and the shooter's has hit: false (optionally hit: false again after seeking past frame 8).

2. (blocking) "grows blobs as more deaths fall inside the playhead" — :637-654

Mutation: if (blob && Math.abs(blob.radius - radius) > 1) { → if (false) { (blobs never recreated with a new radius) — passes. created() is cumulative, so length >= earlyCount is always true, and early.length > 0 only proves something was drawn. Fix: put both deaths in the same cell (same position), seek 10 → 20, and assert that the cell's handle was removed and recreated with a larger size[0] than before.

3. (blocking) "enables smoothing only while playing, sized to the frame interval" — :758

Mutation: renderer.setSmoothingEnabled(playing, frameIntervalSec) → setSmoothingEnabled(false, frameIntervalSec) — passes. The engine is never started, so every assertion is (false, …). Fix: call engine.play() and assert toHaveBeenLastCalledWith(true, 0.1), then pause and assert false again. Or rename the test to only claim the interval sizing.

4. Nits

  • :563 "does not draw a degenerate one-point trail" accepts both outcomes ("either nothing was created, or…"). Fine as a guard, but if the intended behaviour is "no polyline at all", assert polylines.length === 0.
  • :182 "rebuilds the label when a second ping joins": the comment about "the later time" is followed by an alpha assertion, which doesn't check the time. Reword or assert the label text.

…ions

Addresses review feedback.

- hit test now spies updateEntityMarker and asserts the victim's own handle
  receives hit: true on the hit frame, the shooter hit: false, and the victim
  falls back to hit: false one frame later. Mapping an entity to its handle
  reads the createEntityMarker spy result, since the handle is the return value
  rather than an argument.
- the heatmap growth test needs two cells to work at all: radius is
  count/busiest, so a lone cell always scores 1 and never changes size. Two
  deaths in a busy cell plus a far cell that catches up at frame 20 now assert
  the small blob's handle is removed and a larger one drawn in its place
- smoothing test starts and pauses the engine, so it asserts (true, interval)
  while playing instead of only ever seeing the paused value
- degenerate trail now asserts no polyline at all, using a unit that starts one
  frame before the playhead so only the head point resolves
- ping group label test asserts the rendered text actually changed rather than
  claiming to check the time while asserting alpha

Verified against the reviewer's mutations: hit:false, the blob radius guard,
setSmoothingEnabled(false, ..) and removing the points.length < 2 guard are each
caught by exactly one test
@fank

fank commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

Fixed in a7158482. All three reproduced and re-verified with your mutations — each is now caught by exactly one test, so none of them pass by collateral.

1. Hit flag. The test only checked that the victim's marker existed, which is why hit: false slipped through. It now maps each entity to its own handle and asserts hit: true for the victim on frame 8, hit: false for the shooter, and hit: false for the victim again after seeking to frame 9. Worth noting why the first attempt returned nothing: createEntityMarker(id, opts) takes the id and returns the handle, so the mapping has to read the spy's mock.results, not its arguments.

2. Death blob growth. Your diagnosis points at something stronger: with a single cell the radius cannot change at all. deathBlobRadius sizes against count / busiest, and a lone cell always has busiest == count, so share is 1 and the radius is 60 m regardless of how many deaths land there. The old scenario could not have exercised that branch even with correct code — if (false) was not merely an unnoticed escape, the test was structurally incapable of failing. The replacement uses two cells (two deaths in a busy cell, one in a far cell that catches up at frame 20), asserts two distinct radii before, then that the small blob's handle is removed and a larger one drawn in its place. That also spells out the behaviour worth pinning: the radius is baked into the handle at creation, so growth means discard-and-redraw, not update.

3. Smoothing. The engine was never started, so every assertion saw the paused value. Now calls engine.play() and asserts (true, 0.1), pauses back to (false, 0.1), and repeats the sizing at 1x and 60x while playing, plus the clamp at speed 0.

4. Degenerate trail. Now asserts the intended outcome, toHaveLength(0). Getting there needed a genuine one-point case: the old scenario at startFrame: 60 with the playhead at 60 actually produced two points — the stride sample at 60 plus the head — which is why it could only assert something loose. startFrame: 61 with the playhead at 62 leaves no stride sample resolving. Mutation check: removing the points.length < 2 guard is now caught.

5. Ping label comment. The comment claimed to check the time while the assertion checked alpha. It now captures the label text before the second ping and asserts the rebuilt text really differs, alongside the two-line <br> structure.

Mutation transcript (useRenderBridge.ts, one change at a time, each alone):

hit: false                      -> CAUGHT (1 failed | 35 passed)
blob radius guard -> if (false) -> CAUGHT (1 failed | 35 passed)
setSmoothingEnabled(false, ..)  -> CAUGHT (1 failed | 35 passed)
points.length < 2 -> if (false) -> CAUGHT (1 failed | 35 passed)

useRenderBridge.ts is untouched; npx tsc --noEmit clean; full suite 2271 passed / 13 skipped.

@fank
fank requested a review from smitt14ua October 25, 2026 13:25

@smitt14ua smitt14ua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — re-ran the mutations on fe7bdc53: hit flag, blob regrowth and smoothing are each caught now, and tsc is clean. LGTM.

@smitt14ua
smitt14ua merged commit f4cfae4 into main Oct 25, 2026
3 checks passed
@smitt14ua
smitt14ua deleted the claude/coverage-render-bridge branch October 25, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants