Skip to content

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

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

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

Conversation

@github-actions
Copy link
Copy Markdown

Closes #55

Summary

Phase 2 implementation from the Daily Test Coverage Improver plan. Adds 62 new passing tests across 3 previously untested files.

New Test Files

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

Tests validateObject and validateRequiredString pure functions:

  • null, undefined, wrong-type inputs → error message returned
  • valid object / non-empty string → null returned
  • fieldName interpolated correctly in error messages
  • Whitespace-only strings rejected, single-char strings accepted
  • Table-driven with it.each

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

Tests apiSuccess, validationErrorResponse, serviceUnavailableResponse:

  • Correct HTTP status codes (200, 400, 503)
  • success: true/false in body
  • Data and meta fields present/absent as expected
  • Error messages preserved verbatim
  • Various data shapes (object, array, null, string)

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

Tests getNextAchievableSkills and SKILL_PREREQUISITES:

  • Empty profile → all foundation skills returned
  • Skill at intermediate/advanced → excluded from results
  • Skill at beginner → still returned as "next achievable"
  • Prerequisite chains: typescript unlocked by JS, react by JS+HTML+CSS, nextjs by react+TS, etc.
  • Partial prerequisites → skill NOT unlocked
  • Duplicate skill entries → highest level wins
  • Data integrity: all prerequisite IDs reference valid skill nodes

Coverage Comparison

Metric Before After
Test files 63 66
Tests passing 1025 1087
src/lib/api/validation-utils.ts 0% ~100%
src/lib/api/response-utils.ts 0% ~100%
src/lib/skills/prerequisites.ts 0% ~100%

Pre-existing failures in src/lib/github/client.test.ts (10 tests) are unchanged — these require a separate fix.

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 3 new test files identified in #55:
- src/lib/api/validation-utils.test.ts (21 tests)
- src/lib/api/response-utils.test.ts (21 tests)
- src/lib/skills/prerequisites.test.ts (20 tests)

These cover previously untested pure functions in src/lib/api/
and the Knowledge Space Theory logic in src/lib/skills/prerequisites.ts.

Total: +62 passing tests (1087 vs 1025 baseline).

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