Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
test/coverage-improvement-api-skills-36d354767d5e6349
Draft

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

Conversation

@github-actions
Copy link
Copy Markdown

Summary

Phase 2 of the Daily Test Coverage Improver plan. Implements the top 3 priorities from the research issue.

New Test Files

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

Tests for validateObject and validateRequiredString:

  • Valid objects (empty, with properties, arrays, nested)
  • Invalid values: null, undefined, numbers, strings, booleans
  • Custom fieldName appears in error messages
  • Whitespace-only strings rejected by validateRequiredString

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

Tests for apiSuccess, validationErrorResponse, serviceUnavailableResponse:

  • Correct HTTP status codes (200, 400, 503)
  • success: true/false field set correctly
  • meta included only when provided
  • Uses vi.mock('next/server') to isolate from Next.js runtime

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

Tests for getNextAchievableSkills (complex pure function):

  • Empty profile → only foundation skills (javascript, python, html, sql, git)
  • Prerequisites unlock skills at any level (even beginner)
  • Multi-prerequisite skills (react, ci-cd) require ALL dependencies
  • Skills at intermediate/advanced level are excluded from results
  • Duplicate skill entries use the highest level
  • SKILL_PREREQUISITES data integrity: unique IDs, no unknown prerequisite references

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

Test Files  3 passed (3)
     Tests  52 passed (52)

Full suite: 1077 passing (up from ~1041), 10 pre-existing failures in client.test.ts unchanged (token mocking issue tracked separately).

Notes

  • All tests follow project conventions: describe/it blocks, it.each for table-driven cases, AAA pattern
  • Tests are colocated with source files per project conventions
  • Pre-existing client.test.ts failures are unrelated to these changes (missing gh auth in CI)

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 52 new unit tests across 3 files:

- src/lib/api/validation-utils.test.ts (28 tests)
  - validateObject: null/undefined/number/string/bool/valid object
  - validateRequiredString: null/undefined/empty/whitespace/valid

- src/lib/api/response-utils.test.ts (11 tests)
  - apiSuccess: data, meta, no-meta, array, null data
  - validationErrorResponse: 400 status, with/without meta
  - serviceUnavailableResponse: 503 status, with/without meta

- src/lib/skills/prerequisites.test.ts (13 tests)
  - Empty profile returns only foundation skills
  - Prerequisites unlock skills correctly
  - Multi-prereq skills (react, ci-cd) require all deps
  - Already-intermediate/advanced skills are excluded
  - Duplicate skill entries use highest level
  - SKILL_PREREQUISITES data integrity checks

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