Skip to content

test: add Vitest setup with SiteManager and tool-registry coverage#18

Open
kleintech wants to merge 1 commit into
InstaWP:mainfrom
kleintech:feature/test-suite
Open

test: add Vitest setup with SiteManager and tool-registry coverage#18
kleintech wants to merge 1 commit into
InstaWP:mainfrom
kleintech:feature/test-suite

Conversation

@kleintech
Copy link
Copy Markdown

Summary

Establishes a foundation test suite using Vitest. ESM/TypeScript tests run via esbuild — no prior tsc build needed.

  • SiteManager (17 tests) — env parsing (numbered WORDPRESS_N_* and legacy WORDPRESS_API_URL), getSite lookup with error paths, and detectSiteFromContext covering domain/alias/id matching, case-insensitivity, and null cases.
  • Tool registry wiring (7 tests) — every registered tool has a corresponding handler, no orphan handlers, names are unique, every tool has a non-empty description and an object-shaped inputSchema with a properties record. Catches regressions when adding or renaming tools.
  • GitHub Actions (.github/workflows/test.yml) — runs npm test on PRs and pushes to main on a Node 20 / 22 matrix.
  • README — adds a short "Running Tests" subsection under Development.

npm test runs the full suite in ~500ms.

Notes

  • The CI workflow uses npm install --ignore-scripts because the prepare hook runs npm run build, which currently fails on a fresh install due to axios type drift in media.ts and a TS2589 in server.ts. Those are pre-existing and unrelated to this PR — happy to fix them in a separate one.
  • Initial scope is intentionally narrow ("foundation only"): pure-ish unit coverage with no HTTP mocking. Handler-level tests against a mocked WordPress API are a natural follow-up.

Test plan

  • npm test passes locally (24/24)
  • npm run test:watch re-runs on file changes
  • CI green on Node 20 and 22

🤖 Generated with Claude Code

Establishes a foundation test suite using Vitest. ESM/TypeScript tests
run via esbuild without needing a prior tsc build.

- SiteManager: env parsing (numbered + legacy), getSite lookup, and
  detectSiteFromContext (domain/alias/id matching). 17 tests.
- Tool registry wiring: every tool has a handler, names are unique,
  schemas are object-shaped with properties. 7 tests.
- GitHub Actions workflow runs npm test on PRs and pushes to main
  across Node 20 and 22.
- README documents the new test commands.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant