| Filename | Latest commit message | Latest commit date |
|---|---|---|
* refactor(web): update OAuth E2E tests to use new authentication method - Replaced `runGuidedAuth` with `authenticate` in the InspectorClient OAuth end-to-end tests to support quick authentication with CIMD pre-registration. - Updated comments to reflect the change in authentication method and its support for HTTP test metadata URLs. - Ensured that the tests continue to validate the expected authorization URL after the change. Additionally, imported `ensureCimdClientRegistration` in the OAuthManager to streamline client registration during the authentication process. * Guided-auth removal, OAuth smoke testing, and TUI/CLI support * Added CLI OAuth runner flags tests * Added clarifying comment on port 0 binding * README notes on TUI oauth callback port, prettier fixes for CLI tests * CIMD validation uses inline like EMA IdP * Fixed TUI test failures from merge * test: bring 5 OAuth files over the 90 per-file coverage gate The guided-auth-removal work added/touched several files that fell below the repo's >=90 per-file coverage gate (npm run coverage). CI doesn't run the gate (it's local-only), so validate + test:integration passed while these gaps slipped through. Bring them all back over the line: - core/auth/node/runner-oauth-callback.ts: test bad-URL/non-http-scheme throws, no-port->80 default, and IPv6 hostname bracketing. Annotate the provably-dead guards (empty host, out-of-range port, String(err) fallback, pathname "/" fallback) -- all rejected by new URL() upstream -- with justified v8 ignore comments instead of lowering the gate. - core/auth/cimd.ts: test the AS-doesn't-support-CIMD early return. - core/react/useClientSettingsDraft.ts: test the functional-updater path, the stale-onChange-after-close prev===null guard, and the timer-fires-after-close value===null guard. - ClientSettingsForm.tsx: test the CIMD checkbox toggle and CIMD URL clear. - clients/tui/src/utils/oauthDisplay.ts: test static/dcr registration kinds, the expired IdP session, and the configured-scope/empty-scope branches of formatScopes. npm run coverage now passes (exit 0) across web, cli, tui, launcher. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: cliffhall <cliff@futurescale.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
| .. | ||
| helpers | ||
| cli.test.ts | ||
| e2e.test.ts | ||
| error-handler.test.ts | ||
| headers.test.ts | ||
| metadata.test.ts | ||
| methods.test.ts | ||
| oauth-runner.test.ts | ||
| README.md | ||
| tools.test.ts | ||
CLI Tests
Running Tests
# Run all tests (pretest builds test-servers + the CLI binary)
npm test
# Run all tests under the per-file coverage gate
npm run test:coverage
# Run in watch mode (useful for test file changes)
npm run test:watch
# Run specific test file
npm run test:cli # cli.test.ts
npm run test:cli-tools # tools.test.ts
npm run test:cli-headers # headers.test.ts
npm run test:cli-metadata # metadata.test.ts
How the CLI is exercised
Most tests run the CLI in-process: helpers/cli-runner.ts imports runCli()
from ../src/cli.ts and invokes it directly, capturing process.stdout/stderr
and mapping thrown errors to an exit code. This is what lets vitest's v8 coverage
instrument clients/cli/src (#1484). Because commander uses .exitOverride(),
a parse/usage error throws instead of calling process.exit and tearing down the
worker.
e2e.test.ts is the deliberately thin out-of-process layer: it spawns the
built build/index.js as a real subprocess to cover the shebang, the
index.ts isMain bootstrap, and the actual process.exit codes — the only
parts the in-process runner can't reach. (scripts/smoke-cli.mjs at the repo
root provides a further end-to-end check of the binary.)
Test Files
cli.test.ts- Basic CLI functionality: CLI mode, environment variables, config files, resources, prompts, logging, transport typestools.test.ts- Tool-related tests: Tool discovery, JSON argument parsing, error handling, promptsheaders.test.ts- Header parsing and validationmetadata.test.ts- Metadata functionality: General metadata, tool-specific metadata, parsing, merging, validationmethods.test.ts- Method/option-validation paths not covered elsewhere (resource templates, missing/invalid options, the--target separator)error-handler.test.ts- The binary'shandleErrorerror sink, exercised in-process withprocess.exitstubbede2e.test.ts- Out-of-process spawn of the built binary (exit codes + boot)
Helpers
The helpers/ directory contains shared utilities:
cli-runner.ts- InvokesrunCli()in-process and captures stdout/stderr + exit codeassertions.ts- Custom assertion helpers for CLI output validationfixtures.ts- Test config/catalog file generators and temporary directory management
HTTP/SSE test servers (for transport tests) come from the
@modelcontextprotocol/inspector-test-server package (createTestServerHttp),
and the bundled stdio server is launched via getTestMcpServerCommand().
Notes
- Test files run in separate forked processes (
pool: 'forks'), so the in-process runner'sprocess.std*.writepatching never overlaps across files; tests within a file run sequentially - Config files use
crypto.randomUUID()for uniqueness - HTTP/SSE servers use dynamic port allocation to avoid conflicts
- Coverage is enforced per-file (lines ≥ 90, statements ≥ 85, functions ≥ 80,
branches ≥ 50).
src/index.ts(the binary bootstrap) is excluded because it only runs in the spawned binary, which coverage can't instrument - All tests use the built-in MCP test servers — no external/registry dependencies