mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 14:36:31 +00:00
ae79ab8dad
The compare switch in a tour's detail showed whenever the detail sat beside the plan map, but the map draws no comparison in road trip mode or with the trip overview open. Pressing it there turned the switch on while nothing appeared on the map. The plan map now tells the compare store whether it can draw a comparison. The detail offers the switch only then, and turning to the road trip or the overview, or leaving the map, ends a running comparison.
72 lines
3.6 KiB
TypeScript
72 lines
3.6 KiB
TypeScript
import type { StoreApi } from 'zustand';
|
|
import { useAddonStore } from '../../src/store/addonStore';
|
|
import { useAuthStore } from '../../src/store/authStore';
|
|
import { useInAppNotificationStore } from '../../src/store/inAppNotificationStore';
|
|
import { usePaddleObstacleStore } from '../../src/store/paddleObstacleStore';
|
|
import { usePermissionsStore } from '../../src/store/permissionsStore';
|
|
import { useSettingsStore } from '../../src/store/settingsStore';
|
|
import { useTourMapViewportStore } from '../../src/store/tourMapViewportStore';
|
|
import { useTourMapVisibilityStore } from '../../src/store/tourMapVisibilityStore';
|
|
import { useTrackMarkToolStore } from '../../src/store/trackMarkToolStore';
|
|
import { useTripStore } from '../../src/store/tripStore';
|
|
import { useVacayStore } from '../../src/store/vacayStore';
|
|
|
|
/**
|
|
* Every Zustand store in src/, and what resetAllStores does with it.
|
|
*
|
|
* RESET_STORES are put back to the state they had when this module was first
|
|
* imported, before any test touched them. UNRESET_STORES are left alone, each
|
|
* with the reason; their tests reset them on their own. The registry test
|
|
* (tests/unit/helpers/storeRegistry.test.ts) finds every `export const
|
|
* use…Store = create…` under src/ and fails on one that is in neither list,
|
|
* so a new store has to be placed here instead of being forgotten by the
|
|
* reset and leaking state from one test into the next.
|
|
*
|
|
* The stores are imported by name rather than through a glob: an eager glob
|
|
* would load every store module into each of the hundreds of test files that
|
|
* reset, including the ones that mock a store module or import it in a
|
|
* particular order (journeyStore), and a store moved from UNRESET to RESET
|
|
* changes what those files start from. Each such move is its own change.
|
|
*/
|
|
type ResettableStore = Pick<StoreApi<object>, 'getState' | 'setState'>;
|
|
|
|
export const RESET_STORES: Record<string, ResettableStore> = {
|
|
useAuthStore,
|
|
useTripStore,
|
|
useSettingsStore,
|
|
useVacayStore,
|
|
useAddonStore,
|
|
useInAppNotificationStore,
|
|
usePermissionsStore,
|
|
useTourMapVisibilityStore,
|
|
useTourMapViewportStore,
|
|
usePaddleObstacleStore,
|
|
useTrackMarkToolStore,
|
|
};
|
|
|
|
/** Not reset so far; moving one into RESET_STORES changes what every file that resets starts from. */
|
|
const NOT_YET = 'never reset by resetAllStores; its own tests set the state they need';
|
|
|
|
export const UNRESET_STORES: Record<string, string> = {
|
|
useJourneyStore: 'reset in the journey tests themselves; importing it here pulls in a circular import',
|
|
useBackgroundTasksStore: NOT_YET,
|
|
useCollectionStore: NOT_YET,
|
|
useDocSyncOfferStore: NOT_YET,
|
|
useHelpStore: NOT_YET,
|
|
usePluginStore: NOT_YET,
|
|
useRoadtripPreferencesStore: NOT_YET,
|
|
useSaveToCollectionStore: NOT_YET,
|
|
useServerVersionStore: NOT_YET,
|
|
useStudioStore: NOT_YET,
|
|
useSystemNoticeStore: NOT_YET,
|
|
useTourActivityCompareStore:
|
|
'the actual track compared on the map and whether the map can draw it; the tests that read it reset both in their own beforeEach',
|
|
useTourFerrataCrossingStore: 'set by the tour map stage; the tests that read it reset it in their own beforeEach',
|
|
useTourPlaceToolStore: 'reset in the tour tests themselves to initialTourPlaceToolState()',
|
|
useTourPoiStore: 'the places found along a tour; the tests that read it clear it in their own beforeEach',
|
|
useTourRouteHighlightStore:
|
|
'the stretches a bike card points at; the tests that read it clear it in their own beforeEach',
|
|
useTourVisitStore: 'the visits of city walks per day; the tests that read it reset it in their own beforeEach',
|
|
useTripJournalLinkStore: 'the journal link per trip; the tests that read it reset it in their own beforeEach',
|
|
};
|