Cover use-release-stream: applyStreamEvent reducer and stream wiring - #868
Merged
Merged
Conversation
The release SSE hook had zero direct coverage despite owning the client-side job-state reducer and the post-restart health-poll flow. Export applyStreamEvent (same convention as use-sse's appliers) and pin: log append/rewind/replace semantics, per-jobType phase casts with error preservation, progress set/clear, assisted-event gating, pre-snapshot no-ops, info-progress routing, reconnect client-id stability, the onerror -> health-poll -> done -> reloadApp sequence under fake timers, and unmount cleanup of both the stream and the poll interval. 9/9 mutant battery killed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 freeto 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.
Summary
The release SSE hook (
apps/web/src/hooks/use-release-stream.ts) had zero direct coverage despite owning the client-side release-job reducer and the post-restart health-poll flow. This PR exports the previously module-privateapplyStreamEvent(matching the existinguse-sse.tsconvention of exporting pure appliers for tests) and addsuse-release-stream.test.tsxwith 23 tests.What is pinned
Reducer (
applyStreamEvent)logappend is immutable and ordered;log.rewinddrops exactlycountentries (server clamps to ≥1, so the count-0 edge is unreachable and intentionally not pinned);log.replaceswaps the last line and pushes onto an empty logphaseapplies across all three jobType variants, preserves the priorerrorwhen the event carries none, and overwrites it when it doesprogressset/clear,runUrl,tagassistedevents are ignored unlessjobType === "update-assisted"null) are no-opsHook wiring (stubbed global
EventSource+ fake timers)connectStreamcloses the prior stream and reuses the idsnapshotseeds the job;info-progressroutes toinfoProgresswithout touching the jobonerrorduring an update deploy/restart flips torestarting, polls/api/v1/release/statusevery 2s, completes todonewhen the expected tag appears, and schedulesreloadApp1.5s later; keeps polling while the old tag is reportedrestarting) never trigger the health poll9/9 mutant battery killed (append drop, rewind hardcode, replace-push, empty-push drop, error-fallback drop, assisted-guard drop, null-guard fake, onerror jobType-guard relax, poll tag-match invert).
Validation
pnpm run check,pnpm run finalize:webclean🤖 Generated with Claude Code