Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-phase2-api-skills-9b3d1ad4c6b92904
Draft

test: add unit tests for API utils and skill prerequisites (Phase 2)#112
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-phase2-api-skills-9b3d1ad4c6b92904

Conversation

@github-actions
Copy link
Copy Markdown

Implements the Phase 2 test coverage plan from #55.

What's added

src/lib/api/validation-utils.test.ts (22 tests)

Covers validateObject and validateRequiredString:

  • Invalid inputs: null, undefined, non-string types, non-object types
  • Whitespace-only strings correctly rejected
  • Valid objects and non-empty strings return null
  • Uses it.each for table-driven test cases

src/lib/api/response-utils.test.ts (15 tests)

Covers apiSuccess, validationErrorResponse, serviceUnavailableResponse:

  • Correct HTTP status codes: 200 / 400 / 503
  • success: true/false field on all responses
  • meta included when provided, omitted when not
  • Various data types handled correctly by apiSuccess

src/lib/skills/prerequisites.test.ts (11 tests)

Covers getNextAchievableSkills:

  • Empty profile returns all foundation skills
  • Skills with unmet prerequisites are excluded
  • Skills at beginner remain achievable, intermediate/advanced are excluded
  • Cascading prerequisites (e.g. nextjs requires react + typescript)
  • Duplicate skill entries: highest level wins
  • All skills intermediate+ → empty result

Coverage comparison

Metric Before After
Test files 63 (3 failing pre-existing) 66 (same 3 failing)
Tests 1035 (10 failing) 1083 (same 10 failing)
New tests added +48

The 10 pre-existing failures are all in src/lib/github/client.test.ts (token unavailable in CI) — unchanged.

Closes #55

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.

- validation-utils.test.ts: 22 tests covering validateObject and
  validateRequiredString with null/undefined/whitespace/non-string inputs
- response-utils.test.ts: 15 tests covering apiSuccess (200),
  validationErrorResponse (400), and serviceUnavailableResponse (503),
  including meta inclusion/omission
- prerequisites.test.ts: 11 tests covering getNextAchievableSkills:
  empty profile, foundation skills, prerequisite gating, level exclusion,
  duplicate skill deduplication (highest level wins), cascading unlocks

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.

Daily Test Coverage Improver - Research and Plan

0 participants