Skip to content

Add unit tests for the session SSE frame parser #402

Description

@usmanimamu17-create

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

  • Each parser case above has an assertion.
  • npm test passes with the new suite.

Getting started

npm test

Pattern-match tests/hermes.test.ts for structure; mock fetch with a stream if testing connectSessionSse.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardStellar Waveissue-trackingThird CampaignCampaign: Third Campaignarea/sessionImported campaign issue labelarea/testsImported campaign issue label

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions