test: add 26 unit tests for session-parser lib - #133
Closed
TerminalGravity wants to merge 3 commits into
Closed
Conversation
TerminalGravity
commented
Mar 7, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
Solid test coverage for the session parser — 24 cases covering JSONL parsing, subagent detection, array content blocks, and edge cases like empty/malformed files. Clean temp dir setup/teardown.
One minor thing: the findSessionDirs test hardcodes a ~/.claude/projects path expectation — might be worth making that configurable via env var so CI doesn't depend on home dir structure. Not a blocker, LGTM.
Comprehensive coverage for the previously untested session-parser module: - findSessionFiles: top-level and subagent discovery - parseSession: prompts, corrections, assistant text, tool_use, sub_agent_spawn, tool_result errors, compaction events, summary extraction, malformed JSON - Timestamp normalization: epoch seconds, epoch ms, string, fallback to mtime - All 7 correction patterns verified - parseSessionAsync: parity with sync parser - parseAllSessions: sorting and since-filter All 69 tests pass (26 new + 43 existing).
TerminalGravity
force-pushed
the
test/session-parser-coverage
branch
from
March 7, 2026 05:15
0760885 to
ced3612
Compare
Collaborator
Author
|
Closing — superseded by a newer version of this test PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive test coverage for
src/lib/session-parser.ts(325 lines, previously zero tests).26 tests covering:
findSessionFiles: top-level and subagent .jsonl discoveryparseSession: prompts, array content blocks, correction detection (all 7 patterns), assistant text + metadata, tool_use → tool_call events, Task/dispatch_agent → sub_agent_spawn, tool_result errors (is_error + stderr), compaction events (subtype + text match), summary record extraction (branch, sessionId), malformed JSON graceful handling, empty content skipping, content_preview truncation, unique ID generationparseSessionAsync: parity with sync parserparseAllSessions: multi-file sorting, since-filterAll 69 tests pass (26 new + 43 existing).