/* eslint-disable @typescript-eslint/no-explicit-any */ /** * Reset helpers. Call `resetAllMocks()` in `beforeEach` so no Zustand store, * storage key, procedure fixture or navigation spy leaks between cases. */ import { resetTrpcMocks, seedDefaultProcedures } from '../mocks/trpc-client' import { resetJsonMocks } from '../mocks/fetch-json' import { __reset as resetSecureStore } from '../mocks/secure-store-mock' import { __reset as resetLocation } from '../mocks/expo-location-mock' import { __reset as resetNotifications } from '../mocks/expo-notifications-mock' import { __resetRouterMock } from '../mocks/expo-router-mock' import { __resetAuthState } from '../mocks/auth-context' import { useAppStore } from '@/src/store/appStore' import { useAddressStore } from '@/src/store/addressStore' import { useCartStore } from '@/src/store/cartStore' import { useFlashCartStore } from '@/src/store/flashCartStore' import { useNavigationStore } from '@/src/store/navigationStore' import { useQuickDeliveryStore } from '@/src/store/quickDeliveryStore' import { useStoreHeaderStore } from '@/src/store/storeHeaderStore' import { useCheckoutStore } from '@/src/store/checkoutStore' import { useCentralProductStore } from '@/src/store/centralProductStore' import { useCentralSlotStore } from '@/src/store/centralSlotStore' import { useRegionStore } from '@/src/store/regionStore' import { useLocationStore } from '@/src/store/locationStore' import { useSlotStore } from '@/components/stores/slotStore' import { useFlashNavigationStore } from '@/components/stores/flashNavigationStore' export function resetStores() { useAppStore.setState({ hideTabsNav: {} }) useAddressStore.setState({ selectedAddressId: null }) useCartStore.setState({ addedToCartProduct: null }) useFlashCartStore.setState({ addedFlashProduct: null }) useNavigationStore.setState({ isNavigatedFromHome: false, selectedStoreId: null }) useQuickDeliveryStore.setState({ isDrawerHidden: false, selectedSlotId: null }) useStoreHeaderStore.setState({ title: '' }) useCheckoutStore.setState({ userNotes: '' }) useCentralProductStore.setState({ products: [], productsById: {}, refetchProducts: null }) useCentralSlotStore.setState({ slots: [], productSlotsMap: {}, isSlotsLoaded: false, refetchSlots: null, }) useRegionStore.setState({ selectedRegionId: null, selectedRegion: null, selectedBoundId: null, regionGeneration: 0, // Most cases exercise the launch decision with an empty store; they do not // test the SecureStore hydration, so start settled (the persistence tests // flip this back to false). hydrated: true, }) useSlotStore.setState({ slotId: undefined, storeId: undefined }) useFlashNavigationStore.setState({ shouldNavigateToCart: false }) useLocationStore.getState().stop() useLocationStore.setState({ coords: null, status: 'idle', error: null }) } export function resetAllMocks() { jest.clearAllMocks() jest.useRealTimers() resetStores() resetTrpcMocks() resetJsonMocks() resetSecureStore() resetLocation() resetNotifications() __resetRouterMock() __resetAuthState() } export { seedDefaultProcedures }