Skip to content

Commit

Permalink
fix: implement new created actions
Browse files Browse the repository at this point in the history
  • Loading branch information
xlecunff-pass committed Jan 7, 2025
1 parent 8d346f1 commit 5d6d7af
Show file tree
Hide file tree
Showing 39 changed files with 80 additions and 230 deletions.
5 changes: 3 additions & 2 deletions scripts/noUncheckedIndexedAccess_snapshot.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
$ grep --recursive --line-number ./src --regexp '// @ts-expect-error: because of noUncheckedIndexedAccess' | awk -F: '{print $1":"$2}' | sort
./src/cheatcodes/hooks/useSomeOfferId.ts:24
./src/features/bookOffer/components/BookHourChoice.tsx:122
./src/features/bookOffer/components/Calendar/useMarkedDates.native.test.ts:35
Expand Down Expand Up @@ -55,8 +56,8 @@
./src/features/search/components/sections/Accessibility/Accessibility.tsx:33
./src/features/search/pages/SuggestedPlacesOrVenues/SuggestedVenues.native.test.tsx:43
./src/features/venue/components/OpeningHoursStatus/OpeningHoursStatus.native.test.tsx:68
./src/features/venueMap/store/selectedVenueStore.native.test.ts:20
./src/features/venueMap/store/selectedVenueStore.native.test.ts:31
./src/features/venueMap/store/selectedVenueStore.native.test.ts:16
./src/features/venueMap/store/selectedVenueStore.native.test.ts:26
./src/libs/algolia/fetchAlgolia/buildAlgoliaParameters/getCategoriesFacetFilters.ts:26
./src/libs/hooks/useShowReview.native.test.tsx:114
./src/libs/hooks/useTimer.native.test.ts:34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ jest.mock('libs/location', () => ({
}))

const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
}),
}))

const mockShowModal = jest.fn()
const useModalAPISpy = jest.spyOn(useModalAPI, 'useModal')
Expand Down
4 changes: 2 additions & 2 deletions src/features/home/components/modules/TrendsModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Trend } from 'features/home/components/Trend'
import { TrendBlock, TrendNavigationProps } from 'features/home/types'
import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal'
import { useShouldDisplayVenueMap } from 'features/venueMap/hook/useShouldDisplayVenueMap'
import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { analytics } from 'libs/analytics'
import { ContentTypes } from 'libs/contentful/types'
import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
Expand Down Expand Up @@ -34,7 +34,7 @@ export const TrendsModule = ({ index, moduleId, homeEntryId, items }: Trends) =>
visible: venueMapLocationModalVisible,
hideModal: hideVenueMapLocationModal,
} = useModal()
const { removeSelectedVenue } = useSelectedVenueActions()
const { removeSelectedVenue } = selectedVenueActions

const isSmallScreen = width < 375
const shouldOpenMapDirectly = selectedLocationMode !== LocationMode.EVERYWHERE && !isWeb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ jest.mock('libs/location', () => ({
useLocation: () => mockUseLocation(),
}))
const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
}),
}))

