test(data): add zustand store unit tests and fix annotation-store selector hooks#452
Open
WilliamBerryiii wants to merge 2 commits intomainfrom
Open
test(data): add zustand store unit tests and fix annotation-store selector hooks#452WilliamBerryiii wants to merge 2 commits intomainfrom
WilliamBerryiii wants to merge 2 commits intomainfrom
Conversation
…ector hooks - add selector hook tests for annotation, episode, and edit stores - add edge-case tests for edit-store frame utils and action factories - fix annotation-store hooks to use useShallow preventing infinite re-renders - add stable EMPTY_ANOMALIES constant to avoid reference instability 🧪 - Generated by Copilot
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #452 +/- ##
==========================================
+ Coverage 64.41% 64.80% +0.38%
==========================================
Files 251 251
Lines 15435 15441 +6
Branches 2108 2060 -48
==========================================
+ Hits 9942 10006 +64
+ Misses 5205 5146 -59
- Partials 288 289 +1
🚀 New features to boost your workflow:
|
katriendg
approved these changes
Apr 13, 2026
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.
Comprehensive unit tests for all Zustand stores in the Dataset Analysis Tool frontend, targeting 80%+ coverage for Issue #217. Alongside the new tests, a performance bug was discovered and fixed in annotation-store.ts where selector hooks created new object references on every store update, causing unnecessary component re-renders.
Description
Closes #217
Bug Fix
The five selector hooks in annotation-store.ts (
useAnnotationDirtyState,useTaskCompletenessState,useTrajectoryQualityState,useDataQualityState,useAnomalyState) returned new object references on each store update. Wrapped all five withuseShallowfromzustand/react/shallowand extracted anEMPTY_ANOMALIESconstant to stabilize return values and prevent unnecessary re-renders.Test Coverage
Added and expanded tests across seven test files covering the full Zustand store layer:
buildOriginalEditState,buildEditOperations,hasEditContent,computeDirty, andpersistEditStateDraftrenderHookcovering transforms, frame removal/insertion, subtask operations, dirty state, and trajectory adjustmentssetLoadingaction test plus 3 selector hook tests for episode index, navigation, and playbackinitDefaultsAll tests follow existing codebase conventions:
renderHook()for hook isolation,vi.mock()for dependencies,beforeEachcleanup, andact()wrapping for state mutations.Type of Change
Component(s) Affected
data-management/viewer/frontend/src/stores/— Zustand stores and testsTesting Performed
Documentation Impact
Bug Fix Checklist
useShallowwrapping produces stable referencesChecklist
🤖 - Generated by Copilot