Skip to content

test: add SSE stream test coverage for /api/check/stream (#193)#271

Open
schmug wants to merge 1 commit into
mainfrom
claude/issue-193-sse-stream-tests
Open

test: add SSE stream test coverage for /api/check/stream (#193)#271
schmug wants to merge 1 commit into
mainfrom
claude/issue-193-sse-stream-tests

Conversation

@schmug
Copy link
Copy Markdown
Owner

@schmug schmug commented May 14, 2026

Summary

  • Adds test/api-check-stream.test.ts (17 tests) and test/helpers/drain-sse.ts covering the SSE framing contract for GET /api/check/stream
  • Fixes a latent production bug: stream.writeSSE({ event: "done", ... }) was not awaited in the live-scan path, causing the terminal event to be dropped before stream.close() ran — the tests surfaced this and the fix is a one-line await addition in src/index.ts
  • The drainSSE(response) helper is reusable for future SSE tests

Test plan

  • All 17 new tests pass: npx vitest run test/api-check-stream.test.ts
  • Full suite: 877 tests pass, 1 pre-existing network-dependent integration failure unchanged
  • npm run typecheck — clean
  • npm run lint — clean
  • Happy path: 200 + text/event-stream, 7 protocol events (one per protocol ID), one done event last, no duplicates, all data is valid JSON
  • Error path: missing/invalid domain → 400 JSON (stream never opens), XSS payload not reflected
  • DKIM custom selectors: passing selectors=custom1,custom2 increases the "+N more not found" count by exactly 2
  • Stream ordering: all protocol events precede the done event; two sequential scans both complete

Closes #193

https://claude.ai/code/session_01PWjVsDVDNFjWvdMmwVFGdT

Adds test/api-check-stream.test.ts (17 tests) and test/helpers/drain-sse.ts
covering the happy path, error path, DKIM custom selectors, and stream
ordering. Also fixes a latent bug: the done event writeSSE was not awaited
in the live-scan path, causing it to be lost before stream.close() ran.

https://claude.ai/code/session_01PWjVsDVDNFjWvdMmwVFGdT
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
dmarcheck a8cf469 May 14 2026, 01:24 PM

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.

Test /api/check/stream SSE event stream (no coverage today)

2 participants