Skip to content

test(mcp-server): complete the unit test matrix (prompt 20)#4024

Open
gilgardosh wants to merge 1 commit into
claude/mcp-prompt-19-metrics-tracingfrom
claude/mcp-prompt-20-unit-test-matrix
Open

test(mcp-server): complete the unit test matrix (prompt 20)#4024
gilgardosh wants to merge 1 commit into
claude/mcp-prompt-19-metrics-tracingfrom
claude/mcp-prompt-20-unit-test-matrix

Conversation

@gilgardosh

Copy link
Copy Markdown
Collaborator

Summary

Implements Prompt 20 — Unit test matrix completion from
docs/mcp/implementation-blueprint.md.
Rounds out deterministic, service-free unit coverage across the core modules the blueprint calls
out. Stacked on top of the prompt 19 branch (claude/mcp-prompt-19-metrics-tracing).

What's added

  • Env config validation — cover loadEnv's fail-fast startup path (invalid environment → printed
    report + process.exit(1), with process.exit/console.error stubbed) and the valid-source happy
    path. dotenv is pointed at a nonexistent file so no real .env leaks in.
  • Token validation edge cases — verification through a key-resolver function, rejection of a
    signature-valid token that is missing the sub claim, and the per-request principal store
    (setAuthPrincipal/getAuthPrincipal round-trip + isolation between requests).
  • Registry/schema validation — charges tool now covers a single impossible toDate and an
    over-cap date range; the balance report tool covers a regex-passing but impossible date.
  • Output truncation — default-summary branches (No results., and returned-of-total with and
    without the truncated marker).

The policy evaluator and error mapper (taxonomy) already had thorough dedicated suites; the gaps
addressed here are the ones the coverage report flagged.

Coverage

Package branch coverage improves from ~83.9% → ~85.9% (statements ~89.5% → ~90.8%); token.ts
reaches full line coverage. All tests are deterministic and call no external services.

yarn workspace @accounter/mcp-server lint, typecheck, and test (236 passing) all green.

🤖 Generated with Claude Code


Generated by Claude Code

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the unit test matrix for @accounter/mcp-server core modules, adding deterministic, service-free coverage for env loading/validation, auth token verification edge-cases, tool date-range guards, and list output summaries/truncation behavior.

Changes:

  • Add loadEnv fail-fast startup tests (invalid env triggers report + process.exit(1), valid env returns config without exiting).
  • Expand auth token tests for key-resolver verification, missing sub claim rejection, and per-request principal storage isolation.
  • Extend tool-level date validation tests (impossible-but-regex-valid dates, oversized ranges) and output summary string coverage.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/mcp-server/src/config/tests/env.test.ts Adds unit coverage for loadEnv exit-on-invalid and success-with-valid-source paths without leaking real .env.
packages/mcp-server/src/auth/tests/token.test.ts Adds token verification edge-case tests and request-scoped principal store round-trip/isolation coverage.
packages/mcp-server/src/tools/tests/charges.test.ts Adds date parsing/range-cap validation tests for searchChargesTool (invalid toDate, over-cap ranges).
packages/mcp-server/src/tools/tests/reports.test.ts Adds impossible-date test for balanceReportTool to ensure handler-level Date.parse guard rejects it.
packages/mcp-server/src/tools/tests/output.test.ts Adds coverage for shapeListResult default summary branches including truncated marker variants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gilgardosh
gilgardosh force-pushed the claude/mcp-prompt-19-metrics-tracing branch from 9c913b3 to 89f5084 Compare July 22, 2026 12:05
Round out deterministic, service-free unit coverage across the core modules
(blueprint prompt 20):

- Env config: cover loadEnv's fail-fast startup path (invalid → report + exit)
  and the valid-source happy path, with process.exit/console.error stubbed.
- Token validation edge cases: verify via a key-resolver function, reject a
  signature-valid token missing the subject claim, and round-trip the
  per-request principal store (setAuthPrincipal/getAuthPrincipal isolation).
- Charges tool: reject a single impossible toDate and an over-cap date range.
- Balance report tool: reject an impossible (regex-passing) date.
- Output truncation: default-summary branches ("No results.", returned-of-total
  with and without the truncated marker).

Branch coverage improves from ~83.9% to ~85.9%; token.ts reaches full line
coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPMszz9gdZFhNjobRm6Ndo
@gilgardosh
gilgardosh force-pushed the claude/mcp-prompt-20-unit-test-matrix branch from 7e31661 to 622a6e3 Compare July 22, 2026 12:06
@gilgardosh
gilgardosh temporarily deployed to accounter-fullstack July 22, 2026 12:06 — with GitHub Actions Inactive
@gilgardosh
gilgardosh temporarily deployed to accounter-fullstack July 22, 2026 12:06 — with GitHub Actions Inactive
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.

3 participants