Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xlecunff-pass committed Feb 7, 2025
1 parent f68e8cb commit 4ec4a68
Show file tree
Hide file tree
Showing 115 changed files with 284 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ exports[`<SetAddress/> should render correctly 1`] = `
class="css-text-1rynq56 r-color-1rmcaf9 r-fontFamily-g6644c r-fontSize-cygvgh r-lineHeight-u6qrkm"
dir="ltr"
>
Entre ton adresse
Recherche et sélectionne ton adresse
</div>
</div>
</label>
Expand Down
2 changes: 2 additions & 0 deletions src/features/auth/context/useSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useQuery } from 'react-query'

import { api } from 'api/api'
import { SettingsResponse } from 'api/gen'
import { defaultSettings } from 'features/auth/fixtures/fixtures'
import { QueryKeys } from 'libs/queryKeys'

// arbitrary. Should not change that often though
Expand All @@ -13,6 +14,7 @@ export const useSettings = () => {
() => api.getNativeV1Settings(),
{
staleTime: STALE_TIME_APP_SETTINGS,
initialData: defaultSettings,
}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { SafeAreaProvider } from 'react-native-safe-area-context'

import { mockSettings } from 'features/auth/context/mockSettings'
import { render, checkAccessibilityFor, screen, waitFor } from 'tests/utils/web'

import { ForgottenPassword } from './ForgottenPassword'
Expand All @@ -13,6 +14,7 @@ jest.mock('uuid', () => {
v4: jest.fn(() => value++),
}
})
mockSettings()

describe('<ForgottenPassword/>', () => {
describe('Accessibility', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/features/auth/pages/login/Login.native.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => {
}
})

mockSettings({ isRecaptchaEnabled: false })

describe('<Login/>', () => {
beforeEach(() => {
setFeatureFlags([RemoteStoreFeatureFlags.WIP_ENABLE_GOOGLE_SSO])
Expand Down Expand Up @@ -644,7 +646,11 @@ describe('<Login/>', () => {

describe('Login with ReCatpcha', () => {
beforeAll(() => {
mockSettings()
mockSettings({ isRecaptchaEnabled: true })
})

afterAll(() => {
mockSettings({ isRecaptchaEnabled: false })
})

it('should not open reCAPTCHA challenge modal before clicking on login button', async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/features/auth/pages/signup/SignupForm.native.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SigninResponse,
UserProfileResponse,
} from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { PreValidationSignupStep } from 'features/auth/enums'
import { CURRENT_DATE, ELIGIBLE_AGE_DATE } from 'features/auth/fixtures/fixtures'
import * as LoginAndRedirectAPI from 'features/auth/pages/signup/helpers/useLoginAndRedirect'
Expand All @@ -33,6 +34,7 @@ import { SignupForm } from './SignupForm'
jest.mock('libs/campaign')
jest.mock('libs/react-native-device-info/getDeviceId')
jest.mock('libs/network/NetInfoWrapper')
mockSettings({ isRecaptchaEnabled: false })

const getModelSpy = jest.spyOn(DeviceInfo, 'getModel')
const getSystemNameSpy = jest.spyOn(DeviceInfo, 'getSystemName')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import { UserSuspensionDateResponse } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { mockServer } from 'tests/mswServer'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { checkAccessibilityFor, render, screen } from 'tests/utils/web'
Expand All @@ -11,6 +12,7 @@ jest.mock('libs/jwt/jwt')

jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
mockSettings()

describe('<SuspendedAccountUponUserRequest/>', () => {
describe('Accessibility', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { useDepositAmountsByAge } from 'shared/user/useDepositAmountsByAge'
Expand All @@ -13,6 +14,7 @@ mockUseDepositAmountsByAge.mockReturnValue({ eighteenYearsOldDeposit: '300 €'

jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
mockSettings()

describe('<EighteenBirthday/>', () => {
describe('Accessibility', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { RemoteStoreFeatureFlags } from 'libs/firebase/firestore/types'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
Expand All @@ -9,6 +10,7 @@ import { RecreditBirthdayNotification } from './RecreditBirthdayNotification'

jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
mockSettings()

describe('<RecreditBirthdayNotification/>', () => {
describe('Accessibility', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { BookingState, Step } from 'features/bookOffer/context/reducer'
import { mockOffer } from 'features/bookOffer/fixtures/offer'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
Expand All @@ -23,6 +24,7 @@ jest.mock('features/bookOffer/context/useBookingContext', () => ({
dismissModal: mockDismissModal,
})),
}))
mockSettings()

jest.mock('features/bookOffer/helpers/useBookingStock', () => ({
useBookingStock: jest.fn(() => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import { OfferResponseV2 } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
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'
Expand All @@ -14,6 +15,7 @@ const mockStep = Step.HOUR
const mockDuoStep = Step.DUO

const mockDispatch = jest.fn()
mockSettings()

const mockUseBookingContext: jest.Mock<IBookingContext> = jest.fn()
mockUseBookingContext.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { BookPricesChoice } from 'features/bookOffer/components/BookPricesChoice'
import { BookingState, initialBookingState } from 'features/bookOffer/context/reducer'
import { mockStocks } from 'features/bookOffer/fixtures/stocks'
Expand All @@ -25,6 +26,7 @@ const mockCreditOffer = 50000
jest.mock('features/offer/helpers/useHasEnoughCredit/useHasEnoughCredit', () => ({
useCreditForOffer: jest.fn(() => mockCreditOffer),
}))
mockSettings()

describe('BookPricesChoice', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

import { OfferResponseV2 } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { Step } from 'features/bookOffer/context/reducer'
import { useBookingContext } from 'features/bookOffer/context/useBookingContext'
import { offerResponseSnap } from 'features/offer/fixtures/offerResponse'
Expand All @@ -13,6 +14,7 @@ import { render, screen, waitFor } from 'tests/utils'

import { BookingEventChoices } from './BookingEventChoices'

mockSettings()
jest.mock('features/auth/context/AuthContext')

const mockUseBooking = useBookingContext as jest.Mock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

import { OfferResponseV2, SubcategoryIdEnum } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { initialBookingState } from 'features/bookOffer/context/reducer'
import { useBookingContext } from 'features/bookOffer/context/useBookingContext'
import { mockOffer as baseOffer } from 'features/bookOffer/fixtures/offer'
Expand All @@ -17,6 +18,7 @@ const randomDatetime = '2020-12-01T00:00:00Z'
jest.mock('features/bookOffer/context/useBookingContext')
jest.mock('features/bookOffer/helpers/useBookingStock')
jest.mock('libs/address/useFormatFullAddress')
mockSettings()
const mockedUseBooking = jest.mocked(useBookingContext)
const mockedUseBookingStock = jest.mocked(useBookingStock)

Expand Down
3 changes: 3 additions & 0 deletions src/features/bookOffer/components/PriceLine.native.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { PriceLine } from 'features/bookOffer/components/PriceLine'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { render, screen } from 'tests/utils'

const attributes = ['VOSTFR', '3D', 'IMAX']

mockSettings()

describe('<PriceLine />', () => {
beforeEach(() => {
setFeatureFlags()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Share } from 'react-native'

import { reset, useRoute } from '__mocks__/@react-navigation/native'
import reactNativeInAppReview from '__mocks__/react-native-in-app-review'
import { mockSettings } from 'features/auth/context/mockSettings'
import { useReviewInAppInformation } from 'features/bookOffer/helpers/useReviewInAppInformation'
import { analytics } from 'libs/analytics/provider'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
Expand All @@ -11,6 +12,7 @@ import { act, render, screen, userEvent } from 'tests/utils'

import { BookingConfirmation } from './BookingConfirmation'

mockSettings()
jest.mock('react-native/Libraries/Animated/animations/TimingAnimation.js')

jest.mock('features/offer/api/useOffer')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { navigate, useRoute } from '__mocks__/@react-navigation/native'
import { ApiError } from 'api/ApiError'
import { RecommendationApiParams, SubcategoryIdEnum } from 'api/gen'
import * as Auth from 'features/auth/context/AuthContext'
import { mockSettings } from 'features/auth/context/mockSettings'
import * as useBookOfferMutation from 'features/bookOffer/api/useBookOfferMutation'
import { BookingState, Step } from 'features/bookOffer/context/reducer'
import { mockOffer as baseOffer } from 'features/bookOffer/fixtures/offer'
Expand All @@ -22,6 +23,7 @@ import { SnackBarHelperSettings } from 'ui/components/snackBar/types'

import { BookingOfferModalComponent } from './BookingOfferModal'

mockSettings()
jest.mock('libs/campaign')

const mockDismissModal = jest.fn()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import type { BookingsResponse } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { BookingPropertiesSection } from 'features/bookings/components/BookingPropertiesSection'
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import { Booking } from 'features/bookings/types'
Expand All @@ -13,6 +14,7 @@ import { render, screen, waitFor } from 'tests/utils'
jest.mock('features/auth/context/AuthContext')

jest.mock('libs/firebase/analytics/analytics')
mockSettings()

describe('<BookingPropertiesSection />', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UseQueryResult } from 'react-query'

import { useRoute } from '__mocks__/@react-navigation/native'
import { BookingReponse, SubcategoriesResponseModelv2 } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import * as ongoingOrEndedBookingAPI from 'features/bookings/api/useOngoingOrEndedBooking'
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import { Booking } from 'features/bookings/types'
Expand All @@ -28,6 +29,7 @@ const mockUseNetInfoContext = jest.spyOn(useNetInfoContextDefault, 'useNetInfoCo

jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
mockSettings()

describe('BookingDetails', () => {
mockUseNetInfoContext.mockReturnValue({ isConnected: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'

import { CategoryIdEnum, NativeCategoryIdEnumv2, SubcategoryIdEnum } from 'api/gen'
import { mockSettings } from 'features/auth/context/mockSettings'
import { bookingsSnap } from 'features/bookings/fixtures/bookingsSnap'
import { setFeatureFlags } from 'libs/firebase/firestore/featureFlags/__tests__/setFeatureFlags'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
Expand All @@ -10,6 +11,7 @@ import { EndedBookings } from './EndedBookings'

jest.mock('libs/firebase/analytics/analytics')
jest.mock('libs/firebase/remoteConfig/remoteConfig.services')
mockSettings()

const mockBookings = { ...bookingsSnap }
jest.mock('features/bookings/api/useBookings', () => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react'
import { Button } from 'react-native'

import { mockSettings } from 'features/auth/context/mockSettings'
import { render, screen } from 'tests/utils/web'

import { ChronicleOfferInfo } from './ChronicleOfferInfo.web'

mockSettings()

describe('ChronicleOfferInfo', () => {
it('should render correctly', () => {
render(<ChronicleOfferInfo imageUrl="http://image.jpeg" price="12€" title="lorem ipsum" />)
Expand Down
2 changes: 2 additions & 0 deletions src/features/cookies/pages/CookiesDetails.web.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react'

import { mockSettings } from 'features/auth/context/mockSettings'
import { CookiesDetails } from 'features/cookies/pages/CookiesDetails'
import { reactQueryProviderHOC } from 'tests/reactQueryProviderHOC'
import { act, checkAccessibilityFor, render } from 'tests/utils/web'

jest.mock('features/profile/api/useUpdateProfileMutation')
mockSettings()

// Fix the error "IDs used in ARIA and labels must be unique (duplicate-id-aria)" because the UUIDV4 mock return "testUuidV4"
jest.mock('uuid', () => {
Expand Down
Loading

0 comments on commit 4ec4a68

Please sign in to comment.