-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Overview
Add comprehensive unit tests for src/containers/View.tsx to improve test coverage and validate key behaviors, including the recent fix for clearing atom selection when simulation changes.
Test Plan
1. Selection Management
1.1 Auto-clear selection on simulation change (P0 - validates recent fix)
- When
simulationvalue changes,visualizer.clearSelection()should be called -
selectedAtomsstate should be reset to empty Set
1.2 Escape key clears selection (P1)
- Pressing Escape when atoms are selected should clear selection
- Pressing Escape when no atoms are selected should do nothing
1.3 Particle click handling (P3)
- Plain click on atom should select only that atom
- Plain click on already-selected single atom should deselect it
- Shift+click should toggle atom in/out of multi-selection
- Plain click when multiple atoms selected should clear and select only clicked atom
2. Responsive Behavior (P3)
2.1 Mobile/Desktop initial state
- On desktop (width > 900), overlay should start expanded
- On mobile (width <= 900), overlay should start collapsed
2.2 Window resize handling
- Resizing from desktop to mobile should collapse overlay
- Resizing from mobile to desktop should expand overlay
3. LocalStorage Persistence (P2)
3.1 Drawer visibility persistence
-
showAnalyzestate should be saved to localStorage when changed -
showAnalyzestate should be loaded from localStorage on mount - localStorage should NOT be written to in embedded mode
4. Embedded Mode
4.1 Embed config overrides (P2)
-
embedConfig.showSimulationSummaryshould override localStorage preference - ResponsiveSimulationSummary should not render when embed config disables it
4.2 No simulation modal (P1)
- Modal should NOT show in embedded mode even when simulation is null
5. No Simulation Modal (P2)
- Modal should show when
simulationis null and not in embedded mode - Modal should be dismissible via OK button
- Modal should be dismissible via onCancel
6. Visualizer Lifecycle (P2)
6.1 Visibility handling
-
visualizer.idleshould betruewhenvisibleprop isfalse -
visualizer.idleshould befalsewhenvisibleprop istrue
Implementation Notes
Mocking Strategy
The tests will require these mocks:
- Store hooks (
useStoreState,useStoreActions) - return configurable values - Visualizer class from
omovi- mockclearSelection,setSelected,idle, etc. - Browser APIs -
localStorage,window.innerWidth, resize events - Child components - mock
ResponsiveSimulationSummary,SelectedAtomsInfo,ColorLegend, etc. - useEmbeddedMode hook - return configurable embed config
Test File Location
src/containers/View.test.tsx
Priority Legend
| Priority | Description |
|---|---|
| P0 | Critical - validates bug fix |
| P1 | High - core UX behavior |
| P2 | Medium - important functionality |
| P3 | Low - nice to have, complex to test |
References
- Existing test patterns:
src/components/ResponsiveSimulationSummary.test.tsx,src/components/Figure.test.tsx - Testing patterns doc:
docs/testing_patterns.md - Recent fix commit:
054bad2(Fix useEffect dependency: add simulation to clear selection when simulation changes)
Metadata
Metadata
Assignees
Labels
No labels