You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of #839 — [Audit][Round 2] A++ umbrella. Phase: P3 · Finding: R2-9 · Priority: HIGH (grade F module)
Problem
game-ui has 108 pub fns, 0 tests. All UI screens, menus, and widgets are untested. This is one of two grade-F modules in the codebase (the other is engine-rhi, addressed in R2-4). UI bugs (broken navigation, dead buttons, layout regressions on resize) ship silently.
modules/game-ui/src/screens/world.zig is 969 LOC; screens/home.zig, screens/world_list.zig, screens/graphics.zig, screens/settings.zig are all untested
108 pub fns across the module (screen lifecycle, input handling, widget state machines, settings binding)
Co-located tests are an explicit AGENTS.md rule: "Add tests alongside modules"
For contrast:
engine-math ratio 4.00 (A)
world-core ratio 2.33 (A)
world-meshing ratio 2.09 (A)
game-ui ratio 0.00 (F)
Fix
Three layers, in order of return-on-investment:
Layer 1 — Pure state machines (highest ROI, no GPU)
Extract and test the pure-logic cores of each screen:
WorldListScreen state: filter/sort logic, world-metadata parsing, selection state → world_list_state.zig. Test sorting, filtering, pagination.
SettingsScreen state: keybind rebinding, graphics-preset application, value clamping → settings_state.zig. Test value clamping, keybind conflict detection.
Then screens/*_tests.zig can exercise lifecycle: init → input("Enter") → update() → assert navigated to next screen.
Layer 3 — Visual regression hooks
Where headless graphics rendering is feasible (R2-4 mock RHI), wire 2-3 happy-path screen tests through the existing headless-screenshot skill to catch layout regressions.
Verification
nix develop --command zig build test -- --test-filter "WorldListState" and similar
nix develop --command zig build test overall still green
Coverage target: game-ui ratio ≥ 0.4 (43+ tests for 108 pub fns). Stretch: ≥ 0.7 (grade B+).
Co-locate tests under modules/game-ui/src/screens/*_tests.zig per AGENTS.md.
Wire into the test aggregator at src/tests.zig.
Constraints
Tests must run without a GPU (Layer 1 + 2) or with mock RHI (Layer 3).
No production code changes unless extraction is required to make it testable (Layer 1). Extracted state modules are a legitimate refactor.
One PR per layer is acceptable.
Conventional commits: test(game-ui): add WorldListScreen state tests, test(game-ui): add mock UI host for screen lifecycle, etc.
Notes
Coordinate with R2-8 (silent-error surfacing) — the toast-mock harness developed here benefits both.
Layer 1 extraction (state-machine pull-out) is also good SRP discipline — fat screens like world_list.zig and world.zig (969 LOC) benefit from having their pure cores separated from rendering.
Part of #839 — [Audit][Round 2] A++ umbrella.
Phase: P3 · Finding: R2-9 · Priority: HIGH (grade F module)
Problem
game-uihas 108 pub fns, 0 tests. All UI screens, menus, and widgets are untested. This is one of two grade-F modules in the codebase (the other isengine-rhi, addressed in R2-4). UI bugs (broken navigation, dead buttons, layout regressions on resize) ship silently.Evidence
find modules/game-ui -name '*.zig' | xargs grep -l '^test '→ zero resultsmodules/game-ui/src/screens/world.zigis 969 LOC;screens/home.zig,screens/world_list.zig,screens/graphics.zig,screens/settings.zigare all untestedFor contrast:
engine-mathratio 4.00 (A)world-coreratio 2.33 (A)world-meshingratio 2.09 (A)game-uiratio 0.00 (F)Fix
Three layers, in order of return-on-investment:
Layer 1 — Pure state machines (highest ROI, no GPU)
Extract and test the pure-logic cores of each screen:
WorldListScreenstate: filter/sort logic, world-metadata parsing, selection state →world_list_state.zig. Test sorting, filtering, pagination.SettingsScreenstate: keybind rebinding, graphics-preset application, value clamping →settings_state.zig. Test value clamping, keybind conflict detection.GraphicsMenustate: preset matrix, slider-to-setting mapping →graphics_menu_state.zig. Test preset application, slider clamping.Target: 60+ tests across these state modules. Lifts
game-uiratio from 0.00 to ~0.5.Layer 2 — Mock UI host
Build on
engine-ui's existing test harness (if any). Createmodules/game-ui/src/test_host.zig:MockInputHost— implementsIInputHost(fake keyboard/mouse events)MockDrawHost— implementsIDrawHost(records draw calls instead of executing them)MockNavigationHost— implementsINavigationHost(records push/pop transitions)Then
screens/*_tests.zigcan exercise lifecycle:init → input("Enter") → update() → assert navigated to next screen.Layer 3 — Visual regression hooks
Where headless graphics rendering is feasible (R2-4 mock RHI), wire 2-3 happy-path screen tests through the existing
headless-screenshotskill to catch layout regressions.Verification
nix develop --command zig build test -- --test-filter "WorldListState"and similarnix develop --command zig build testoverall still greengame-uiratio ≥ 0.4 (43+ tests for 108 pub fns). Stretch: ≥ 0.7 (grade B+).modules/game-ui/src/screens/*_tests.zigper AGENTS.md.src/tests.zig.Constraints
test(game-ui): add WorldListScreen state tests,test(game-ui): add mock UI host for screen lifecycle, etc.Notes
world_list.zigandworld.zig(969 LOC) benefit from having their pure cores separated from rendering.game-ui-test-coverageCI gate (codecov threshold) would prevent regression. Out of scope here; tracked in Production-Readiness Audit: missing CI / lint / benchmark / regression guardrails #834.Tracking: #839