test: add hydration-level coverage for onRehydrateStorage (#129) - #143
Merged
cybermax4200 merged 2 commits intoAug 30, 2026
Merged
Conversation
Contributor
Author
|
@cybermax4200 ci fixed, please merge |
cybermax4200
approved these changes
Aug 30, 2026
4 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.
Summary
Investigated #129 and couldn't reproduce the described bug. Zustand v4's
persistmiddleware documentsonRehydrateStorageas:The outer function runs once pre-hydration; its return value is invoked
again post-hydration with the hydrated state. That's exactly the shape
currently implemented in
prefsStore.ts, and it does run — it's not deadcode.
Reference: https://zustand.docs.pmnd.rs/reference/middlewares/persist
What this PR does
Adds hydration-level test coverage that exercises the actual registered
onRehydrateStoragecallback (viapersist.getOptions()), rather thanre-simulating it. No production code changes.
Covers the acceptance criteria from #129:
notificationPrefsmissingPROOF_TIMEOUTresults inPROOF_TIMEOUT: trueafter rehydration.notificationPrefswithREWARD_CONFIRMED: falsepreservesthat value (not overwritten by defaults).
postRehydrationCallback(undefined, error)) is a no-op.All four pass against the current, unmodified
prefsStore.ts.Why not the originally-proposed fix
The issue proposes collapsing
onRehydrateStorageto a single-argument(state) => {...}form. That would actually break rehydration: Zustandwould call it once with the pre-hydration state and never invoke it
again after the persisted data loads, so
mergeNotificationDefaultswouldstop running entirely — a regression, not a fix.
Out of scope
quietHoursorscheduledNotificationIdspersistenceCloses
[Bug] prefsStore.onRehydrateStorage callback is dead code — new notification types added to the codebase are never enabled by default for existing users#129