Skip to content

Add unit tests for use-streams-view-preference, use-undo-cancel, use-… - #878

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
MamaLove360:feat/739-740-741-742-hook-unit-tests
Sep 27, 2026
Merged

Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
MamaLove360:feat/739-740-741-742-hook-unit-tests

Conversation

@MamaLove360

Copy link
Copy Markdown
Contributor

…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

…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
@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Austinaminu2
Austinaminu2 merged commit 4146223 into FlowwStar:main Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants