Skip to content

Commit

Permalink
(PC-34423) feat(venueMap): use isOpenToPublic instead of isPermanent …
Browse files Browse the repository at this point in the history
…for venue page redirection when wipIsOpenToPublic feature flag is true
  • Loading branch information
clesausse-pass committed Feb 11, 2025
1 parent 4855667 commit e6108e9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { VenueMapOfferPlaylist } from 'features/venueMap/components/VenueMapBott
import { VenueMapPreview } from 'features/venueMap/components/VenueMapPreview/VenueMapPreview'
import { GeolocatedVenue } from 'features/venueMap/components/VenueMapView/types'
import { getVenueTags } from 'features/venueMap/helpers/getVenueTags/getVenueTags'
import { useFeatureFlag } from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { useLocation } from 'libs/location'
import { getDistance } from 'libs/location/getDistance'
import { parseType } from 'libs/parsers/venueType'
Expand Down Expand Up @@ -54,6 +56,7 @@ export const VenueMapBottomSheet = forwardRef<BottomSheetMethods, VenueMapBottom
{ userLocation, selectedPlace, selectedLocationMode }
)
const { navigate } = useNavigation<UseNavigationType>()
const shouldUseIsOpenToPublic = useFeatureFlag(RemoteStoreFeatureFlags.WIP_IS_OPEN_TO_PUBLIC)

const venueTags = useMemo(() => {
if (!venue) {
Expand Down Expand Up @@ -87,6 +90,9 @@ export const VenueMapBottomSheet = forwardRef<BottomSheetMethods, VenueMapBottom
const venueMapPreview = useMemo(() => {
if (venue) {
const address = venue.postalCode ? `${venue.info}, ${venue.postalCode}` : venue.info
const isOpenToPublicVenue = venue.isOpenToPublic ?? false
const enableNavigate = shouldUseIsOpenToPublic ? isOpenToPublicVenue : venue.isPermanent

return (
<VenueMapPreview
venueName={venue.label}
Expand All @@ -100,14 +106,14 @@ export const VenueMapBottomSheet = forwardRef<BottomSheetMethods, VenueMapBottom
navigateTo={{ screen: 'Venue', params: { id: venue.venueId, from: 'venueMap' } }}
noBorder
testID="venueMapPreview"
enableNavigate={venue.isPermanent}
withRightArrow={venue.isPermanent}
enableNavigate={enableNavigate}
withRightArrow={enableNavigate}
style={{ paddingHorizontal: getSpacing(4) }}
/>
)
}
return null
}, [venue, onClose, venueTags])
}, [venue, shouldUseIsOpenToPublic, onClose, venueTags])

return (
<StyledBottomSheet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { State } from 'react-native-gesture-handler'
import { fireGestureHandler, getByGestureTestId } from 'react-native-gesture-handler/jest-utils'
import { UseQueryResult } from 'react-query'

import { navigate } from '__mocks__/@react-navigation/native'
import { VenueTypeCodeKey } from 'api/gen'
import { PlaylistType } from 'features/offer/enums'
import * as useVenueOffers from 'features/venue/api/useVenueOffers'
Expand All @@ -24,13 +25,6 @@ import * as constants from '../../constant'

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

const mockNavigate = jest.fn()
jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
useNavigation: () => ({ navigate: mockNavigate, push: jest.fn() }),
useFocusEffect: jest.fn(),
}))

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

Expand Down Expand Up @@ -94,9 +88,10 @@ const pressVenueMarker = (venue: GeolocatedVenue) => {
})
}

describe('<VenueMapView />', () => {
const user = userEvent.setup()
const user = userEvent.setup()
jest.useFakeTimers()

describe('<VenueMapView />', () => {
beforeEach(() => {
jest.useFakeTimers()
mockUseVenueOffers()
Expand Down Expand Up @@ -221,7 +216,37 @@ describe('<VenueMapView />', () => {
{ state: State.END, absoluteY: -30 },
])

expect(mockNavigate).toHaveBeenCalledWith('Venue', { id: venuesFixture[0].venueId })
expect(navigate).toHaveBeenCalledWith('Venue', { id: venuesFixture[0].venueId })
})

it('should deactivate navigation to Venue page when bottom sheet is open, pressing venue button, wipIsOpenToPublic feature flag is true and venue is not open to public', async () => {
mockUseVenueOffers(true)
setFeatureFlags([RemoteStoreFeatureFlags.WIP_IS_OPEN_TO_PUBLIC])
render(getVenueMapViewComponent({ selectedVenue: venuesFixture[0] }))
await screen.findByTestId(`marker-${venuesFixture[0].venueId}`)

await pressVenueMarker(venuesFixture[0])
await waitFor(() => expect(screen.getByTestId('venueMapPreview')).toBeOnTheScreen())

await user.press(screen.getByText(venuesFixture[0].label))

expect(screen.queryByTestId('RightFilled')).not.toBeOnTheScreen()
})

it('should activate navigation to Venue page when bottom sheet is open, pressing venue button, wipIsOpenToPublic feature flag is true and venue is open to public', async () => {
mockUseVenueOffers(true)
setFeatureFlags([RemoteStoreFeatureFlags.WIP_IS_OPEN_TO_PUBLIC])
render(
getVenueMapViewComponent({ selectedVenue: { ...venuesFixture[0], isOpenToPublic: true } })
)
await screen.findByTestId(`marker-${venuesFixture[0].venueId}`)

await pressVenueMarker(venuesFixture[0])
await waitFor(() => expect(screen.getByTestId('venueMapPreview')).toBeOnTheScreen())

await user.press(screen.getByText(venuesFixture[0].label))

expect(screen.getByTestId('RightFilled')).toBeOnTheScreen()
})

// TODO(PC-33564): fix flaky tests
Expand Down

0 comments on commit e6108e9

Please sign in to comment.