Skip to content

test: add unit tests for API utils and skill prerequisites (Phase 2)#117

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-improvements-phase2-2026-03-20-8dfaff4ace4519a3
Draft

test: add unit tests for API utils and skill prerequisites (Phase 2)#117
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-improvements-phase2-2026-03-20-8dfaff4ace4519a3

Conversation

@github-actions
Copy link
Copy Markdown

Summary

Phase 2 of the Daily Test Coverage Improver plan from #55. Adds 54 new unit tests across 3 previously uncovered files.


Files Added

src/lib/api/validation-utils.test.ts — 24 tests

Pure function tests for validateObject and validateRequiredString:

  • Null/undefined/falsy rejections
  • Whitespace-only string rejection
  • Non-object type rejections (string, number, boolean)
  • Documents array behavior (typeof [] === 'object', passes as valid)
  • Correct fieldName used in error messages

src/lib/api/response-utils.test.ts — 14 tests

Tests for apiSuccess, validationErrorResponse, serviceUnavailableResponse:

  • Correct HTTP status codes (200, 400, 503)
  • success: true/false field
  • Meta included when provided, omitted when not
  • Various data shapes (object, array, null)

src/lib/skills/prerequisites.test.ts — 16 tests

Tests for getNextAchievableSkills:

  • Empty profile → only foundation skills returned
  • Beginner skills still included (not yet excluded)
  • Intermediate/advanced skills excluded from results
  • Single prerequisite unlocking (javascript → typescript)
  • Multi-prerequisite unlocking (javascript + html + css → react)
  • Cascading prerequisites (react + typescript → nextjs)
  • Duplicate skill entries → highest level wins
  • Two-prereq skill (git + testing → ci-cd)

Coverage Improvement

File Before After
src/lib/api/validation-utils.ts 0% ~100%
src/lib/api/response-utils.ts 0% ~100%
src/lib/skills/prerequisites.ts 0% ~100%

Test Results

All 54 new tests pass ✅. Full test suite unaffected.

Generated by Daily Test Coverage Improver

To install this workflow, run gh aw add githubnext/agentics/workflows/daily-test-improver.md@828ac109efb43990f59475cbfce90ede5546586c. View source at https://github.com/githubnext/agentics/tree/828ac109efb43990f59475cbfce90ede5546586c/workflows/daily-test-improver.md.

…equisites

- src/lib/api/validation-utils.test.ts: 24 tests covering validateObject and
  validateRequiredString (null/undefined/falsy/whitespace/type checks)
- src/lib/api/response-utils.test.ts: 14 tests covering apiSuccess,
  validationErrorResponse, and serviceUnavailableResponse (status codes,
  body shape, meta inclusion/omission)
- src/lib/skills/prerequisites.test.ts: 16 tests covering
  getNextAchievableSkills (empty profile, foundation skills, prerequisite
  resolution, cascading prereqs, duplicate skill handling, ci-cd multi-prereq)

Closes #55

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants