Skip to content

Commit

Permalink
(PC-33782) feat(V2): remove wipAppV2CircleNavButtons feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeneston-pass committed Jan 10, 2025
1 parent 2aeef69 commit cdad888
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 49 deletions.
44 changes: 15 additions & 29 deletions src/features/home/components/modules/TrendsModule.native.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { TrendsModule } from 'features/home/components/modules/TrendsModule'
import { formattedTrendsModule } from 'features/home/fixtures/homepage.fixture'
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { analytics } from 'libs/analytics'
import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen, userEvent } from 'tests/utils'
import * as useModalAPI from 'ui/components/modals/useModal'

Expand Down Expand Up @@ -39,26 +39,21 @@ const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelected

const mockShowModal = jest.fn()
const useModalAPISpy = jest.spyOn(useModalAPI, 'useModal')
const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(false)

const user = userEvent.setup()

jest.useFakeTimers()

describe('TrendsModule', () => {
it('should not log analytics on render when FF is disabled', () => {
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)

expect(analytics.logModuleDisplayedOnHomepage).not.toHaveBeenCalled()
})

it('should log analytics on render when FF is enabled', () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
it('should log analytics on render', () => {
const trackingPropsWithoutRedesign = {
...trackingProps,
homeEntryId: 'homeEntryId',
}
render(<TrendsModule {...formattedTrendsModule} {...trackingPropsWithoutRedesign} />)
render(
reactQueryProviderHOC(
<TrendsModule {...formattedTrendsModule} {...trackingPropsWithoutRedesign} />
)
)

expect(analytics.logModuleDisplayedOnHomepage).toHaveBeenCalledWith({
moduleId: 'g6VpeYbOosfALeqR55Ah6',
Expand All @@ -69,25 +64,22 @@ describe('TrendsModule', () => {
})

it('should redirect to VenueMap when pressing venue map block content type and user location is not everywhere', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

expect(navigate).toHaveBeenCalledWith('VenueMap', undefined)
})

it('should reset selected venue in store when pressing venue map block content type and user location is not everywhere', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

expect(mockRemoveSelectedVenue).toHaveBeenCalledTimes(1)
})

it('should open venue map location modal when pressing venue map block content type and user location is everywhere', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
useModalAPISpy.mockReturnValueOnce({
visible: false,
showModal: mockShowModal,
Expand All @@ -100,16 +92,15 @@ describe('TrendsModule', () => {
place: mockedPlace,
onModalHideRef: jest.fn(),
})
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

expect(mockShowModal).toHaveBeenCalledTimes(1)
})

it('should redirect to thematic home when pressing trend block content type', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Tendance 1'))

Expand All @@ -121,17 +112,14 @@ describe('TrendsModule', () => {
})

it('should log analytics when pressing venue map block content type and user location is not everywhere', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)

render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

expect(analytics.logConsultVenueMap).toHaveBeenNthCalledWith(1, { from: 'trend_block' })
})

it('should not log analytics when pressing venue map block content type and user location is everywhere', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
useModalAPISpy.mockReturnValueOnce({
visible: false,
showModal: mockShowModal,
Expand All @@ -144,16 +132,15 @@ describe('TrendsModule', () => {
place: mockedPlace,
onModalHideRef: jest.fn(),
})
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

expect(analytics.logConsultVenueMap).not.toHaveBeenCalled()
})

it('should log trends block clicked when pressing a trend', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Tendance 1'))

Expand All @@ -166,8 +153,7 @@ describe('TrendsModule', () => {
})

it('should log trends block clicked when pressing venue map block content type', async () => {
useFeatureFlagSpy.mockReturnValueOnce(true)
render(<TrendsModule {...formattedTrendsModule} {...trackingProps} />)
render(reactQueryProviderHOC(<TrendsModule {...formattedTrendsModule} {...trackingProps} />))

await user.press(screen.getByText('Accès carte des lieux'))

Expand Down
22 changes: 7 additions & 15 deletions src/features/home/components/modules/TrendsModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { useShouldDisplayVenueMap } from 'features/venueMap/hook/useShouldDispla
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'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode } from 'libs/location/types'
import { useModal } from 'ui/components/modals/useModal'
import { getSpacing } from 'ui/theme'
Expand All @@ -25,8 +23,6 @@ type Trends = {
const isWeb = Platform.OS === 'web'

export const TrendsModule = ({ index, moduleId, homeEntryId, items }: Trends) => {
const enableTrendsModule = useFeatureFlag(RemoteStoreFeatureFlags.WIP_APP_V2_CIRCLE_NAV_BUTTONS)

const { width } = useWindowDimensions()
const { selectedLocationMode } = useShouldDisplayVenueMap()
const {
Expand All @@ -40,16 +36,14 @@ export const TrendsModule = ({ index, moduleId, homeEntryId, items }: Trends) =>
const shouldOpenMapDirectly = selectedLocationMode !== LocationMode.EVERYWHERE && !isWeb

useEffect(() => {
if (enableTrendsModule) {
analytics.logModuleDisplayedOnHomepage({
moduleId,
moduleType: ContentTypes.TRENDS,
index,
homeEntryId,
})
}
analytics.logModuleDisplayedOnHomepage({
moduleId,
moduleType: ContentTypes.TRENDS,
index,
homeEntryId,
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [enableTrendsModule])
}, [])

const handleLogTrendsBlockClicked = (props: TrendBlock) =>
analytics.logTrendsBlockClicked({
Expand Down Expand Up @@ -87,8 +81,6 @@ export const TrendsModule = ({ index, moduleId, homeEntryId, items }: Trends) =>
}
}

if (!enableTrendsModule) return null

return (
<React.Fragment>
<Container isSmallScreen={isSmallScreen}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import React from 'react'
import { navigate } from '__mocks__/@react-navigation/native'
import { TrendsModule } from 'features/home/components/modules/TrendsModule'
import { formattedTrendsModule } from 'features/home/fixtures/homepage.fixture'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { fireEvent, render, screen, waitFor } from 'tests/utils/web'

const trackingProps = {
Expand All @@ -17,8 +16,7 @@ jest.mock('libs/firebase/remoteConfig/remoteConfig.services')

describe('TrendsModule', () => {
it('should redirect to thematic home when content type is venue map block', async () => {
setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_CIRCLE_NAV_BUTTONS])
render(<TrendsModule {...trackingProps} {...formattedTrendsModule} />)
render(reactQueryProviderHOC(<TrendsModule {...trackingProps} {...formattedTrendsModule} />))

fireEvent.click(screen.getByText('Accès carte des lieux'))

Expand Down
1 change: 0 additions & 1 deletion src/libs/firebase/firestore/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export enum RemoteStoreFeatureFlags {
TARGET_XP_CINE_FROM_OFFER = 'targetXpCineFromOffer',
WIP_APP_V2_BUSINESS_BLOCK = 'wipAppV2BusinessBlock',
WIP_APP_V2_CATEGORY_BLOCK = 'wipAppV2CategoryBlock',
WIP_APP_V2_CIRCLE_NAV_BUTTONS = 'wipAppV2CircleNavButtons',
WIP_APP_V2_LOCATION_WIDGET = 'wipAppV2LocationWidget',
WIP_APP_V2_MULTI_VIDEO_MODULE = 'wipAppV2MultiVideoModule',
WIP_APP_V2_SEARCH_CATEGORY_BLOCK = 'wipAppV2SearchCategoryBlock',
Expand Down

0 comments on commit cdad888

Please sign in to comment.