From 4ce621780eef8d1b21a7b455a70b862bcb9e4504 Mon Sep 17 00:00:00 2001
From: cgerrard-pass <187540148+cgerrard-pass@users.noreply.github.com>
Date: Tue, 14 Jan 2025 16:02:02 +0100
Subject: [PATCH] (BSR) refactor(tests): replace last spyon FF
---
.../ArtistBody/ArtistBody.native.test.tsx | 5 +-
.../ArtistPlaylist.native.test.tsx | 9 ++--
.../ArtistTopOffers.native.test.tsx | 10 ++--
.../SSOButton/SSOButton.native.test.tsx | 6 +--
...pConfirmationEmailSentPage.native.test.tsx | 3 --
...gnupConfirmationEmailSentPage.web.test.tsx | 3 --
.../pages/EighteenBirthday.native.test.tsx | 7 ++-
...creditBirthdayNotification.native.test.tsx | 7 ++-
.../components/BookDuoChoice.native.test.tsx | 8 +--
.../components/BookHourChoice.native.test.tsx | 5 +-
.../BookPricesChoice.native.test.tsx | 5 +-
.../components/BookingDetails.native.test.tsx | 5 +-
.../BookingEventChoices.native.test.tsx | 5 +-
.../BookingInformations.native.test.tsx | 8 +--
.../components/PriceLine.native.test.tsx | 8 +--
.../BookingPropertiesSection.native.test.tsx | 8 +--
.../CancelBookingModal.native.test.tsx | 8 +--
.../components/Favorite.native.test.tsx | 5 +-
.../RecommendationModule.native.test.tsx | 5 +-
.../modules/VenueListModule.native.test.tsx | 9 ++--
.../modules/VenueListModule.web.test.tsx | 4 +-
.../modules/VenueMapModule.native.test.tsx | 14 +++--
.../venues/AppV2VenuesModule.native.test.tsx | 14 +++--
.../venues/AppV2VenuesModule.web.test.tsx | 11 ++--
.../video/VideoCarouselModule.native.test.tsx | 54 ++++++-------------
.../OfferCTAButton.native.test.tsx | 6 +--
.../OfferContent/OfferContent.native.test.tsx | 8 ++-
.../OfferHeader/OfferHeader.web.test.tsx | 3 --
.../BeneficiaryCeilings.native.test.tsx | 8 +--
.../SearchListHeader.native.test.tsx | 22 +++-----
.../helpers/useSync/useSync.native.test.ts | 10 ++--
.../SearchLanding/SearchLanding.web.test.tsx | 5 +-
.../Cinema/CinemaPlaylist.native.test.tsx | 11 ++--
.../Films/FilmsPlaylist.native.test.tsx | 11 ++--
.../Music/MusicPlaylist.native.test.tsx | 11 ++--
.../ThematicSearchPlaylist.native.test.tsx | 9 ++--
...ThematicSearchPlaylistList.native.test.tsx | 9 ++--
.../FilterBannerContainer.native.test.tsx | 13 ++---
.../useShouldDisplayVenueMap.native.test.ts | 11 ++--
.../hook/useShouldDisplayVenueMap.web.test.ts | 7 +--
.../buttons/FavoriteButton.native.test.tsx | 7 +--
41 files changed, 197 insertions(+), 180 deletions(-)
diff --git a/src/features/artist/components/ArtistBody/ArtistBody.native.test.tsx b/src/features/artist/components/ArtistBody/ArtistBody.native.test.tsx
index 13e36e131d0..5292ab3665b 100644
--- a/src/features/artist/components/ArtistBody/ArtistBody.native.test.tsx
+++ b/src/features/artist/components/ArtistBody/ArtistBody.native.test.tsx
@@ -9,7 +9,7 @@ import { mockSubcategory } from 'features/offer/fixtures/mockSubcategory'
import { offerResponseSnap } from 'features/offer/fixtures/offerResponse'
import * as useArtistResults from 'features/offer/helpers/useArtistResults/useArtistResults'
import { mockedAlgoliaOffersWithSameArtistResponse } from 'libs/algolia/fixtures/algoliaFixtures'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { fireEvent, render, screen } from 'tests/utils'
@@ -40,8 +40,6 @@ useRoute.mockReturnValue({
},
})
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const spyUseArtistResults = jest.spyOn(useArtistResults, 'useArtistResults')
const mockArtist = {
@@ -51,6 +49,7 @@ const mockArtist = {
describe('', () => {
beforeEach(() => {
+ setFeatureFlags()
spyUseArtistResults.mockReturnValue({
artistTopOffers: mockedAlgoliaOffersWithSameArtistResponse.slice(0, 4),
artistPlaylist: [],
diff --git a/src/features/artist/components/ArtistPlaylist/ArtistPlaylist.native.test.tsx b/src/features/artist/components/ArtistPlaylist/ArtistPlaylist.native.test.tsx
index 22b9afe22fb..84ac3a7d9e6 100644
--- a/src/features/artist/components/ArtistPlaylist/ArtistPlaylist.native.test.tsx
+++ b/src/features/artist/components/ArtistPlaylist/ArtistPlaylist.native.test.tsx
@@ -3,12 +3,11 @@ import React from 'react'
import { ArtistPlaylist } from 'features/artist/components/ArtistPlaylist/ArtistPlaylist'
import { mockOffer } from 'features/bookOffer/fixtures/offer'
import { mockedAlgoliaOffersWithSameArtistResponse } from 'libs/algolia/fixtures/algoliaFixtures'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('@shopify/flash-list', () => {
const ActualFlashList = jest.requireActual('@shopify/flash-list').FlashList
class MockFlashList extends ActualFlashList {
@@ -26,6 +25,10 @@ jest.mock('@shopify/flash-list', () => {
})
describe('ArtistPlaylist', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_HOME_MODULE_SIZES])
+ })
+
it('should display artist playlist when there is some offer from this artist', () => {
render(
reactQueryProviderHOC(
diff --git a/src/features/artist/components/ArtistTopOffers/ArtistTopOffers.native.test.tsx b/src/features/artist/components/ArtistTopOffers/ArtistTopOffers.native.test.tsx
index 807ab21ca63..3bce62e9dd3 100644
--- a/src/features/artist/components/ArtistTopOffers/ArtistTopOffers.native.test.tsx
+++ b/src/features/artist/components/ArtistTopOffers/ArtistTopOffers.native.test.tsx
@@ -2,14 +2,18 @@ import React from 'react'
import { ArtistTopOffers } from 'features/artist/components/ArtistTopOffers/ArtistTopOffers'
import { mockedAlgoliaOffersWithSameArtistResponse } from 'libs/algolia/fixtures/algoliaFixtures'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
jest.mock('libs/firebase/analytics/analytics')
-describe('ArtistPlaylist', () => {
+describe('ArtistTopOffers', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_HOME_MODULE_SIZES])
+ })
+
it('should display top offers when there is some offer from this artist', () => {
render(
reactQueryProviderHOC(
diff --git a/src/features/auth/components/SSOButton/SSOButton.native.test.tsx b/src/features/auth/components/SSOButton/SSOButton.native.test.tsx
index 880096b8fdb..be0a274531c 100644
--- a/src/features/auth/components/SSOButton/SSOButton.native.test.tsx
+++ b/src/features/auth/components/SSOButton/SSOButton.native.test.tsx
@@ -8,7 +8,8 @@ import { AccountState, OauthStateResponse, SigninResponse, UserProfileResponse }
import { SSOButton } from 'features/auth/components/SSOButton/SSOButton'
import { beneficiaryUser } from 'fixtures/user'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { DEFAULT_REMOTE_CONFIG } from 'libs/firebase/remoteConfig/remoteConfig.constants'
import * as useRemoteConfigContext from 'libs/firebase/remoteConfig/RemoteConfigProvider'
import { eventMonitoring } from 'libs/monitoring'
@@ -16,8 +17,6 @@ import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, fireEvent, render, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/monitoring')
jest.mock('libs/react-native-device-info/getDeviceId')
jest.mock('features/identityCheck/context/SubscriptionContextProvider', () => ({
@@ -48,6 +47,7 @@ describe('', () => {
mockServer.getApi('/v1/oauth/state', {
oauthStateToken: 'oauth_state_token',
})
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_ENABLE_GOOGLE_SSO])
})
it('should sign in with device info when sso button is clicked', async () => {
diff --git a/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.native.test.tsx b/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.native.test.tsx
index cb350fce570..e552911770b 100644
--- a/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.native.test.tsx
+++ b/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.native.test.tsx
@@ -4,7 +4,6 @@ import React from 'react'
import { EmailValidationRemainingResendsResponse } from 'api/gen'
import { SignupConfirmationEmailSentPage } from 'features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage'
import { RootStackParamList } from 'features/navigation/RootNavigator/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils'
@@ -13,8 +12,6 @@ const navigationProps = {
route: { params: { email: 'john.doe@gmail.com' } },
} as StackScreenProps
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/firebase/analytics/analytics')
jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
diff --git a/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.web.test.tsx b/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.web.test.tsx
index bab0a6ff281..8edb047cc0d 100644
--- a/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.web.test.tsx
+++ b/src/features/auth/pages/signup/SignupConfirmationEmailSent/SignupConfirmationEmailSentPage.web.test.tsx
@@ -3,7 +3,6 @@ import React from 'react'
import { EmailValidationRemainingResendsResponse } from 'api/gen'
import { RootStackParamList } from 'features/navigation/RootNavigator/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, checkAccessibilityFor, render } from 'tests/utils/web'
@@ -14,8 +13,6 @@ const navigationProps = {
route: { params: { email: 'john.doe@gmail.com' } },
} as StackScreenProps
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
diff --git a/src/features/birthdayNotifications/pages/EighteenBirthday.native.test.tsx b/src/features/birthdayNotifications/pages/EighteenBirthday.native.test.tsx
index fe087e052fa..1a89edcf703 100644
--- a/src/features/birthdayNotifications/pages/EighteenBirthday.native.test.tsx
+++ b/src/features/birthdayNotifications/pages/EighteenBirthday.native.test.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import { navigate } from '__mocks__/@react-navigation/native'
import { nonBeneficiaryUser } from 'fixtures/user'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { storage } from 'libs/storage'
import { mockAuthContextWithUser } from 'tests/AuthContextUtils'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -10,7 +10,6 @@ import { fireEvent, render, screen } from 'tests/utils'
import { EighteenBirthday } from './EighteenBirthday'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
jest.mock('features/auth/context/AuthContext')
afterEach(() => {
@@ -24,6 +23,10 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
})
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should render eighteen birthday', () => {
render(reactQueryProviderHOC())
diff --git a/src/features/birthdayNotifications/pages/RecreditBirthdayNotification.native.test.tsx b/src/features/birthdayNotifications/pages/RecreditBirthdayNotification.native.test.tsx
index 7957ed7542e..e4eeaa80dc7 100644
--- a/src/features/birthdayNotifications/pages/RecreditBirthdayNotification.native.test.tsx
+++ b/src/features/birthdayNotifications/pages/RecreditBirthdayNotification.native.test.tsx
@@ -2,14 +2,13 @@ import mockdate from 'mockdate'
import React from 'react'
import { underageBeneficiaryUser } from 'fixtures/user'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { mockAuthContextWithUser } from 'tests/AuthContextUtils'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils'
import { RecreditBirthdayNotification } from './RecreditBirthdayNotification'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
jest.mock('features/auth/context/AuthContext')
jest.mock('features/profile/api/useUpdateProfileMutation', () => ({
useResetRecreditAmountToShow: jest.fn().mockReturnValue({
@@ -36,6 +35,10 @@ describe('', () => {
mockdate.set(new Date('2023-02-28'))
})
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should have correct text', async () => {
render(reactQueryProviderHOC())
diff --git a/src/features/bookOffer/components/BookDuoChoice.native.test.tsx b/src/features/bookOffer/components/BookDuoChoice.native.test.tsx
index 17644a23d7c..bdb75875e22 100644
--- a/src/features/bookOffer/components/BookDuoChoice.native.test.tsx
+++ b/src/features/bookOffer/components/BookDuoChoice.native.test.tsx
@@ -2,13 +2,11 @@ import React from 'react'
import { BookingState, Step } from 'features/bookOffer/context/reducer'
import { mockOffer } from 'features/bookOffer/fixtures/offer'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { fireEvent, render, screen } from 'tests/utils'
import { BookDuoChoice } from './BookDuoChoice'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockStep = Step.DUO
const mockDismissModal = jest.fn()
@@ -44,6 +42,10 @@ jest.mock('features/offer/helpers/useHasEnoughCredit/useHasEnoughCredit', () =>
}))
describe('BookDuoChoice', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should display two blocs if offer is duo', () => {
render()
diff --git a/src/features/bookOffer/components/BookHourChoice.native.test.tsx b/src/features/bookOffer/components/BookHourChoice.native.test.tsx
index 3fe6f936255..b1ba1aa95e3 100644
--- a/src/features/bookOffer/components/BookHourChoice.native.test.tsx
+++ b/src/features/bookOffer/components/BookHourChoice.native.test.tsx
@@ -5,13 +5,11 @@ import { BookingState, Step } from 'features/bookOffer/context/reducer'
import { mockOffer as mockBaseOffer } from 'features/bookOffer/fixtures/offer'
import { stock1, stock2, stock3, stock4 } from 'features/bookOffer/fixtures/stocks'
import { IBookingContext } from 'features/bookOffer/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { fireEvent, render, screen } from 'tests/utils'
import { BookHourChoice } from './BookHourChoice'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockStep = Step.HOUR
const mockDuoStep = Step.DUO
@@ -60,6 +58,7 @@ describe('BookHourChoice when hour is already selected', () => {
dismissModal: jest.fn(),
dispatch: mockDispatch,
})
+ setFeatureFlags()
})
it('should change step to Hour', () => {
diff --git a/src/features/bookOffer/components/BookPricesChoice.native.test.tsx b/src/features/bookOffer/components/BookPricesChoice.native.test.tsx
index 5ee5b9df099..94132fa9bfe 100644
--- a/src/features/bookOffer/components/BookPricesChoice.native.test.tsx
+++ b/src/features/bookOffer/components/BookPricesChoice.native.test.tsx
@@ -4,11 +4,9 @@ import { BookPricesChoice } from 'features/bookOffer/components/BookPricesChoice
import { BookingState, initialBookingState } from 'features/bookOffer/context/reducer'
import { mockStocks } from 'features/bookOffer/fixtures/stocks'
import { IBookingContext } from 'features/bookOffer/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { fireEvent, render, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockInitialBookingState = initialBookingState
const mockOfferId = 1337
@@ -40,6 +38,7 @@ describe('BookPricesChoice', () => {
dismissModal: jest.fn(),
dispatch: mockDispatch,
})
+ setFeatureFlags()
})
it('should render prices of stocks in parameter', () => {
diff --git a/src/features/bookOffer/components/BookingDetails.native.test.tsx b/src/features/bookOffer/components/BookingDetails.native.test.tsx
index 16b0dac7f93..ef2720cb4e6 100644
--- a/src/features/bookOffer/components/BookingDetails.native.test.tsx
+++ b/src/features/bookOffer/components/BookingDetails.native.test.tsx
@@ -11,7 +11,7 @@ import { offerResponseSnap } from 'features/offer/fixtures/offerResponse'
import { offerStockResponseSnap } from 'features/offer/fixtures/offerStockResponse'
import * as UnderageUserAPI from 'features/profile/helpers/useIsUserUnderage'
import * as logOfferConversionAPI from 'libs/algolia/analytics/logOfferConversion'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { mockServer } from 'tests/mswServer'
@@ -22,8 +22,6 @@ import { SnackBarHelperSettings } from 'ui/components/snackBar/types'
import { BookingDetails, BookingDetailsProps } from './BookingDetails'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockDismissModal = jest.fn()
const mockDispatch = jest.fn()
@@ -173,6 +171,7 @@ describe('', () => {
dismissModal: mockDismissModal,
dispatch: mockDispatch,
})
+ setFeatureFlags()
})
it('should initialize correctly state when offer isDigital', async () => {
diff --git a/src/features/bookOffer/components/BookingEventChoices.native.test.tsx b/src/features/bookOffer/components/BookingEventChoices.native.test.tsx
index 2c568044ac5..566fcac854f 100644
--- a/src/features/bookOffer/components/BookingEventChoices.native.test.tsx
+++ b/src/features/bookOffer/components/BookingEventChoices.native.test.tsx
@@ -5,7 +5,7 @@ import { Step } from 'features/bookOffer/context/reducer'
import { useBookingContext } from 'features/bookOffer/context/useBookingContext'
import { offerResponseSnap } from 'features/offer/fixtures/offerResponse'
import { beneficiaryUser } from 'fixtures/user'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { mockAuthContextWithUser } from 'tests/AuthContextUtils'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -13,8 +13,6 @@ import { render, screen, waitFor } from 'tests/utils'
import { BookingEventChoices } from './BookingEventChoices'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('features/auth/context/AuthContext')
const mockUseBooking = useBookingContext as jest.Mock
@@ -35,6 +33,7 @@ jest.mock('features/bookOffer/context/useBookingContext', () => ({
describe('', () => {
beforeEach(() => {
mockServer.getApi(`/v2/offer/116656`, offerResponseSnap)
+ setFeatureFlags()
})
beforeAll(() => {
diff --git a/src/features/bookOffer/components/BookingInformations.native.test.tsx b/src/features/bookOffer/components/BookingInformations.native.test.tsx
index 0931791882e..fe8e0dc2568 100644
--- a/src/features/bookOffer/components/BookingInformations.native.test.tsx
+++ b/src/features/bookOffer/components/BookingInformations.native.test.tsx
@@ -6,14 +6,12 @@ import { useBookingContext } from 'features/bookOffer/context/useBookingContext'
import { mockOffer as baseOffer } from 'features/bookOffer/fixtures/offer'
import { useBookingStock } from 'features/bookOffer/helpers/useBookingStock'
import { offerStockResponseSnap } from 'features/offer/fixtures/offerStockResponse'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { formatDateTimezone } from 'libs/parsers/formatDates'
import { render, screen } from 'tests/utils'
import { BookingInformations } from './BookingInformations'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const randomDatetime = '2020-12-01T00:00:00Z'
jest.mock('features/bookOffer/context/useBookingContext')
@@ -45,6 +43,10 @@ jest.mock('features/bookOffer/helpers/useBookingOffer', () => ({
const ANY_CHARACTER = /./
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should return empty component when no offer', async () => {
mockUseBookingOffer.mockReturnValueOnce(undefined)
render()
diff --git a/src/features/bookOffer/components/PriceLine.native.test.tsx b/src/features/bookOffer/components/PriceLine.native.test.tsx
index 41c828685ce..de11adeaa39 100644
--- a/src/features/bookOffer/components/PriceLine.native.test.tsx
+++ b/src/features/bookOffer/components/PriceLine.native.test.tsx
@@ -1,14 +1,16 @@
import React from 'react'
import { PriceLine } from 'features/bookOffer/components/PriceLine'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { render, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const attributes = ['VOSTFR', '3D', 'IMAX']
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should show total price', () => {
render()
diff --git a/src/features/bookings/components/BookingPropertiesSection.native.test.tsx b/src/features/bookings/components/BookingPropertiesSection.native.test.tsx
index 70ec29486b4..b1284eafcca 100644
--- a/src/features/bookings/components/BookingPropertiesSection.native.test.tsx
+++ b/src/features/bookings/components/BookingPropertiesSection.native.test.tsx
@@ -5,18 +5,20 @@ import { BookingPropertiesSection } from 'features/bookings/components/BookingPr
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import { Booking } from 'features/bookings/types'
import { beneficiaryUser } from 'fixtures/user'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { mockAuthContextWithUser } from 'tests/AuthContextUtils'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen, waitFor } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('features/auth/context/AuthContext')
jest.mock('libs/firebase/analytics/analytics')
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
beforeAll(() => {
mockAuthContextWithUser(
{
diff --git a/src/features/bookings/components/CancelBookingModal.native.test.tsx b/src/features/bookings/components/CancelBookingModal.native.test.tsx
index 8f479f62c60..fc7399d8db5 100644
--- a/src/features/bookings/components/CancelBookingModal.native.test.tsx
+++ b/src/features/bookings/components/CancelBookingModal.native.test.tsx
@@ -5,7 +5,7 @@ import { CancelBookingModal } from 'features/bookings/components/CancelBookingMo
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import { getTabNavConfig } from 'features/navigation/TabBar/helpers'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import * as useNetInfoContextDefault from 'libs/network/NetInfoWrapper'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -15,8 +15,6 @@ import { SnackBarHelperSettings } from 'ui/components/snackBar/types'
const mockDismissModal = jest.fn()
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/jwt/jwt')
jest.mock('features/auth/context/AuthContext')
@@ -43,6 +41,10 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
})
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
mockUseNetInfoContext.mockReturnValue({ isConnected: true })
it('should dismiss modal on press rightIconButton', () => {
diff --git a/src/features/favorites/components/Favorite.native.test.tsx b/src/features/favorites/components/Favorite.native.test.tsx
index 811cbe20609..a66d1f52190 100644
--- a/src/features/favorites/components/Favorite.native.test.tsx
+++ b/src/features/favorites/components/Favorite.native.test.tsx
@@ -14,7 +14,7 @@ import { initialFavoritesState } from 'features/favorites/context/reducer'
import { favoriteResponseSnap as favorite } from 'features/favorites/fixtures/favoriteResponseSnap'
import { analytics } from 'libs/analytics'
import { EmptyResponse } from 'libs/fetch'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { subcategoriesDataTest } from 'libs/subcategories/fixtures/subcategoriesResponse'
import { Credit } from 'shared/user/useAvailableCredit'
import { mockServer } from 'tests/mswServer'
@@ -25,8 +25,6 @@ import { SnackBarHelperSettings } from 'ui/components/snackBar/types'
import { Favorite } from './Favorite'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockShowErrorSnackBar = jest.fn()
jest.mock('ui/components/snackBar/SnackBarContext', () => ({
useSnackBarContext: () => ({
@@ -72,6 +70,7 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
describe(' component', () => {
beforeEach(() => {
mockServer.getApi(`/v1/subcategories/v2`, subcategoriesDataTest)
+ setFeatureFlags()
})
it('should navigate to the offer when clicking on the favorite', async () => {
diff --git a/src/features/home/components/modules/RecommendationModule.native.test.tsx b/src/features/home/components/modules/RecommendationModule.native.test.tsx
index c72d74e3d03..da0e9596e8d 100644
--- a/src/features/home/components/modules/RecommendationModule.native.test.tsx
+++ b/src/features/home/components/modules/RecommendationModule.native.test.tsx
@@ -5,7 +5,6 @@ import { mockedAlgoliaResponse } from 'libs/algolia/fixtures/algoliaFixtures'
import { analytics } from 'libs/analytics'
import { ContentTypes, DisplayParametersFields } from 'libs/contentful/types'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { subcategoriesDataTest } from 'libs/subcategories/fixtures/subcategoriesResponse'
import { mockServer } from 'tests/mswServer'
@@ -14,8 +13,6 @@ import { act, render, screen, waitFor } from 'tests/utils'
import { RecommendationModule } from './RecommendationModule'
-const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag')
-
const displayParameters: DisplayParametersFields = {
title: 'Tes offres recommandées',
minOffers: 2,
@@ -45,7 +42,7 @@ describe('RecommendationModule', () => {
})
it('should display V2 playlist when FF activated', async () => {
- useFeatureFlagSpy.mockReturnValueOnce(true)
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
renderRecommendationModule()
expect(await screen.findByTestId('playlist-card-offer-v2')).toBeOnTheScreen()
diff --git a/src/features/home/components/modules/VenueListModule.native.test.tsx b/src/features/home/components/modules/VenueListModule.native.test.tsx
index 93e9de4818f..92e5cf1f568 100644
--- a/src/features/home/components/modules/VenueListModule.native.test.tsx
+++ b/src/features/home/components/modules/VenueListModule.native.test.tsx
@@ -5,14 +5,13 @@ import { VenueListModule } from 'features/home/components/modules/VenueListModul
import { selectedVenueActions } from 'features/venueMap/store/selectedVenueStore'
import { venuesSearchFixture } from 'libs/algolia/fixtures/venuesSearchFixture'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { fireEvent, render, screen, waitFor } from 'tests/utils'
import * as useModalAPI from 'ui/components/modals/useModal'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockShowModal = jest.fn()
const useModalAPISpy = jest.spyOn(useModalAPI, 'useModal')
@@ -38,6 +37,10 @@ jest.mock('libs/location', () => ({
const mockRemoveSelectedVenue = jest.spyOn(selectedVenueActions, 'removeSelectedVenue')
describe('', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP])
+ })
+
it('should display venue list', () => {
render(
', () => {
+ beforeEach(jest.fn())
+
it('should redirect to thematic home', async () => {
render(
({
}))
describe('VenueMapModule', () => {
+ beforeEach(() => {
+ setFeatureFlags([
+ RemoteStoreFeatureFlags.WIP_VENUE_MAP,
+ RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_MAP_BLOCK,
+ ])
+ })
+
it('should render venue map block when user is located and feature flag enabled', () => {
render()
@@ -36,7 +42,7 @@ describe('VenueMapModule', () => {
})
it('should not render venue map block when feature flag is disabled', () => {
- useFeatureFlagSpy.mockReturnValueOnce(false)
+ setFeatureFlags()
render()
expect(screen.queryByText('Carte des lieux culturels')).not.toBeOnTheScreen()
diff --git a/src/features/home/components/modules/venues/AppV2VenuesModule.native.test.tsx b/src/features/home/components/modules/venues/AppV2VenuesModule.native.test.tsx
index 0f5720677b1..4b3d753a854 100644
--- a/src/features/home/components/modules/venues/AppV2VenuesModule.native.test.tsx
+++ b/src/features/home/components/modules/venues/AppV2VenuesModule.native.test.tsx
@@ -4,12 +4,11 @@ import { AppV2VenuesModule } from 'features/home/components/modules/venues/AppV2
import { ModuleData } from 'features/home/types'
import { venuesSearchFixture } from 'libs/algolia/fixtures/venuesSearchFixture'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils'
-const mockFeatureFlag = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const props = {
moduleId: 'fakemoduleid',
index: 1,
@@ -23,6 +22,8 @@ const props = {
describe('', () => {
it('should log ModuleDisplayedOnHomePage event when seeing the module', () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_LIST])
+
renderAppV2VenuesModule()
expect(analytics.logModuleDisplayedOnHomepage).toHaveBeenNthCalledWith(1, {
@@ -35,6 +36,8 @@ describe('', () => {
})
it('should not render list when data is undefined', () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_LIST])
+
renderAppV2VenuesModule({ data: undefined })
expect(
@@ -43,13 +46,16 @@ describe('', () => {
})
it('should return 4 venues maximum when home id', () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_LIST])
+
renderAppV2VenuesModule()
expect(screen.queryByText('Le Petit Rintintin 5')).not.toBeOnTheScreen()
})
it('should not render list when feature flag deactivated', () => {
- mockFeatureFlag.mockReturnValueOnce(false)
+ setFeatureFlags()
+
renderAppV2VenuesModule()
expect(
diff --git a/src/features/home/components/modules/venues/AppV2VenuesModule.web.test.tsx b/src/features/home/components/modules/venues/AppV2VenuesModule.web.test.tsx
index f2dcfc27575..3a1bf4f3ec6 100644
--- a/src/features/home/components/modules/venues/AppV2VenuesModule.web.test.tsx
+++ b/src/features/home/components/modules/venues/AppV2VenuesModule.web.test.tsx
@@ -3,7 +3,8 @@ import React, { ComponentProps } from 'react'
import { AppV2VenuesModule } from 'features/home/components/modules/venues/AppV2VenuesModule.web'
import { venuesSearchFixture } from 'libs/algolia/fixtures/venuesSearchFixture'
import { Layout } from 'libs/contentful/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen } from 'tests/utils/web'
@@ -24,23 +25,27 @@ const props = {
}
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
-const mockFeatureFlag = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
describe('', () => {
it('should return 6 venues maximum on web desktop', () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_VENUE_LIST])
+
renderAppV2VenuesModule({ isDesktopViewport: true })
expect(screen.getByText('Le Petit Rintintin 5')).toBeInTheDocument()
})
it('should return 4 venues maximum on web mobile', () => {
+ setFeatureFlags()
+
renderAppV2VenuesModule({ isDesktopViewport: false })
expect(screen.queryByText('Le Petit Rintintin 5')).not.toBeInTheDocument()
})
it('should not render list when feature flag deactivated', () => {
- mockFeatureFlag.mockReturnValueOnce(false)
+ setFeatureFlags()
+
renderAppV2VenuesModule()
expect(
diff --git a/src/features/home/components/modules/video/VideoCarouselModule.native.test.tsx b/src/features/home/components/modules/video/VideoCarouselModule.native.test.tsx
index 608d10cb037..1d9a8a7915a 100644
--- a/src/features/home/components/modules/video/VideoCarouselModule.native.test.tsx
+++ b/src/features/home/components/modules/video/VideoCarouselModule.native.test.tsx
@@ -15,14 +15,13 @@ import * as fetchAlgoliaOffer from 'libs/algolia/fetchAlgolia/fetchCarouselVideo
import { mockedAlgoliaResponse } from 'libs/algolia/fixtures/algoliaFixtures'
import { analytics } from 'libs/analytics'
import { ContentTypes } from 'libs/contentful/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, fireEvent, render, screen, waitFor } from 'tests/utils'
jest.mock('libs/firebase/analytics/analytics')
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockFetchCarouselVideoOffers = jest
.spyOn(fetchAlgoliaOffer, 'fetchCarouselVideoOffers')
.mockResolvedValue([mockedAlgoliaResponse])
@@ -32,15 +31,16 @@ const DEFAULT_ITEM_WITH_TAG = videoCarouselModuleFixture.items[1]
const DEFAULT_ITEM_WITH_HOME_ENTRY_ID = videoCarouselModuleFixture.items[2]
const MOCKED_ALGOLIA_RESPONSE_OFFER = mockedAlgoliaResponse.hits[0]
-describe('', () => {
+// TODO(PC-33562): fix flaky tests
+// eslint-disable-next-line jest/no-disabled-tests
+describe.skip('', () => {
beforeEach(() => {
MockedYouTubePlayer.setPlayerState(PLAYER_STATES.UNSTARTED)
MockedYouTubePlayer.setError(false)
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_VIDEO_9_16])
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should call fetchCarouselVideoOffers with properly formatted data', async () => {
+ it('should call fetchCarouselVideoOffers with properly formatted data', async () => {
renderVideoCarouselModule(videoCarouselModuleFixture)
await screen.findByText(MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name)
@@ -75,9 +75,7 @@ describe('', () => {
])
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should call fetchCarouselVideoOffers with empty array when item has homeEntryId', async () => {
+ it('should call fetchCarouselVideoOffers with empty array when item has homeEntryId', async () => {
const VIDEO_CAROUSEL_MODULE_FIXTURE_WITH_ITEM_HAVING_HOMEENTRYID = {
...videoCarouselModuleFixture,
items: [DEFAULT_ITEM_WITH_HOME_ENTRY_ID],
@@ -90,9 +88,7 @@ describe('', () => {
expect(mockFetchCarouselVideoOffers).toHaveBeenCalledWith([])
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should not render carousel with only one item', async () => {
+ it('should not render carousel with only one item', async () => {
const VIDEO_CAROUSEL_MODULE_FIXTURE_WITH_ONE_ITEM = {
...videoCarouselModuleFixture,
items: [DEFAULT_ITEM_WITH_OFFER_ID],
@@ -105,9 +101,7 @@ describe('', () => {
expect(screen.queryByTestId('videoCarousel')).not.toBeOnTheScreen()
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should render carousel with multiple items', async () => {
+ it('should render carousel with multiple items', async () => {
renderVideoCarouselModule(videoCarouselModuleFixture)
await screen.findByText(MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name)
@@ -115,9 +109,7 @@ describe('', () => {
expect(screen.getByTestId('videoCarousel')).toBeOnTheScreen()
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should render video player correctly', async () => {
+ it('should render video player correctly', async () => {
renderVideoCarouselModule(videoCarouselModuleFixture)
await screen.findByText(MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name)
@@ -129,9 +121,7 @@ describe('', () => {
expect(verticalVideoPlayerButton).toBeOnTheScreen()
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should redirect to thematic home when item has an homeEntryId', async () => {
+ it('should redirect to thematic home when item has an homeEntryId', async () => {
const HOME_ENTRY_ID = DEFAULT_ITEM_WITH_HOME_ENTRY_ID.homeEntryId
const THEMATIC_HOME_TITLE = DEFAULT_ITEM_WITH_HOME_ENTRY_ID.thematicHomeTitle
const MODULE_ITEM_ID = DEFAULT_ITEM_WITH_HOME_ENTRY_ID.id
@@ -152,9 +142,7 @@ describe('', () => {
})
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should redirect to offer based on offerId', async () => {
+ it('should redirect to offer based on offerId', async () => {
const OFFER_NAME = MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name
const OFFER_ID = MOCKED_ALGOLIA_RESPONSE_OFFER.objectID
@@ -172,9 +160,7 @@ describe('', () => {
})
describe('tracking', () => {
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should send logConsultVideo when video starts autoplay', async () => {
+ it('should send logConsultVideo when video starts autoplay', async () => {
renderVideoCarouselModule(videoCarouselModuleFixture)
await screen.findByText(MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name)
@@ -187,9 +173,7 @@ describe('', () => {
})
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should send logConsultVideo event when user presses `next video button`', async () => {
+ it('should send logConsultVideo event when user presses `next video button`', async () => {
MockedYouTubePlayer.setPlayerState(PLAYER_STATES.ENDED)
renderVideoCarouselModule(videoCarouselModuleFixture)
@@ -209,9 +193,7 @@ describe('', () => {
})
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should send logConsultOffer event when user presses on offer', async () => {
+ it('should send logConsultOffer event when user presses on offer', async () => {
const OFFER_NAME = MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name
const OFFER_ID = MOCKED_ALGOLIA_RESPONSE_OFFER.objectID
@@ -231,9 +213,7 @@ describe('', () => {
})
})
- // TODO(PC-33562): fix flaky tests
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('should send logModuleDisplayedOnHomepage event', async () => {
+ it('should send logModuleDisplayedOnHomepage event', async () => {
const OFFER_NAME = MOCKED_ALGOLIA_RESPONSE_OFFER.offer.name
renderVideoCarouselModule(videoCarouselModuleFixture)
diff --git a/src/features/offer/components/OfferCTAButton/OfferCTAButton.native.test.tsx b/src/features/offer/components/OfferCTAButton/OfferCTAButton.native.test.tsx
index 71567fa01ed..68084c4fdc6 100644
--- a/src/features/offer/components/OfferCTAButton/OfferCTAButton.native.test.tsx
+++ b/src/features/offer/components/OfferCTAButton/OfferCTAButton.native.test.tsx
@@ -9,7 +9,7 @@ import { offerResponseSnap } from 'features/offer/fixtures/offerResponse'
import { mockedBookingApi } from 'fixtures/booking'
import { beneficiaryUser } from 'fixtures/user'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { mockAuthContextWithoutUser, mockAuthContextWithUser } from 'tests/AuthContextUtils'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -23,9 +23,6 @@ jest.mock('features/auth/context/AuthContext')
jest.mock('libs/subcategories/useSubcategories')
-// feature flag wipPricesByCategories
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('features/navigation/helpers/openUrl')
const mockedOpenUrl = openUrl as jest.MockedFunction
@@ -78,6 +75,7 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
describe('', () => {
beforeEach(() => {
mockAuthContextWithoutUser({ persist: true })
+ setFeatureFlags() // No tests for WIP_APP_V2_CATEGORY_BLOCK
})
it('should open booking modal when login after booking attempt', async () => {
diff --git a/src/features/offer/components/OfferContent/OfferContent.native.test.tsx b/src/features/offer/components/OfferContent/OfferContent.native.test.tsx
index 82e6ddad1f9..3ca9999d294 100644
--- a/src/features/offer/components/OfferContent/OfferContent.native.test.tsx
+++ b/src/features/offer/components/OfferContent/OfferContent.native.test.tsx
@@ -20,7 +20,8 @@ import {
mockedAlgoliaResponse,
} from 'libs/algolia/fixtures/algoliaFixtures'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { DEFAULT_REMOTE_CONFIG } from 'libs/firebase/remoteConfig/remoteConfig.constants'
import * as useRemoteConfigContextModule from 'libs/firebase/remoteConfig/RemoteConfigProvider'
import { Position } from 'libs/location'
@@ -66,8 +67,6 @@ jest.spyOn(useGoBack, 'useGoBack').mockReturnValue({
canGoBack: jest.fn(() => true),
})
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('features/auth/context/AuthContext')
const apiRecoParams: RecommendationApiParams = {
@@ -167,8 +166,7 @@ describe('', () => {
mockServer.getApi('/v1/subcategories/v2', subcategoriesDataTest)
mockPosition = { latitude: 90.4773245, longitude: 90.4773245 }
mockAuthContextWithoutUser({ persist: true })
-
- jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
+ setFeatureFlags([RemoteStoreFeatureFlags.TARGET_XP_CINE_FROM_OFFER])
})
afterEach(cleanup)
diff --git a/src/features/offer/components/OfferHeader/OfferHeader.web.test.tsx b/src/features/offer/components/OfferHeader/OfferHeader.web.test.tsx
index 7d00101fbfa..3039ecb7678 100644
--- a/src/features/offer/components/OfferHeader/OfferHeader.web.test.tsx
+++ b/src/features/offer/components/OfferHeader/OfferHeader.web.test.tsx
@@ -4,7 +4,6 @@ import { Animated } from 'react-native'
import { PaginatedFavoritesResponse } from 'api/gen'
import { paginatedFavoritesResponseSnap } from 'features/favorites/fixtures/paginatedFavoritesResponseSnap'
import { offerResponseSnap as mockOffer } from 'features/offer/fixtures/offerResponse'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, render, screen, userEvent } from 'tests/utils/web'
@@ -13,8 +12,6 @@ import { OfferHeader } from '../OfferHeader/OfferHeader'
jest.mock('features/auth/context/AuthContext')
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
diff --git a/src/features/profile/components/BeneficiaryCeilings/BeneficiaryCeilings.native.test.tsx b/src/features/profile/components/BeneficiaryCeilings/BeneficiaryCeilings.native.test.tsx
index 3af88e6454c..dc5528680ce 100644
--- a/src/features/profile/components/BeneficiaryCeilings/BeneficiaryCeilings.native.test.tsx
+++ b/src/features/profile/components/BeneficiaryCeilings/BeneficiaryCeilings.native.test.tsx
@@ -8,11 +8,9 @@ import {
domains_exhausted_credit_v1,
} from 'features/profile/fixtures/domainsCredit'
import * as ProfileUtils from 'features/profile/helpers/useIsUserUnderageBeneficiary'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { render, waitFor, screen } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockUseIsUserUnderageBeneficiary = jest
.spyOn(ProfileUtils, 'useIsUserUnderageBeneficiary')
.mockReturnValue(false)
@@ -20,6 +18,10 @@ const mockUseIsUserUnderageBeneficiary = jest
jest.mock('libs/firebase/analytics/analytics')
describe('BeneficiaryCeilings', () => {
+ beforeEach(() => {
+ setFeatureFlags()
+ })
+
it('should not return credits if credit is exhausted', () => {
render()
diff --git a/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx b/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx
index 2737549674c..68f77c1570e 100644
--- a/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx
+++ b/src/features/search/components/SearchListHeader/SearchListHeader.native.test.tsx
@@ -12,7 +12,8 @@ import { MAX_RADIUS } from 'features/search/helpers/reducer.helpers'
import { SearchState } from 'features/search/types'
import { Venue } from 'features/venue/types'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { GeoCoordinates } from 'libs/location'
import { ILocationContext, LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
@@ -35,13 +36,6 @@ jest.mock('libs/location/LocationWrapper', () => ({
useLocation: () => mockUseLocation(),
}))
-const useFeatureFlagSpy = jest
- .spyOn(useFeatureFlagAPI, 'useFeatureFlag')
- // venue map FF
- .mockReturnValue(false)
- // venue map in search FF
- .mockReturnValue(false)
-
const mockDisabilities = {
[DisplayedDisabilitiesEnum.AUDIO]: false,
[DisplayedDisabilitiesEnum.MENTAL]: false,
@@ -106,8 +100,8 @@ describe('', () => {
})
describe('When feature flags deactivated', () => {
- beforeAll(() => {
- useFeatureFlagSpy.mockReturnValue(false)
+ beforeEach(() => {
+ setFeatureFlags()
})
it('should display the number of results', () => {
@@ -457,8 +451,8 @@ describe('', () => {
})
describe('When wipVenueMapInSearch feature flag activated', () => {
- beforeAll(() => {
- useFeatureFlagSpy.mockReturnValue(true).mockReturnValue(true)
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP_IN_SEARCH])
})
it('should not displayed the button "Voir sur la carte"', () => {
@@ -476,8 +470,8 @@ describe('', () => {
})
describe('When wipAppV2SystemBlock feature flag activated', () => {
- beforeAll(() => {
- useFeatureFlagSpy.mockReturnValue(true)
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_APP_V2_SYSTEM_BLOCK])
})
it('should display system banner for geolocation incitation', () => {
diff --git a/src/features/search/helpers/useSync/useSync.native.test.ts b/src/features/search/helpers/useSync/useSync.native.test.ts
index 6e60ba713f7..981d508e85e 100644
--- a/src/features/search/helpers/useSync/useSync.native.test.ts
+++ b/src/features/search/helpers/useSync/useSync.native.test.ts
@@ -1,6 +1,7 @@
import { useRoute } from '__mocks__/@react-navigation/native'
import { initialSearchState } from 'features/search/context/reducer'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { GeolocPermissionState } from 'libs/location'
import { LocationMode, Position } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
@@ -21,8 +22,6 @@ jest.mock('libs/subcategories/useSubcategories')
jest.mock('libs/firebase/analytics/analytics')
jest.mock('features/navigation/TabBar/routes')
-const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag')
-useFeatureFlagSpy.mockReturnValue(false)
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter')
@@ -73,8 +72,13 @@ jest.mock('libs/location/LocationWrapper', () => ({
}))
mockUseLocation.mockReturnValue(everywhereUseLocation)
+// TODO(PC-33123): fix test
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('useSync', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP])
+ })
+
it('should update search state with locationType params when user has geolocPosition', async () => {
mockUseLocation
.mockReturnValueOnce({
diff --git a/src/features/search/pages/SearchLanding/SearchLanding.web.test.tsx b/src/features/search/pages/SearchLanding/SearchLanding.web.test.tsx
index 953a49a896b..727d028df70 100644
--- a/src/features/search/pages/SearchLanding/SearchLanding.web.test.tsx
+++ b/src/features/search/pages/SearchLanding/SearchLanding.web.test.tsx
@@ -5,7 +5,7 @@ import { initialSearchState } from 'features/search/context/reducer'
import * as useFilterCountAPI from 'features/search/helpers/useFilterCount/useFilterCount'
import { SearchLanding } from 'features/search/pages/SearchLanding/SearchLanding'
import { SearchState } from 'features/search/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import * as useNetInfoContextDefault from 'libs/network/NetInfoWrapper'
import { subcategoriesDataTest } from 'libs/subcategories/fixtures/subcategoriesResponse'
import { mockedSuggestedVenue } from 'libs/venue/fixtures/mockedSuggestedVenues'
@@ -82,8 +82,6 @@ jest.mock('uuid', () => ({
v4: jest.fn(),
}))
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
jest.mock('features/navigation/TabBar/routes')
@@ -93,6 +91,7 @@ describe('', () => {
describe('Accessibility', () => {
beforeEach(() => {
mockServer.getApi('/v1/subcategories/v2', subcategoriesDataTest)
+ setFeatureFlags()
})
it('should not have basic accessibility issues', async () => {
diff --git a/src/features/search/pages/ThematicSearch/Cinema/CinemaPlaylist.native.test.tsx b/src/features/search/pages/ThematicSearch/Cinema/CinemaPlaylist.native.test.tsx
index a0d572e5221..ca97f245cab 100644
--- a/src/features/search/pages/ThematicSearch/Cinema/CinemaPlaylist.native.test.tsx
+++ b/src/features/search/pages/ThematicSearch/Cinema/CinemaPlaylist.native.test.tsx
@@ -2,7 +2,8 @@ import React from 'react'
import * as useThematicSearchPlaylistsAPI from 'features/search/pages/ThematicSearch/api/useThematicSearchPlaylists'
import { CinemaPlaylist } from 'features/search/pages/ThematicSearch/Cinema/CinemaPlaylist'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode, Position } from 'libs/location/types'
import { mockBuilder } from 'tests/mockBuilder'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -13,8 +14,6 @@ jest.unmock('react-native/Libraries/Animated/createAnimatedComponent')
jest.mock('libs/network/NetInfoWrapper')
jest.mock('libs/firebase/analytics/analytics')
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx
-
const mockLocationMode = LocationMode.AROUND_ME
const mockUserLocation: Position = { latitude: 2, longitude: 2 }
jest.mock('libs/location/LocationWrapper', () => ({
@@ -33,7 +32,11 @@ const useThematicSearchPlaylistsSpy = jest
playlists: [{ title: DEFAULT_PLAYLIST_TITLE, offers: DEFAULT_PLAYLIST_OFFERS }],
})
-describe('Cinema', () => {
+describe('CinemaPlaylist', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
+ })
+
it('should render playlist when algolia returns offers', async () => {
renderCinema()
diff --git a/src/features/search/pages/ThematicSearch/Films/FilmsPlaylist.native.test.tsx b/src/features/search/pages/ThematicSearch/Films/FilmsPlaylist.native.test.tsx
index 670ca0b4f8a..430269904fa 100644
--- a/src/features/search/pages/ThematicSearch/Films/FilmsPlaylist.native.test.tsx
+++ b/src/features/search/pages/ThematicSearch/Films/FilmsPlaylist.native.test.tsx
@@ -2,7 +2,8 @@ import React from 'react'
import * as useThematicSearchPlaylistsAPI from 'features/search/pages/ThematicSearch/api/useThematicSearchPlaylists'
import { FilmsPlaylist } from 'features/search/pages/ThematicSearch/Films/FilmsPlaylist'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode, Position } from 'libs/location/types'
import { mockBuilder } from 'tests/mockBuilder'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -13,8 +14,6 @@ jest.unmock('react-native/Libraries/Animated/createAnimatedComponent')
jest.mock('libs/network/NetInfoWrapper')
jest.mock('libs/firebase/analytics/analytics')
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx
-
const mockLocationMode = LocationMode.AROUND_ME
const mockUserLocation: Position = { latitude: 2, longitude: 2 }
jest.mock('libs/location/LocationWrapper', () => ({
@@ -33,7 +32,11 @@ const useThematicSearchPlaylistsSpy = jest
playlists: [{ title: DEFAULT_PLAYLIST_TITLE, offers: DEFAULT_OFFERS }],
})
-describe('Films', () => {
+describe('FilmsPlaylist', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
+ })
+
it('should render playlist when algolia returns offers', async () => {
renderFilms()
diff --git a/src/features/search/pages/ThematicSearch/Music/MusicPlaylist.native.test.tsx b/src/features/search/pages/ThematicSearch/Music/MusicPlaylist.native.test.tsx
index 43e92e394f7..335e512641f 100644
--- a/src/features/search/pages/ThematicSearch/Music/MusicPlaylist.native.test.tsx
+++ b/src/features/search/pages/ThematicSearch/Music/MusicPlaylist.native.test.tsx
@@ -2,7 +2,8 @@ import React from 'react'
import * as useThematicSearchPlaylistsAPI from 'features/search/pages/ThematicSearch/api/useThematicSearchPlaylists'
import { MusicPlaylist } from 'features/search/pages/ThematicSearch/Music/MusicPlaylist'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode, Position } from 'libs/location/types'
import { mockBuilder } from 'tests/mockBuilder'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
@@ -13,8 +14,6 @@ jest.unmock('react-native/Libraries/Animated/createAnimatedComponent')
jest.mock('libs/network/NetInfoWrapper')
jest.mock('libs/firebase/analytics/analytics')
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx
-
const mockLocationMode = LocationMode.AROUND_ME
const mockUserLocation: Position = { latitude: 2, longitude: 2 }
jest.mock('libs/location/LocationWrapper', () => ({
@@ -33,7 +32,11 @@ const useThematicSearchPlaylistsSpy = jest
playlists: [{ title: DEFAULT_PLAYLIST_TITLE, offers: DEFAULT_PLAYLIST_OFFERS }],
})
-describe('Music', () => {
+describe('MusicPlaylist', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
+ })
+
it('should render playlist when algolia returns offers', async () => {
renderMusic()
diff --git a/src/features/search/pages/ThematicSearch/ThematicSearchPlaylist.native.test.tsx b/src/features/search/pages/ThematicSearch/ThematicSearchPlaylist.native.test.tsx
index 3d87abbc11e..313f7e11b50 100644
--- a/src/features/search/pages/ThematicSearch/ThematicSearchPlaylist.native.test.tsx
+++ b/src/features/search/pages/ThematicSearch/ThematicSearchPlaylist.native.test.tsx
@@ -4,13 +4,12 @@ import { Referrals, ScreenNames } from 'features/navigation/RootNavigator/types'
import { ThematicSearchPlaylist } from 'features/search/pages/ThematicSearch/ThematicSearchPlaylist'
import { ThematicSearchPlaylistData } from 'features/search/pages/ThematicSearch/types'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { mockBuilder } from 'tests/mockBuilder'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { fireEvent, render, screen, act } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx
-
jest.mock('@shopify/flash-list', () => {
const ActualFlashList = jest.requireActual('@shopify/flash-list').FlashList
class MockFlashList extends ActualFlashList {
@@ -31,6 +30,10 @@ const DEFAULT_PLAYLIST_TITLE = 'Titre de la playlist'
const DEFAULT_PLAYLIST = { title: DEFAULT_PLAYLIST_TITLE, offers: DEFAULT_PLAYLIST_OFFERS }
describe('ThematicSearchPlaylist', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
+ })
+
it('should log ConsultOffer when pressing an item', async () => {
renderThematicSearchPlaylist(DEFAULT_PLAYLIST, 'thematicsearch', 'ThematicSearch')
diff --git a/src/features/search/pages/ThematicSearch/ThematicSearchPlaylistList.native.test.tsx b/src/features/search/pages/ThematicSearch/ThematicSearchPlaylistList.native.test.tsx
index a9ca312ff91..169571b09d1 100644
--- a/src/features/search/pages/ThematicSearch/ThematicSearchPlaylistList.native.test.tsx
+++ b/src/features/search/pages/ThematicSearch/ThematicSearchPlaylistList.native.test.tsx
@@ -2,13 +2,12 @@ import React from 'react'
import { ThematicSearchPlaylistList } from 'features/search/pages/ThematicSearch/ThematicSearchPlaylistList'
import { ThematicSearchPlaylistData } from 'features/search/pages/ThematicSearch/types'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { mockBuilder } from 'tests/mockBuilder'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { render, screen, cleanup } from 'tests/utils'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true) // WIP_NEW_OFFER_TILE in renderPassPlaylist.tsx
-
jest.mock('@shopify/flash-list', () => {
const ActualFlashList = jest.requireActual('@shopify/flash-list').FlashList
class MockFlashList extends ActualFlashList {
@@ -36,6 +35,10 @@ const DEFAULT_PLAYLIST_WITHOUT_HITS = {
}
describe('ThematicSearchPlaylistList', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_OFFER_TILE])
+ })
+
afterEach(cleanup)
it('should render playlist properly', async () => {
diff --git a/src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.native.test.tsx b/src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.native.test.tsx
index 5f5857302e3..61347d90dfe 100644
--- a/src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.native.test.tsx
+++ b/src/features/venueMap/components/FilterBannerContainer/FilterBannerContainer.native.test.tsx
@@ -1,19 +1,16 @@
import React from 'react'
import { FILTERS_VENUE_TYPE_MAPPING } from 'features/venueMap/constant'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { render, screen } from 'tests/utils'
import { FilterBannerContainer } from './FilterBannerContainer'
-const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag')
-
describe('FilterBannerConainer', () => {
- beforeEach(() => {
- useFeatureFlagSpy.mockReturnValue(true)
- })
-
it('should render FilterCategoriesBannerContainer if FF is enabled', async () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP_TYPE_FILTER_V2])
+
render()
await screen.findAllByTestId(/[A-Z]+Label/)
@@ -23,7 +20,7 @@ describe('FilterBannerConainer', () => {
})
it('should render SingleFilterBannerContainer if FF is disabled', async () => {
- useFeatureFlagSpy.mockReturnValueOnce(false)
+ setFeatureFlags()
render()
diff --git a/src/features/venueMap/hook/useShouldDisplayVenueMap.native.test.ts b/src/features/venueMap/hook/useShouldDisplayVenueMap.native.test.ts
index 001e881e92f..0fc9a8a7c52 100644
--- a/src/features/venueMap/hook/useShouldDisplayVenueMap.native.test.ts
+++ b/src/features/venueMap/hook/useShouldDisplayVenueMap.native.test.ts
@@ -1,11 +1,10 @@
import { useShouldDisplayVenueMap } from 'features/venueMap/hook/useShouldDisplayVenueMap'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { renderHook } from 'tests/utils'
-const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockedPlace: SuggestedPlace = {
label: 'Kourou',
info: 'Guyane',
@@ -26,6 +25,10 @@ jest.mock('libs/location', () => ({
}))
describe('useShouldDisplayVenueMap', () => {
+ beforeEach(() => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP])
+ })
+
it('should render venue map when user is located and feature flag enabled', () => {
const { result } = renderHook(useShouldDisplayVenueMap)
@@ -37,7 +40,7 @@ describe('useShouldDisplayVenueMap', () => {
})
it('should not render venue map when feature flag is disabled', () => {
- useFeatureFlagSpy.mockReturnValueOnce(false)
+ setFeatureFlags()
const { result } = renderHook(useShouldDisplayVenueMap)
expect(result.current).toEqual({
diff --git a/src/features/venueMap/hook/useShouldDisplayVenueMap.web.test.ts b/src/features/venueMap/hook/useShouldDisplayVenueMap.web.test.ts
index c742eae0458..bb49846d852 100644
--- a/src/features/venueMap/hook/useShouldDisplayVenueMap.web.test.ts
+++ b/src/features/venueMap/hook/useShouldDisplayVenueMap.web.test.ts
@@ -1,11 +1,10 @@
import { useShouldDisplayVenueMap } from 'features/venueMap/hook/useShouldDisplayVenueMap'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { LocationMode } from 'libs/location/types'
import { SuggestedPlace } from 'libs/place/types'
import { renderHook } from 'tests/utils/web'
-jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
-
const mockedPlace: SuggestedPlace = {
label: 'Kourou',
info: 'Guyane',
@@ -25,6 +24,8 @@ jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
describe('useShouldDisplayVenueMap', () => {
it('should not render venue map on web', () => {
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_VENUE_MAP])
+
const { result } = renderHook(useShouldDisplayVenueMap)
expect(result.current).toEqual({
diff --git a/src/ui/components/buttons/FavoriteButton.native.test.tsx b/src/ui/components/buttons/FavoriteButton.native.test.tsx
index 5fac39b9b7a..5b11c7c4206 100644
--- a/src/ui/components/buttons/FavoriteButton.native.test.tsx
+++ b/src/ui/components/buttons/FavoriteButton.native.test.tsx
@@ -8,7 +8,8 @@ import { favoriteResponseSnap } from 'features/favorites/fixtures/favoriteRespon
import { simulateBackend } from 'features/favorites/helpers/simulateBackend'
import { PlaylistType } from 'features/offer/enums'
import { analytics } from 'libs/analytics'
-import * as useFeatureFlagAPI from 'libs/firebase/firestore/featureFlags/useFeatureFlag'
+import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
+import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { mockAuthContextWithoutUser } from 'tests/AuthContextUtils'
import { queryCache, reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, fireEvent, render, screen, waitFor } from 'tests/utils'
@@ -40,7 +41,6 @@ mockedUseSnackBarContext.mockReturnValue({
showErrorSnackBar,
})
-const useFeatureFlagSpy = jest.spyOn(useFeatureFlagAPI, 'useFeatureFlag').mockReturnValue(true)
const useAddFavoriteSpy = jest.spyOn(useAddFavoriteAPI, 'useAddFavorite')
const useRemoveFavoriteSpy = jest.spyOn(useRemoveFavoriteAPI, 'useRemoveFavorite')
@@ -121,7 +121,8 @@ describe('', () => {
})
it('should not show favorite list modal when pressing favorite icon but feature flag is not activated', async () => {
- useFeatureFlagSpy.mockReturnValueOnce(false)
+ setFeatureFlags([RemoteStoreFeatureFlags.WIP_NEW_EXCLUSIVITY_MODULE])
+
renderFavoriteButton()
await act(async () => {