mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
bacc6a29a7
All places offers the pairs that look like one place: both sides side by side with what differs marked, "keep this one" to group them as one place of the user's own (undo right after), and "not the same place" to set a pair aside for good. Desktop dialog and phone sheet share usePlaceDuplicates; every locale has the new strings. What the last dev run flagged on the client: - Tailwind's Prettier plugin had trimmed the leading space of conditional class names (col-filter-btn, col-lrow sel, col-split map-full, col-detail docked), so the filter row and the open row lost their styling; those classes are now joined so the formatter cannot glue them. - The dock position lives in one helper for the lists and All places, which moves the measured-position markers there instead of adding new ones. - usePlacesLibrary is split into filters, pages, detail and cover hooks that derive their loading state instead of setting it inside effects; the big sheets and views are cut into parts under the complexity limit, dynamic icons go through createElement, originName moves out of a component file. - formatRange is guarded like in the packing export, the cover lookup skips places without a position. - Tests follow the rename to Places, the category icon, the default list icon and the new trip collections store; react-hooks/refs is lowered to the count the run measured. - The rating on a place is a round badge again, in the list and on the map.
95 lines
5.0 KiB
TypeScript
95 lines
5.0 KiB
TypeScript
import type { StoreApi } from 'zustand';
|
|
import { useDayPreviewStore } from '../../src/mobile/dayPreviewStore';
|
|
import { useSharedImportStore } from '../../src/native/sharedFiles';
|
|
import { useAddonStore } from '../../src/store/addonStore';
|
|
import { useAssistantHintsStore } from '../../src/store/assistantHintsStore';
|
|
import { useAuthStore } from '../../src/store/authStore';
|
|
import { useFlightLiveStore } from '../../src/store/flightLiveStore';
|
|
import { useInAppNotificationStore } from '../../src/store/inAppNotificationStore';
|
|
import { useMailIngestStore } from '../../src/store/mailIngestStore';
|
|
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 { useTripAddonsStore } from '../../src/store/tripAddonsStore';
|
|
import { useTripCollectionsStore } from '../../src/store/tripCollectionsStore';
|
|
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,
|
|
useDayPreviewStore,
|
|
useSharedImportStore,
|
|
useTripStore,
|
|
useSettingsStore,
|
|
useVacayStore,
|
|
useAddonStore,
|
|
useInAppNotificationStore,
|
|
usePermissionsStore,
|
|
useTourMapVisibilityStore,
|
|
useTourMapViewportStore,
|
|
usePaddleObstacleStore,
|
|
useTrackMarkToolStore,
|
|
useAssistantHintsStore,
|
|
// Live flight states are per test: a leg seeded by one test must not show up in the next.
|
|
useFlightLiveStore,
|
|
// The mail inbox and its pending count, which the menus of every shell read.
|
|
useMailIngestStore,
|
|
// The trip addons per trip, which every trip view reads: a list one test loaded must not decide the next one's tabs.
|
|
useTripAddonsStore,
|
|
// The lists linked to each trip: one test's links must not show on the next test's trip.
|
|
useTripCollectionsStore,
|
|
};
|
|
|
|
/** 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',
|
|
useAssistantStore:
|
|
'the assistant chats, window and live map links; the tests that read it put back its first state themselves',
|
|
useBackgroundTasksStore: NOT_YET,
|
|
useCollectionStore: NOT_YET,
|
|
useCollectionTourStore:
|
|
'its own tests put it back with clear(); it holds one open collection and nothing else reads it',
|
|
useDocSyncOfferStore: NOT_YET,
|
|
useHelpStore: NOT_YET,
|
|
useOpenTourStore: 'the saved tour open in the Tours tab, set by its stage; the tests that read it set it themselves',
|
|
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',
|
|
};
|