Repository navigation
test: cover SSE reconnect cleanup, settings fallback, streaming pause, and malformed events (#1781, #1782, #1783, #1784) - #1811
Open
mskdylan wants to merge 1 commit into
Conversation
…, and malformed events Add deterministic regression tests for four hook-level issues: - LabsCrypt#1783: unmounting useStreamEvents during a pending reconnect clears the backoff timer, closes the EventSource, and never reconnects; repeated error bursts keep exactly one timer and honor the attempt cap. - LabsCrypt#1784: invalid decimal settings (missing, empty, negative, out-of-range, malformed, fractional) fall back per the parseInt contract without throwing, and valid values still apply after invalid ones. - LabsCrypt#1781: useStreamingAmount freezes on pause, resumes without duplicate frame loops, excludes paused time across repeated cycles, resyncs after clock drift, and cleans up when unmounted while streaming or paused. - LabsCrypt#1782: malformed JSON, unknown event types, and partial frames are ignored without corrupting subsequent valid event processing. All tests use fake timers and controlled clocks; no production code changed. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This branch has not been deployed
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.
Summary
Test-only PR that adds deterministic regression tests for four hook-level issues in one coordinated change. No production code was modified — every test asserts the hooks' existing documented behavior and error contracts. All tests use Vitest fake timers and controlled clocks (no real sleeps).
#1783 — SSE reconnect timer cleanup (
frontend/src/__tests__/useStreamEvents.test.tsx)vi.getTimerCount()→ 0) and no newEventSourceis ever created, even after advancing the clock far past the delay.reconnecting/connected/errorstate is correct while a retry is pending and cleans up on unmount.#1784 — Invalid decimal settings fallback (
frontend/src/hooks/useSettings.test.ts)flowfi-decimal-placesfalls back to the documented default of 7.4.9,2.7) are truncated to their integer prefix perparseIntsemantics; leading zeros and surrounding whitespace are tolerated.12,100) stay parseable but formatting never exceeds the 7 fractional digits that exist on-chain.-2) never throw; malformed values (abc,seven,NaN,—) yieldNaNand degrade to integer-only formatting without throwing.USD/full.#1781 — Streaming amount pause transitions (
frontend/src/hooks/useStreamingAmount.test.tsx)totalPausedDurationand keep timer counts consistent.cancelAnimationFrame, 0 timers) and no stale ticker mutates state; unmount while paused leaves nothing scheduled.#1782 — Malformed SSE event recovery (
frontend/src/__tests__/useStreamEvents.test.tsx)Tests executed (actual results)
frontend/)npx vitest run src/__tests__/useStreamEvents.test.tsx src/hooks/useSettings.test.ts src/hooks/useStreamingAmount.test.tsx src/__tests__/useStreamingAmount.test.tsxnpm run test(full frontend suite, re-run on this branch rebased onmain)npm run test:coveragenpm run lintnpx tsc --noEmitnpm run build(Next.js)No existing tests were weakened, skipped, or deleted; no flaky real-time waits were introduced.
Closes #1781
Closes #1782
Closes #1783
Closes #1784