test: stand up Vitest rig + adjacent coverage for audited surface#38
Open
nx-thaddeusaid wants to merge 28 commits intoBattletechModders:mainfrom
Open
test: stand up Vitest rig + adjacent coverage for audited surface#38nx-thaddeusaid wants to merge 28 commits intoBattletechModders:mainfrom
nx-thaddeusaid wants to merge 28 commits intoBattletechModders:mainfrom
Conversation
Introduce the test-platform branch's working test rig: Vitest configured with jsdom + @vitejs/plugin-react-swc, a setup file that installs @testing-library/jest-dom and a Map-backed localStorage polyfill to work around Vitest 4's empty-object stub under Node 25, dedicated tsconfig.vitest.json, and reusable Konva / react-konva mocks under src/test/. Also relocates the three pre-existing gm.* tests from tests/ to sit adjacent to their source files per CLAUDE.md's placement rule and seeds model/log.md with the decision trail. The next commit adds the adjacent test suites for the rest of the codebase. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Layer 26 new adjacent test files on top of the rig commit, covering every file in the Option-B audit: - Helpers: ApiHelper, CapitalHelper, FactionHelper, NewTabHelper, RouteHelper, devStateInjector, and the barrel index each get positive-path, edge-case, and contract coverage. - Hook tier: useSettings, useTooltip, useWarmapAPI, useFiltering use renderHook + stubbed fetch; useGalaxyViewport and usePinchZoom use queue-based rAF plus a controllable performance.now() to deterministically pin throttle, zoom-clamp, pinch-start/end, and frame-coalescing behavior. - Component tier: PageTemplate, SideMenu, Home (with HomeCard), ToS (with BulletPoint), and Error (all three route-error branches) run under MemoryRouter / createMemoryRouter. BottomFilterPanel drives toggle, search, faction chips, and mobile help tooltip. - Konva smoke tier: StarSystem, GalaxyMap, App, and main.tsx bootstrap run against the shared src/test/konvaMocks reusable mock, with fetch stubbed to produce valid faction/system payloads; main.tsx wraps createRoot to confirm the bootstrap attaches to #react-root. - Pages barrel: pages/index.test.ts re-export contract. - Types: Settings.test.ts exercises initialSettings; hooks/types/index expectTypeOf-asserts the full type-alias surface so every type file is covered under the adjacent convention. Final suite: 29 files / 122 tests passing. `yarn build` and `npx tsc -p tsconfig.vitest.json --noEmit` both clean. Updates model/log.md with sections 8 (authoring strategy per tier) and 9 (final rig verification + coverage map). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…mbers The `test:coverage` script already existed but was unreachable without a provider installed. Pin `@vitest/coverage-v8` to `4.0.8` to match Vitest's version (4.1.x ships an import against `vitest/node` that 4.0.x does not export), configure text/html/lcov reporters with reasonable include / exclude globs, and add `coverage/` to `.gitignore` so generated reports don't dirty the working tree. Initial report: 73.9% stmts · 61.21% branches · 70.52% funcs · 76.75% lines — deep-tested surface at 100%, the Option-B smoke targets (GalaxyMap.tsx, StarSystem.tsx, usePinchZoom.ts) account for the gap, matching the documented posture. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds .github/workflows/test.yml that runs on push to main / test-platform and on any PR to main. Steps: checkout, setup-node with yarn cache, yarn install --frozen-lockfile, tsc --noEmit against tsconfig.vitest.json, yarn test:coverage, and an upload of the coverage/ directory as a 14-day-retention artifact (Node 20 leg only). Matrix covers Node 20 + 22. The workflow only becomes active for PR checks on the upstream repo once this branch merges; until then, the fork's own Actions trigger on each push, providing a pre-merge smoke. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Moves the inline helper bodies out of GalaxyMap.tsx and StarSystem.tsx
into adjacent modules (GalaxyMap.helpers.ts, StarSystem.helpers.ts) and
rewires the two components to call them:
- StarSystem.helpers.ts: buildControlItems, formatControlLine,
formatSystemState, formatDamageLevel, buildTooltipText.
- GalaxyMap.helpers.ts: getViewportSize, getTooltipFontSize,
getDesktopLineSegments (now takes a {titleFontSize, bodyFontSize}
object), and parseMobileTooltipData.
The production behavior is unchanged — two Konva call sites retain their
prior shape via a tiny segmentsFor closure, and buildTooltipText is now
called with an explicit {system, factions[, includeTapHint]} object.
31 new deep tests cover positive paths, empty inputs, ordering, label-
split branches, and the mobile parser's control-block skipping.
Suite: 31 files / 153 tests passing (was 29 / 122). Coverage across the
project: 79.22% stmts / 69.5% branches / 76.16% funcs / 82.43% lines
(was 73.9 / 61.21 / 70.52 / 76.75). The remaining gap lives inside the
Konva render trees, matching the documented Option-B posture.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test-platformbranch, branched fromaca800cper session-scoped instructions (diverges from currentmaintip — reviewers will see the five security-patch commits as missing from the base; re-target or rebase before merge if that is unacceptable).[name].test.ts(x)suites covering every audited source file — helpers, hooks, components, and bootstrap — yielding a green baseline of 29 files / 122 tests withyarn test.model/log.md(action / alternatives / reasoning, per-section).Notable pieces
eba39d0): Vitest config pinned to jsdom +@vitejs/plugin-react-swc;src/test/setup.tswith@testing-library/jest-dom/vitestplus a Map-backedlocalStoragepolyfill to work around Vitest 4's empty-object stub under Node 25; reusablesrc/test/konvaMocks.tsxthatuseImperativeHandle-exposes the Konva methods effects call; dedicatedtsconfig.vitest.json. Relocates the three pre-existinggm.*.test.tsfiles fromtests/to sit adjacent to their source per CLAUDE.md's placement rule.97a4a51): adjacent suites for every source file in the audit (helpers with edge/contract cases; hooks withrenderHook+ stubbed fetch + queue-based rAF; components underMemoryRouter/createMemoryRouter; Konva consumers as smoke tests behind the shared mock;main.tsxverified via a wrappedcreateRoot).Scope posture
This is Option B from the session's three-option plan: deep coverage on pure utilities, hooks, and non-Konva components; smoke coverage on Konva render paths (
GalaxyMap.tsx,StarSystem.tsx,useGalaxyViewport,usePinchZoom). Canvas-accurate assertions were explicitly deferred as a second-pass investment.Test plan
yarn installyarn test— expect 29 files / 122 tests passingnpx tsc -p tsconfig.vitest.json --noEmit— expect cleanyarn build— expect production build succeedsmodel/log.mdfor the full decision trail🤖 Generated with Claude Code