Skip to content
Strata v1.2.6

2026-05-15: Fix CI coverage failure and improve agent instructions

CI Frontend job fails on every push to main:

ERROR: Coverage for functions (89.06%) does not meet global threshold (90%)

Five untested functions across three frontend files:

FileLinesUntested function(s)
front/src/lib/api/assets.ts29, 31updateSnapshot, deleteSnapshot
front/src/lib/theme.ts25–33initTheme
front/src/lib/hooks/assets.ts79–95useUpdateAssetSnapshot, useDeleteAssetSnapshot

Secondary cause: Agent instruction files do not specify which command enforces coverage thresholds. Agents run npm test which does not enforce thresholds. Only npm run test:cov (backend) and npx vitest run --coverage (frontend) do.

MetricThreshold
Statements90%
Branches80%
Functions90%
Lines90%

Save before implementation starts.

T1 — Fix: lib/api/__tests__/assets.test.ts

Section titled “T1 — Fix: lib/api/__tests__/assets.test.ts”

Add 2 tests: updateSnapshot calls PUT, deleteSnapshot calls DELETE.

Add 2 tests for initTheme: registers matchMedia listener when theme=system, skips it for dark/light. Mock window.matchMedia (jsdom does not implement it).

T3 — Create: lib/hooks/__tests__/assets.test.ts

Section titled “T3 — Create: lib/hooks/__tests__/assets.test.ts”

New test file. renderHook + QueryClientProvider wrapper. Mock assetApi. 1 test each for useUpdateAssetSnapshot and useDeleteAssetSnapshot.

Add ## Coverage Gate (CI-Enforced — MANDATORY) section with exact thresholds, correct command (npm run test:cov), excluded patterns, rule.

Same section adapted for frontend (npx vitest run --coverage).

T6 — agents-plan-checklist.instructions.md

Section titled “T6 — agents-plan-checklist.instructions.md”

Update test gate commands block to show threshold-enforcing commands explicitly.

npx vitest run --coverage → exit 0, all thresholds pass.

#ConventionStatus
1Docs✅ Plan doc saved. No feature change → no additional docs needed.
2All 4 test gates✅ T7 confirms frontend coverage gate
3Self-review✅ All uncovered lines verified against coverage report
4Bruno/Swagger✅ N/A
5Bug-to-Test✅ This plan IS the bug-to-test for the CI failure
6Seed isolation✅ N/A
7Transaction invariants✅ N/A
8Plan history✅ This file
9Infra gate✅ N/A
10Env compat✅ N/A
11Do-no-harm baseline✅ Backend coverage passes locally before any change
12Execution summary✅ Will append after T7
13Doc grep✅ N/A — no renames
14Semver release✅ T8 — patch v1.2.4

Commit: ae2b58b

  • front/src/lib/api/__tests__/assets.test.ts — added updateSnapshot and deleteSnapshot tests
  • front/src/lib/__tests__/theme.test.ts — added initTheme describe block (2 tests, mocking window.matchMedia)
  • front/src/lib/hooks/__tests__/assets.test.ts — new file; tests useUpdateAssetSnapshot and useDeleteAssetSnapshot via renderHook
  • .github/instructions/astro.instructions.md — added “Coverage Gate (CI-Enforced — MANDATORY)” section
  • .github/instructions/nestjs.instructions.md — added “Coverage Gate (CI-Enforced — MANDATORY)” section
  • .github/instructions/agents-plan-checklist.instructions.md — replaced test gate commands block with threshold-enforcing commands and coverage table

None. All 6 planned tasks executed as specified.

GateResult
Frontend unit (npx vitest run --coverage)✅ exit 0, functions 100%, all thresholds pass
Backend unit⏭ not affected
Backend e2e⏭ not affected
Frontend e2e⏭ not affected
  • window.matchMedia is not implemented in jsdom — requires explicit mock (vi.fn().mockReturnValue(...)) for initTheme tests.
  • Hook tests need QueryClientProvider wrapper; @testing-library/react renderHook handles this cleanly.