Skip to content

test: add 9 tests for inspectTranscript#12

Merged
protosphinx merged 1 commit intomainfrom
test/inspect-tests
May 3, 2026
Merged

test: add 9 tests for inspectTranscript#12
protosphinx merged 1 commit intomainfrom
test/inspect-tests

Conversation

@protosphinx
Copy link
Copy Markdown
Member

Summary

`mcprec inspect ` is the operator's first-look summary of a recorded transcript — frame count, request/response pair count, per-method counts, error flagging. Until now it had no tests; the existing suite covered every other `src/*` module (10 test files for 10 src files except `inspect.ts`, `record.ts`, `cli.ts`, `index.ts`, `types.ts`).

A regression here is silent in production — operators see a wrong frame count or a missing method and don't realise the formatter dropped data, not the recording.

Coverage (9 tests)

  • Basic shape: renders one line per frame + summary footer.
  • Method counts descending: chatty methods first; a regression to insertion order or alphabetical would silently change the report.
  • Direction filtering: only `→` frames count (they carry `method`); `←` frames don't double-count.
  • Error marker: error responses get a visible `error` label (operators scanning a transcript want errors to stand out).
  • Pair count footer: matches what `pairFrames` returns.
  • Notification handling: a request with no id adds 0 pairs (notifications are not requests).
  • Empty transcript: renders zero-counts summary, doesn't crash.
  • Timestamp width: documented 8-char fixed-width prefix so multi-frame output aligns in the terminal.

Verification

  • `npm test` → 80 passed (was 71; +9 net new) on Node 22
  • `npm run lint` (tsc --noEmit) → clean

`mcprec inspect <file>` is the operator's first-look summary of a
recorded transcript — number of frames, request/response pair count,
per-method counts, errors flagged. Until now it had no tests; the
existing suite covered every other src/* module (10 test files for
10 src files except `inspect.ts`, `record.ts`, `cli.ts`, `index.ts`,
`types.ts`).

A regression here is silent in production — operators see a
wrong frame count or a missing method and don't realise the
formatter dropped data, not the recording.

Coverage:

- Renders one line per frame plus a summary footer (basic shape).
- Counts requests by method, descending — pin the documented
  ordering (chatty methods first) so a regression to insertion
  order or alphabetical doesn't silently change the report.
- Ignores responses when computing method counts; only `→` frames
  carry a `method` and they're the only ones that should count.
  A regression that double-counted both directions would inflate
  every per-method number.
- Renders error responses with a visible "error" marker (operators
  scanning a transcript want errors to stand out, not blend into
  generic "response").
- Reports the request/response pair count in the footer (matches
  what `pairFrames` returns).
- Handles a notification (no id, no response) without adding a
  pair (notifications are not requests).
- Empty transcript renders a sensible summary (zero counts, no
  crash) — the inspect command must not blow up on a fresh-but-
  empty recording.
- Timestamps render with the documented fixed-width 8-char prefix
  so multi-frame output aligns in the terminal; a regression to
  variable-width would shift columns on long transcripts.

Verified locally on Node 22:
  - `npm test` -> 80 passed (was 71; +9 net new)
  - `npm run lint` (tsc --noEmit) clean
@protosphinx protosphinx merged commit 3322e02 into main May 3, 2026
3 checks passed
@protosphinx protosphinx deleted the test/inspect-tests branch May 3, 2026 00:26
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