describe('<VenueListModule />', () => {
it('should display venue list', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/features/home/components/modules/VenueListModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components/native'

import { VenueListModuleItem } from 'features/home/components/modules/VenueListModuleItem'
import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal'
import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { VenueHit } from 'libs/algolia/types'
import { analytics } from 'libs/analytics'
import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
Expand All @@ -25,7 +25,7 @@ type HeaderProps = {

const ListHeaderComponent: FunctionComponent<HeaderProps> = ({ onPress }) => {
const focusProps = useHandleFocus()
const { removeSelectedVenue } = useSelectedVenueActions()
const { removeSelectedVenue } = selectedVenueActions

const handleOnBeforeNavigate = () => {
removeSelectedVenue()
Expand Down
2 changes: 1 addition & 1 deletion src/features/identityCheck/api/useCreditActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const defaultState: CreditState = {
activationDate: undefined,
}

export const useCreditStore = createStore('credit', defaultState, { persist: true })
const useCreditStore = createStore('credit', defaultState, { persist: true })

export const creditActions = createActions(useCreditStore, (set) => ({
setActivationDate: (date: Date) => set({ activationDate: date }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { navigate } from '__mocks__/@react-navigation/native'
import { SearchLocationModal } from 'features/location/components/SearchLocationModal'
import { VenueMapLocationModal } from 'features/location/components/VenueMapLocationModal'
import { DEFAULT_RADIUS } from 'features/search/constants'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { analytics } from 'libs/analytics'
import { checkGeolocPermission, GeolocPermissionState, LocationWrapper } from 'libs/location'
import { getGeolocPosition } from 'libs/location/geolocation/getGeolocPosition/getGeolocPosition'
Expand All @@ -14,6 +15,7 @@ import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { MODAL_TO_HIDE_TIME, MODAL_TO_SHOW_TIME } from 'tests/constants'
import { act, fireEvent, render, screen, userEvent, waitFor } from 'tests/utils'
// import * as selectedVenueModule from

jest.useFakeTimers()

Expand Down Expand Up @@ -62,18 +64,9 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
}
})

const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
}),
}))
const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({
setInitialVenues: mockSetInitialVenues,
}),
}))
const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue')

const mockSetInitialVenues = jest.spyOn(selectedVenueActions, 'setSelectedVenue')

const user = userEvent.setup()
jest.useFakeTimers()
Expand Down
8 changes: 4 additions & 4 deletions src/features/location/components/VenueMapLocationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useLocationSubmit } from 'features/location/helpers/useLocationSubmit'
import { usePlaceSelection } from 'features/location/helpers/usePlaceSelection'
import { useRadiusChange } from 'features/location/helpers/useRadiusChange'
import { Referrals, UseNavigationType } from 'features/navigation/RootNavigator/types'
import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { analytics } from 'libs/analytics'
import { LocationMode } from 'libs/location/types'

Expand Down Expand Up @@ -69,8 +69,8 @@ export const VenueMapLocationModal = ({
...locationSubmitProps,
})

const { removeSelectedVenue } = useSelectedVenueActions()
const { setInitialVenues } = useInitialVenuesActions()
const { removeSelectedVenue } = selectedVenueActions
const { setInitialVenues } = initialVenuesActions

useEffect(() => {
setInitialVenues([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { defaultDisabilitiesProperties } from 'features/accessibility/context/Ac
import { useSearchInfiniteQuery } from 'features/search/api/useSearchResults/useSearchResults'
import { Action, initialSearchState } from 'features/search/context/reducer'
import { SearchState } from 'features/search/types'
import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import * as doAlgoliaRedirect from 'libs/algolia/doAlgoliaRedirect'
import { offerAttributesToRetrieve } from 'libs/algolia/fetchAlgolia/buildAlgoliaParameters/offerAttributesToRetrieve'
import * as fetchSearchResults from 'libs/algolia/fetchAlgolia/fetchSearchResults/fetchSearchResults'
Expand Down Expand Up @@ -41,17 +43,9 @@ jest.mock('libs/location/LocationWrapper', () => ({
useLocation: () => mockUseLocation(),
}))

const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }),
useInitialVenues: jest.fn(),
}))
const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
}),
}))
const mockSetInitialVenues = jest.spyOn(initialVenuesActions, 'setInitialVenues')

const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue')

