Add unit tests for use-streams-view-preference, use-undo-cancel, use-… - #878
Merged
Austinaminu2 merged 1 commit intoSep 27, 2026
Merged
Austinaminu2 merged 1 commit into
Austinaminu2 merged 1 commit into
Conversation
…page-visibility, and use-online-status hooks Issue FlowwStar#741: Added tests for useStreamsViewPreference covering the default ("list") value, reading a previously-stored preference back, ignoring an invalid stored value, and that setView both updates state and persists to localStorage — following the same pattern as the existing useShowUsd tests. Issue FlowwStar#742: Added tests for useUndoableCancel / useIsStreamCancelling covering: scheduling a cancel marks the stream as cancelling immediately; letting the countdown run out submits the cancel transaction and clears the cancelling state (cancel-on-timeout); calling abortCancel before the countdown finishes clears it without ever submitting the transaction (undo-before-timeout); abortCancel returns false when nothing is pending; useIsStreamCancelling reacts to a cancellation scheduled by a different hook instance via the shared pub/sub; and unmounting the scheduling component aborts any in-flight countdown as a safe default. Mocked useContract and sonner's toast, matching this repo's existing mocking conventions for hooks that call out to the contract layer. Issue FlowwStar#740: The issue described usePageVisibility as returning state that updates on visibilitychange events. The real hook is callback-based — it takes onVisible/onHidden callbacks and calls whichever applies when the event fires; it returns nothing. Added tests for the real shape instead: onHidden fires when the document becomes hidden, onVisible fires when it becomes visible again, a call with only one callback provided doesn't throw, the latest callback identity is used even without re-registering the listener (via the hook's internal refs), and the listener is removed on unmount. Issue FlowwStar#739: Added tests for useOnlineStatus covering the default (online) value, syncing to navigator.onLine on mount, becoming false on the offline event, becoming true again on the online event, and not throwing after unmount. Verification: ran the full existing test suite before adding these files. The pre-existing failures (dashboard, hero, settings, live-stream-preview, sections, wallet-lobstr, empty-state, dropdown-menu — 26 failing tests across 8 files) match the same known-unrelated baseline already seen on another fork of this same project, so they predate and are unrelated to this change. All 20 new tests across the 4 files pass. Closes FlowwStar#739 Closes FlowwStar#740 Closes FlowwStar#741 Closes FlowwStar#742
|
@MamaLove360 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
…page-visibility, and use-online-status hooks
Issue #741: Added tests for useStreamsViewPreference covering the default ("list") value, reading a previously-stored preference back, ignoring an invalid stored value, and that setView both updates state and persists to localStorage — following the same pattern as the existing useShowUsd tests.
Issue #742: Added tests for useUndoableCancel / useIsStreamCancelling covering: scheduling a cancel marks the stream as cancelling immediately; letting the countdown run out submits the cancel transaction and clears the cancelling state (cancel-on-timeout); calling abortCancel before the countdown finishes clears it without ever submitting the transaction (undo-before-timeout); abortCancel returns false when nothing is pending; useIsStreamCancelling reacts to a cancellation scheduled by a different hook instance via the shared pub/sub; and unmounting the scheduling component aborts any in-flight countdown as a safe default. Mocked useContract and sonner's toast, matching this repo's existing mocking conventions for hooks that call out to the contract layer.
Issue #740: The issue described usePageVisibility as returning state that updates on visibilitychange events. The real hook is callback-based — it takes onVisible/onHidden callbacks and calls whichever applies when the event fires; it returns nothing. Added tests for the real shape instead: onHidden fires when the document becomes hidden, onVisible fires when it becomes visible again, a call with only one callback provided doesn't throw, the latest callback identity is used even without re-registering the listener (via the hook's internal refs), and the listener is removed on unmount.
Issue #739: Added tests for useOnlineStatus covering the default (online) value, syncing to navigator.onLine on mount, becoming false on the offline event, becoming true again on the online event, and not throwing after unmount.
Verification: ran the full existing test suite before adding these files. The pre-existing failures (dashboard, hero, settings, live-stream-preview, sections, wallet-lobstr, empty-state, dropdown-menu — 26 failing tests across 8 files) match the same known-unrelated baseline already seen on another fork of this same project, so they predate and are unrelated to this change. All 20 new tests across the 4 files pass.
Closes #739
Closes #740
Closes #741
Closes #742