Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
daily-test-coverage-phase2-2026-03-17-85ef3219c09796b0
Draft

test: add unit tests for API utils and skill prerequisites (Phase 2 retry)#108
github-actions[bot] wants to merge 1 commit intomainfrom
daily-test-coverage-phase2-2026-03-17-85ef3219c09796b0

Conversation

@github-actions
Copy link
Copy Markdown

Closes part of #55 (Daily Test Coverage Improver).

What changed

Added 48 new unit tests across 3 previously uncovered files:

File Tests added Coverage gain
src/lib/api/validation-utils.test.ts 23 ~100% for validateObject & validateRequiredString
src/lib/api/response-utils.test.ts 15 ~100% for apiSuccess, validationErrorResponse, serviceUnavailableResponse
src/lib/skills/prerequisites.test.ts 10 ~100% for getNextAchievableSkills

Test suite comparison

Before After
Test files 63 66
Passing tests 1025 1073 (+48)
Failing tests 10 10 (pre-existing client.test.ts token issue — unchanged)

Coverage highlights

validation-utils

  • Rejects null, undefined, numbers, booleans, strings for validateObject
  • Rejects empty strings and whitespace-only strings for validateRequiredString
  • Verifies field name appears in error messages
  • Accepts arrays (which are objects) for validateObject

response-utils

  • NextResponse is mocked via vi.hoisted() + vi.mock('next/server') to inspect call arguments
  • Verifies success: true / success: false shape
  • Verifies correct HTTP status codes (200, 400, 503)
  • Verifies meta is included only when provided (no spurious keys)

prerequisites

  • Empty profile returns all foundation skills
  • Skills at intermediate/advanced excluded from results
  • Multi-prerequisite skills (nextjs, react) only unlock when all prereqs present
  • Duplicate skill entries resolved to the highest level
  • Returned nodes have the expected shape (skillId, displayName, prerequisites[])

Generated by Daily Test Coverage Improver

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.

…uisites

Add 48 new unit tests across 3 files identified in issue #55:

- src/lib/api/validation-utils.test.ts (23 tests)
  - validateObject: rejects null/undefined/primitives, accepts objects/arrays
  - validateRequiredString: rejects empty/whitespace/non-strings, accepts valid strings

- src/lib/api/response-utils.test.ts (15 tests)
  - apiSuccess: correct shape with/without meta, no spurious keys
  - validationErrorResponse: status 400, correct error format
  - serviceUnavailableResponse: status 503, correct error format

- src/lib/skills/prerequisites.test.ts (10 tests)
  - getNextAchievableSkills: empty profile, unmet prerequisites, level thresholds,
    multi-prerequisite skills, duplicate skill deduplication

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