const mockDispatch = jest.fn()
const mockFetchSearchResultsResponse = {
Expand Down
8 changes: 4 additions & 4 deletions src/features/search/api/useSearchResults/useSearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { useSearch } from 'features/search/context/SearchWrapper'
import { useNavigateToSearch } from 'features/search/helpers/useNavigateToSearch/useNavigateToSearch'
import { SearchState } from 'features/search/types'
import { Venue } from 'features/venue/types'
import { useInitialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { useSelectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { useSearchAnalyticsState } from 'libs/algolia/analytics/SearchAnalyticsWrapper'
import { doAlgoliaRedirect } from 'libs/algolia/doAlgoliaRedirect'
import { fetchSearchResults } from 'libs/algolia/fetchAlgolia/fetchSearchResults/fetchSearchResults'
Expand Down Expand Up @@ -43,8 +43,8 @@ export const useSearchInfiniteQuery = (searchState: SearchState, dispatch: Dispa
const transformHits = useTransformOfferHits()
const { setCurrentQueryID } = useSearchAnalyticsState()
const previousPageObjectIds = useRef<string[]>([])
const { setInitialVenues } = useInitialVenuesActions()
const { removeSelectedVenue } = useSelectedVenueActions()
const { setInitialVenues } = initialVenuesActions
const { removeSelectedVenue } = selectedVenueActions
const { replaceToSearch: navigateToThematicSearch } = useNavigateToSearch('ThematicSearch')
const { aroundPrecision } = useRemoteConfigContext()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({
useSearch: () => mockUseSearch(),
}))

const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }),
useInitialVenues: jest.fn(),
}))

jest.mock('@shopify/flash-list', () => {
const ActualFlashList = jest.requireActual('@shopify/flash-list').FlashList
class MockFlashList extends ActualFlashList {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SearchResultsContent } from 'features/search/components/SearchResultsCo
import { initialSearchState } from 'features/search/context/reducer'
import { MAX_RADIUS } from 'features/search/helpers/reducer.helpers'
import { SearchState, UserData } from 'features/search/types'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { useGetAllVenues } from 'features/venueMap/useGetAllVenues'
import { beneficiaryUser, nonBeneficiaryUser } from 'fixtures/user'
import { venuesFixture } from 'libs/algolia/fetchAlgolia/fetchVenues/fixtures/venuesFixture'
Expand Down Expand Up @@ -41,12 +42,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({
jest.mock('features/venueMap/useGetAllVenues')
const mockUseGetAllVenues = useGetAllVenues as jest.Mock

const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }),
useInitialVenues: jest.fn(),
}))

jest.mock('features/venueMap/helpers/zoomOutIfMapEmpty')

jest.mock('features/accessibility/context/AccessibilityFiltersWrapper')
Expand Down Expand Up @@ -174,14 +169,7 @@ jest.mock('libs/location/LocationWrapper', () => ({
useLocation: () => mockUseLocation(),
}))

const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
setSelectedVenue: jest.fn(),
}),
useSelectedVenue: jest.fn(),
}))
const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue')

jest.mock('libs/subcategories/useSubcategories')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ jest.mock('features/location/helpers/useLocationState', () => ({
}),
}))

const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }),
useInitialVenues: jest.fn(),
}))

jest.mock('features/venueMap/useGetAllVenues')
const mockUseGetAllVenues = useGetAllVenues as jest.Mock

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({
}))

const mockSetVenueTypeCode = jest.fn()
jest.mock('features/venueMap/store/venueTypeCodeStore', () => ({
useVenueTypeCodeActions: () => ({ setVenueTypeCode: mockSetVenueTypeCode }),
}))

