Skip to content

test: ratchet coverage thresholds + fill tests/lib branch gaps (#107 P0) - #155

Merged
cheerc merged 1 commit into
mainfrom
test/107-p0-coverage-ratchet
Jun 24, 2026
Merged

test: ratchet coverage thresholds + fill tests/lib branch gaps (#107 P0)#155
cheerc merged 1 commit into
mainfrom
test/107-p0-coverage-ratchet

Conversation

@cheerc

@cheerc cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Coverage threshold ratchet + branch gap fill for tests/lib helpers. Part of #107 Phase 2 P0.

Part 1: Threshold Ratchet

Bump vitest coverage thresholds to match current actuals minus ~3% buffer:

Metric Old New Actual
Statements 55% 67% 70.71%
Branches 65% 74% 78.14%
Functions 75% 82% 87.09%
Lines 55% 67% 70.06%

Part 2: Branch Gap Fill

New tests/unit/libBranchGaps.test.js (12 tests) covering:

undoRedoHelpers.js (71.42% → 100% branch) 🎉

  • L33-36: Default parameter branches for optional callbacks (onLoadState, onUpdateButtons, onCheckDirty, onUpdateCleanSnapshot)
  • Tests: exercise module with omitted callbacks + with provided callbacks

scheduleListHelpers.js (96.66% → 100% branch) 🎉

  • L59: backendResult.lastModified falsy branch — backend omits lastModified, scheduleLastModified should not be updated

dataCollectionHelpers.js (92.06% branch — improved but some gaps remain)

  • collectFromAllCourses: null schedules, missing data/scheduleData, null classroom, non-array day schedule
  • getGlobalAllTags: courses without tags, non-array tags
  • getGlobalAllCourseNames: courses without name
  • getGlobalAllTeachers: courses without teacher

Changed Files (2)

  • vitest.config.js (threshold update)
  • tests/unit/libBranchGaps.test.js (new, 12 tests)

Verification

  • npm test: 1154 tests passed (37 files) ✅
  • npx vitest run --coverage: all thresholds pass ✅
  • 2 of 3 target files at 100% branch coverage ✅

refs #107

Part 1: Bump vitest coverage thresholds from 55/65/75/55 to 67/74/82/67
(actuals minus ~3% buffer). Previous buffer was ~5%, tightened to ~3%.

Part 2: Add libBranchGaps.test.js with 12 new test cases covering:
- undoRedoHelpers.js L33-36: default parameter branches (71.42% → 100%)
- dataCollectionHelpers.js: null/missing data, non-array tags, null classroom
- scheduleListHelpers.js L59: lastModified falsy branch (96.66% → 100%)

Overall branch coverage: 77.38% → 78.14%
undoRedoHelpers branch: 71.42% → 100%
scheduleListHelpers branch: 96.66% → 100%

All 1154 tests pass. Thresholds pass.

refs #107

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Agend-Agent: cb-team-impl
Agend-Task: t-20260624113612576521-40473-30
Agend-Branch: test/107-p0-coverage-ratchet
Agend-Issued-At: 2026-06-24T11:36:44.587554+00:00
@cheerc

cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner Author

✅ VERIFIED

Reviewed HEAD: 31022e6
Reviewer: cb-team-reviewer
Audit mode: fast_path (D1 — test-only, no production code)

Files Reviewed (2)

  • vitest.config.js — threshold ratchet 55/65/75/55 → 67/74/82/67
  • tests/unit/libBranchGaps.test.js (new, +240) — branch gap tests for 3 lib helpers

Fast Path Checklist

  • No production code changes
  • Threshold ratchet: ~3% buffer from actuals (70.71/77.38/84.94/70.06) ✓
  • New test targets documented uncovered branches:
    • undoRedoHelpers L33-36 (default param no-ops)
    • dataCollectionHelpers L58/77-78 (null guards, non-array tags)
    • scheduleListHelpers L59 (lastModified falsy)
  • Correct imports from tests/lib/
  • refs [Test-Coverage] Phase 2 — 覆蓋缺口補齊 + 重構前置強化 #107

Evidence

  • cited: vitest.config.js — lines:67, functions:82, branches:74, statements:67
  • cited: libBranchGaps.test.js:1-9 — targets 3 helpers with documented branch %

@cheerc
cheerc merged commit 7ba266a into main Jun 24, 2026
1 check passed
@cheerc
cheerc deleted the test/107-p0-coverage-ratchet branch June 24, 2026 11:44
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.

1 participant