Summary
processFrame in src/lib/session-sse.ts (single-line data: extraction, event: dispatch, JSON parsing with a swallow-on-error catch) has no unit tests. The parser's behavior — a multi-line data: frame losing the remainder, a malformed JSON payload being silently dropped, an unknown event type being ignored — is entirely unpinned, and the reconnect/401 behavior (companion issue) will need the parser contract locked down before it can be changed safely.
Proposal
- Export
processFrame (or test through connectSessionSse with a mocked fetch that feeds frames through a ReadableStream).
- Cover: single-line frame, multi-line
data: (assert current truncation behavior, to be fixed in the companion issue), malformed JSON, unknown event, missing event: line, and session_revoked with each documented reason.
- Cover the reconnect path: non-200 responses schedule a retry; 401/403 (after the companion fix) stop.
Acceptance criteria
Getting started
Pattern-match tests/hermes.test.ts for structure; mock fetch with a stream if testing connectSessionSse.
Summary
processFrameinsrc/lib/session-sse.ts(single-linedata:extraction,event:dispatch, JSON parsing with a swallow-on-error catch) has no unit tests. The parser's behavior — a multi-linedata:frame losing the remainder, a malformed JSON payload being silently dropped, an unknown event type being ignored — is entirely unpinned, and the reconnect/401 behavior (companion issue) will need the parser contract locked down before it can be changed safely.Proposal
processFrame(or test throughconnectSessionSsewith a mockedfetchthat feeds frames through aReadableStream).data:(assert current truncation behavior, to be fixed in the companion issue), malformed JSON, unknown event, missingevent:line, andsession_revokedwith each documented reason.Acceptance criteria
npm testpasses with the new suite.Getting started
npm testPattern-match
tests/hermes.test.tsfor structure; mockfetchwith a stream if testingconnectSessionSse.