const user = userEvent.setup()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SearchStackParamList } from 'features/navigation/SearchStackNavigator/t
import { NumberOfResults } from 'features/search/components/NumberOfResults/NumberOfResults'
import { SearchVenueItem } from 'features/search/components/SearchVenueItems/SearchVenueItem'
import { useSearch } from 'features/search/context/SearchWrapper'
import { useVenueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore'
import { venueTypeCodeActions } from 'features/venueMap/store/venueTypeCodeStore'
import { AlgoliaVenue } from 'libs/algolia/types'
import { analytics } from 'libs/analytics'
import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
Expand Down Expand Up @@ -60,7 +60,7 @@ export const VenuePlaylist: React.FC<Props> = ({
shouldDisplaySeparator = true,
}) => {
const { navigate } = useNavigation<UseNavigationType>()
const { setVenueTypeCode } = useVenueTypeCodeActions()
const { setVenueTypeCode } = venueTypeCodeActions
const {
searchState: { searchId },
} = useSearch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ jest.mock('features/search/context/SearchWrapper', () => ({
useSearch: () => mockUseSearch(),
}))

const mockSetVenueTypeCode = jest.fn()
jest.mock('features/venueMap/store/venueTypeCodeStore', () => ({
useVenueTypeCodeActions: () => ({ setVenueTypeCode: mockSetVenueTypeCode }),
}))

jest.mock('react-native-safe-area-context', () => ({
...(jest.requireActual('react-native-safe-area-context') as Record<string, unknown>),
useSafeAreaInsets: () => ({ bottom: 16, right: 16, left: 16, top: 16 }),
Expand Down
9 changes: 0 additions & 9 deletions src/features/search/helpers/useSync/useSync.native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ jest.mock('libs/location/LocationWrapper', () => ({
}))
mockUseLocation.mockReturnValue(everywhereUseLocation)

const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
setSelectedVenue: jest.fn(),
}),
useSelectedVenue: jest.fn(),
}))

// eslint-disable-next-line jest/no-disabled-tests
describe.skip('useSync', () => {
it('should update search state with locationType params when user has geolocPosition', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ jest.mock('uuid', () => ({
jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')

const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({ setInitialVenues: mockSetInitialVenues }),
useInitialVenues: jest.fn(),
}))

jest.mock('features/venueMap/useGetAllVenues')
const mockUseGetAllVenues = useGetAllVenues as jest.Mock

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import React from 'react'

import { VenueTypeCodeKey } from 'api/gen'
import {
useVenueTypeCode,
useVenueTypeCodeActions,
} from 'features/venueMap/store/venueTypeCodeStore'
import { useVenueTypeCode } from 'features/venueMap/store/venueTypeCodeStore'
import { parseType } from 'libs/parsers/venueType'
import { ellipseString } from 'shared/string/ellipseString'
import { render, screen } from 'tests/utils'

import { SingleFilterBannerContainer } from './SingleFilterBannerContainer'

jest.mock('features/venueMap/store/venueTypeCodeStore')
const mockSetVenueTypeCode = jest.fn()
const mockUseVenueTypeCode = useVenueTypeCode as jest.Mock
const mockUseVenueTypeCodeActions = useVenueTypeCodeActions as jest.Mock

mockUseVenueTypeCodeActions.mockReturnValue({ setVenueTypeCode: mockSetVenueTypeCode })

const VENUE_TYPE = VenueTypeCodeKey.MOVIE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ import React from 'react'

import { navigate } from '__mocks__/@react-navigation/native'
import { VenueMapBlock } from 'features/venueMap/components/VenueMapBlock/VenueMapBlock'
import { initialVenuesActions } from 'features/venueMap/store/initialVenuesStore'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { analytics } from 'libs/analytics'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { fireEvent, render, screen, waitFor } from 'tests/utils'

const mockRemoveSelectedVenue = jest.fn()
jest.mock('features/venueMap/store/selectedVenueStore', () => ({
useSelectedVenueActions: () => ({
removeSelectedVenue: mockRemoveSelectedVenue,
}),
}))
const mockSetInitialVenues = jest.fn()
jest.mock('features/venueMap/store/initialVenuesStore', () => ({
useInitialVenuesActions: () => ({
setInitialVenues: mockSetInitialVenues,
}),
}))
const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue')

const mockSetInitialVenues = jest.spyOn(initialVenuesActions, 'setInitialVenues')

describe('<VenueMapBlock />', () => {
describe('When wipAppV2VenueMapBlock feature flag activated', () => {
Expand Down
Loading

0 comments on commit 5d6d7af

Please sign in to comment.