Repository navigation
test(ui): cover render bridge overlays (zeus pings/modules, blasts, trails, death heatmap) - #589
Conversation
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%.
Coverage Report for ui
File CoverageNo changed files found. |
smitt14ua
left a comment
There was a problem hiding this comment.
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", assertpolylines.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
|
Fixed in 1. Hit flag. The test only checked that the victim's marker existed, which is why 2. Death blob growth. Your diagnosis points at something stronger: with a single cell the radius cannot change at all. 3. Smoothing. The engine was never started, so every assertion saw the paused value. Now calls 4. Degenerate trail. Now asserts the intended outcome, 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 Mutation transcript (
|
smitt14ua
left a comment
There was a problem hiding this comment.
Thanks — re-ran the mutations on fe7bdc53: hit flag, blob regrowth and smoothing are each caught now, and tsc is clean. LGTM.
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 realPlaybackEngine+MarkerManageragainstMockRenderer, spying on the briefing/entity marker API so assertions are on what the map is actually told to draw:<img src=x onerror=…>renders as text, never as a tag), and module curator/display/attached names are escaped tooUnit <id>; unnamed curator →Zeus <id>with no dangling separator; unknown side → the#ffcc00default colourindirectHitRange(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 barrageplayersmode;followedmode 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 markerff3b3b, positive radius), growing with the playhead, and every blob released when hidden againcrewnaming only the player, a vehicle with no player crew does not, and a unit past itsendFramehas its marker handle released0.1 sat the default 10x,1 sat 1x,1/60 sat 60x, clamped so it is never zero-length), dragging the map releases the follow lock, and the CSS--leaflet-left-offsetfollows the side panelCoverage impact
useRenderBridge.tslinesuseRenderBridge.tsbranchesVerification
npx tsc --noEmitclean.main.internal/, so they can land in any order relative to this one.