Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-improvements-phase2-24d3beca351d0e12
Draft

test: add unit tests for API utils and skill prerequisites (Phase 2)#126
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-improvements-phase2-24d3beca351d0e12

Conversation

@github-actions
Copy link
Copy Markdown

Implements the Phase 2 test coverage improvements planned in #55.

What's added

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

Covers validateObject and validateRequiredString with table-driven it.each cases:

  • Returns error message for null, undefined, numbers, strings, booleans
  • Returns null for valid objects (including {})
  • Error messages include the fieldName parameter
  • validateRequiredString rejects empty strings, whitespace-only strings, and non-string values

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

Covers apiSuccess, validationErrorResponse, and serviceUnavailableResponse:

  • Correct HTTP status codes (200 / 400 / 503)
  • Response body shape: success, data/error, optional meta
  • Handles various data types (objects, arrays, null)
  • meta is omitted when not provided, included when passed

src/lib/skills/prerequisites.test.ts — 13 new tests

Covers getNextAchievableSkills with realistic scenarios:

  • Empty profile returns all foundation skills (no prerequisites)
  • Skills with unmet prerequisites are excluded
  • Skills are unlocked when prerequisites are present at any level
  • Skills already at intermediate/advanced are excluded
  • Skills at beginner remain achievable (not yet intermediate)
  • Multi-prerequisite skills unlock only when all prerequisites are present
  • Cascading prerequisites (nextjs → react+typescript)
  • Duplicate skill entries use the highest level
  • Returned nodes have correct shape

Coverage comparison

Metric Before After
Test files 63 66
Passing tests 1025 1077
New tests +52

Pre-existing failures in src/lib/github/client.test.ts (10 tests, missing token in CI) are unchanged — as noted in #55.

All new tests pass. TypeScript (npx tsc --noEmit) is clean.

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.

- Add validation-utils.test.ts: 22 tests covering validateObject and
  validateRequiredString with table-driven cases for valid/invalid inputs
- Add response-utils.test.ts: 17 tests covering apiSuccess,
  validationErrorResponse, and serviceUnavailableResponse including
  status codes, body shape, data and meta handling
- Add prerequisites.test.ts: 13 tests covering getNextAchievableSkills
  including empty profile, foundation skills, cascading prerequisites,
  intermediate/advanced exclusion, duplicate skill handling

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