test: add watchlist toggle unit tests asserting localStorage persiste… - #893
Merged
Chucks1093 merged 1 commit intoSep 3, 2026
Conversation
…nce (accesslayerorg#861) Implement useWatchlist hook and WatchlistToggle component with comprehensive unit tests covering all acceptance criteria: - Bookmarking adds key to localStorage and shows filled icon - Unbookmarking removes key from localStorage and shows outline icon - Filled icon shown on mount when key is already in localStorage - Watchlist count updates after each toggle - localStorage cleared on wallet disconnect via clearWatchlist() Co-Authored-By: Samuel Ojetunde <samjay8@users.noreply.github.com>
|
@sojetunde8 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! 🚀 |
5 tasks
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.
test: add watchlist toggle unit tests asserting localStorage persistence (#861)
Closes #861
Summary
Adds the
useWatchlisthook andWatchlistTogglecomponent along with comprehensive unit tests that verify the watchlist toggle reads from and writes to localStorage correctly, and that bookmark state persists across renders.Changes
New files
src/hooks/useWatchlist.ts— Custom hook that manages a watchlist of creator-key IDs persisted inlocalStorageunderaccesslayer.watchlist. ExposesisBookmarked(),toggleWatch(),watchlistCount, andclearWatchlist().src/components/common/WatchlistToggle.tsx— Bookmark icon button component that toggles a creator key in/out of the watchlist. ShowsBookmarkCheck(filled) when bookmarked,Bookmark(outline) when not.src/hooks/__tests__/useWatchlist.test.ts— 9 unit tests for the hook covering all acceptance criteria.src/components/common/__tests__/WatchlistToggle.test.tsx— 6 component tests verifying icon state reflects localStorage across renders.Acceptance Criteria
toggleWatch()writes to localStorage andisBookmarked()returnstrue.watchlistCountreflects additions and removals after each toggle.clearWatchlist()empties both the React state and the localStorage entry.Verification
pnpm tsc -b --noEmit— passes (no type errors)pnpm eslint— passes (no lint errors)Scope
This PR is strictly scoped to issue #861 — unit tests for the watchlist toggle asserting bookmark state persists in localStorage across renders. No work outside the issue scope is included.