diff --git a/.env.local b/.env.local index 8079ea20e6e..85188a85db2 100644 --- a/.env.local +++ b/.env.local @@ -33,12 +33,9 @@ ZENDESK_PRIVACY_URL='https://www.pagopa.it/it/privacy-policy-assistenza/' MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f' # Test overlay caption, if the string is nonempty will be displayed in the TestOverlay # TEST_OVERLAY_CAPTION='Functionality name here!' -BONUS_VACANZE_ENABLED=YES MYPORTAL_ENABLED=NO # enable playgrounds inside developer section PLAYGROUNDS_ENABLED=YES -# BPD configuration -BPD_ENABLED=YES # endpoint BPD API BPD_API_URL_PREFIX='http://127.0.0.1:3000/bonus' BPD_API_SIT='https://api-io.dev.cstar.pagopa.it' @@ -53,8 +50,6 @@ SICILIAVOLA_ENABLED=NO ZENDESK_ENABLED=YES # CGN new merchants features CGN_MERCHANTS_V2_ENABLED=NO -# Opt-in payments method -BPD_OPT_IN_PAYMENT_METHODS = YES # Ukraine donation UA_DONATIONS_ENABLED=YES # FIMS (Federated Identity Management System) feature diff --git a/.env.production b/.env.production index 3fceccceccc..38c252e171a 100644 --- a/.env.production +++ b/.env.production @@ -33,12 +33,9 @@ ZENDESK_PRIVACY_URL='https://www.pagopa.it/it/privacy-policy-assistenza/' MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f' # Test overlay caption, if the string is nonempty will be displayed in the TestOverlay # TEST_OVERLAY_CAPTION='Functionality name here!' -BONUS_VACANZE_ENABLED=YES MYPORTAL_ENABLED=NO # enable playgrounds inside developer section PLAYGROUNDS_ENABLED=YES -# BPD configuration -BPD_ENABLED=YES # endpoint BPD API BPD_API_URL_PREFIX=https://api-io.cstar.pagopa.it BPD_API_SIT='https://api-io.dev.cstar.pagopa.it' @@ -53,8 +50,6 @@ SICILIAVOLA_ENABLED=NO ZENDESK_ENABLED=YES # CGN new merchants features CGN_MERCHANTS_V2_ENABLED=NO -# Opt-in payments method -BPD_OPT_IN_PAYMENT_METHODS = YES # Ukraine donation UA_DONATIONS_ENABLED=YES # FIMS (Federated Identity Management System) feature diff --git a/jestGlobalExtendExpectImport.ts b/jestGlobalExtendExpectImport.ts new file mode 100644 index 00000000000..dd5adc27ba6 --- /dev/null +++ b/jestGlobalExtendExpectImport.ts @@ -0,0 +1,9 @@ +// for TSC to correctly read the type definition +// exported by this lib, it is necessary to import it +// in a `.ts` file, otherwise it will be ignored + +// this file is strictly for TS to recognize the type definition, +// avoiding the malpractice of having to import it in a test, +// since the import is already done in the jest config files + +import "@testing-library/jest-native/extend-expect"; diff --git a/ts/config.ts b/ts/config.ts index 92ede32ee6c..bb504c21df6 100644 --- a/ts/config.ts +++ b/ts/config.ts @@ -54,8 +54,6 @@ export const isDebugBiometricIdentificationEnabled = export const myPortalEnabled: boolean = Config.MYPORTAL_ENABLED === "YES"; -export const bpdEnabled: boolean = Config.BPD_ENABLED === "YES"; - export const bpdApiUrlPrefix: string = Config.BPD_API_URL_PREFIX; export const bpdApiSitUrlPrefix: string = Config.BPD_API_SIT; @@ -77,10 +75,6 @@ export const zendeskEnabled: boolean = Config.ZENDESK_ENABLED === "YES"; // CGN new merchants features export const cgnMerchantsV2Enabled = Config.CGN_MERCHANTS_V2_ENABLED === "YES"; -// Opt-in payments method -export const bpdOptInPaymentMethodsEnabled = - Config.BPD_OPT_IN_PAYMENT_METHODS === "YES"; - // Ukraine donation export const uaDonationsEnabled = Config.UA_DONATIONS_ENABLED === "YES"; diff --git a/ts/features/bonus/__mock__/availableBonuses.ts b/ts/features/bonus/__mock__/availableBonuses.ts index bd774940972..660a313eb09 100644 --- a/ts/features/bonus/__mock__/availableBonuses.ts +++ b/ts/features/bonus/__mock__/availableBonuses.ts @@ -1,7 +1,6 @@ -import { BonusAvailable } from "../../../../definitions/content/BonusAvailable"; -import { BonusesAvailable } from "../../../../definitions/content/BonusesAvailable"; -import { ID_BPD_TYPE, ID_CGN_TYPE } from "../common/utils"; import { BonusVisibilityEnum } from "../../../../definitions/content/BonusVisibility"; +import { BonusesAvailable } from "../../../../definitions/content/BonusesAvailable"; +import { ID_CGN_TYPE } from "../common/utils"; export const contentBonusVacanzeIT = `#### Chi può richiederlo? @@ -68,42 +67,8 @@ This is the process in app: - if you confirm the request, IO generates your Bonus Vacanze; - once activated, your bonus will be visible in the Payments section of the app. `; -export const bpdBonus: BonusAvailable = { - id_type: ID_BPD_TYPE, - it: { - name: "Cashback", - description: - "Fino a 500€ a nucleo familiare per andare in vacanza in Italia", - subtitle: - "L'incentivo per supportare il settore del turismo dopo il lockdown richiesto dal COVID-19", - title: "Richiesta Bonus Vacanze", - content: contentBonusVacanzeIT, - tos_url: "https://io.italia.it/app-content/bonus_vacanze_tos.html" - }, - en: { - name: "Cashback", - description: "Up to € 500 per family to go on holiday in Italy", - subtitle: - "The incentive established to support tourism after the lockdown due to the Coronavirus emergency.", - title: "Bonus Vacanze Request", - content: contentBonusVacanzeEN, - tos_url: "https://io.italia.it/app-content/bonus_vacanze_tos.html" - }, - service_id: "01EB8AXKNV6NMSP2R25KSGF743", - is_active: false, - hidden: true, - visibility: BonusVisibilityEnum.visible, - valid_from: new Date("2020-07-01T00:00:00.000Z"), - valid_to: new Date("2020-12-31T00:00:00.000Z"), - cover: - "https://raw.githubusercontent.com/pagopa/io-services-metadata/master/bonus/vacanze/logo/logo_BonusVacanze.png", - sponsorship_description: "Agenzia delle Entrate", - sponsorship_cover: - "https://raw.githubusercontent.com/pagopa/io-services-metadata/master/bonus/vacanze/logo/logo_AgenziaEntrate.png" -}; export const availableBonuses: BonusesAvailable = [ - bpdBonus, { id_type: ID_CGN_TYPE, it: { diff --git a/ts/features/bonus/bpd/analytics/index.ts b/ts/features/bonus/bpd/analytics/index.ts deleted file mode 100644 index 799b41746b7..00000000000 --- a/ts/features/bonus/bpd/analytics/index.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { getType } from "typesafe-actions"; -import { mixpanel } from "../../../../mixpanel"; -import { Action } from "../../../../store/actions/types"; -import { bpdEnabled } from "../../../../config"; -import { - bpdDeleteUserFromProgram, - bpdEnrollUserToProgram, - bpdOnboardingAcceptDeclaration, - bpdOnboardingCancel, - bpdOnboardingCompleted, - bpdOnboardingStart, - bpdUnsubscribeCompleted, - bpdUpdateOptInStatusMethod, - bpdUserActivate -} from "../store/actions/onboarding"; -import { - bpdIbanInsertionCancel, - bpdIbanInsertionContinue, - bpdIbanInsertionResetScreen, - bpdIbanInsertionStart, - bpdUpsertIban -} from "../store/actions/iban"; -import { - bpdTransactionsLoad, - bpdTransactionsLoadRequiredData -} from "../store/actions/transactions"; -import { bpdAllData, bpdLoadActivationStatus } from "../store/actions/details"; -import { bpdSelectPeriod } from "../store/actions/selectedPeriod"; -import { - bpdPaymentMethodActivation, - bpdUpdatePaymentMethodActivation -} from "../store/actions/paymentMethods"; -import { - optInPaymentMethodsCompleted, - optInPaymentMethodsDeletionChoice, - optInPaymentMethodsFailure, - optInPaymentMethodsShowChoice, - optInPaymentMethodsStart -} from "../store/actions/optInPaymentMethods"; -import { getError } from "../../../../utils/errors"; - -const trackAction = - (mp: NonNullable) => - // eslint-disable-next-line complexity - (action: Action): Promise => { - switch (action.type) { - // onboarding - case getType(bpdEnrollUserToProgram.request): - case getType(bpdDeleteUserFromProgram.success): - case getType(bpdDeleteUserFromProgram.request): - case getType(bpdUnsubscribeCompleted): - case getType(bpdOnboardingStart): - case getType(bpdUserActivate): - case getType(bpdOnboardingCancel): - case getType(bpdOnboardingCompleted): - case getType(bpdOnboardingAcceptDeclaration): - return mp.track(action.type); - case getType(bpdEnrollUserToProgram.success): - return mp.track(action.type, { bpdEnroll: action.payload.enabled }); - case getType(bpdDeleteUserFromProgram.failure): - case getType(bpdEnrollUserToProgram.failure): - case getType(bpdAllData.failure): - return mp.track(action.type, { reason: action.payload.message }); - - // IBAN - case getType(bpdIbanInsertionStart): - case getType(bpdIbanInsertionContinue): - case getType(bpdIbanInsertionCancel): - case getType(bpdIbanInsertionResetScreen): - case getType(bpdUpsertIban.request): - return mp.track(action.type); - case getType(bpdUpsertIban.success): - return mp.track(action.type, { ibanStatus: action.payload.status }); - case getType(bpdUpsertIban.failure): - return mp.track(action.type, { reason: action.payload.message }); - - // transactions - case getType(bpdTransactionsLoad.failure): - case getType(bpdTransactionsLoadRequiredData.failure): - return mp.track(action.type, { - awardPeriodId: action.payload.awardPeriodId, - reason: action.payload.error.message - }); - case getType(bpdTransactionsLoad.request): - case getType(bpdTransactionsLoadRequiredData.request): - case getType(bpdTransactionsLoadRequiredData.success): - return mp.track(action.type, { awardPeriodId: action.payload }); - case getType(bpdTransactionsLoad.success): - case getType(bpdSelectPeriod): // SelectedPeriod - return mp.track(action.type, { - awardPeriodId: action.payload.awardPeriodId - }); - // CashBack details - case getType(bpdAllData.request): - case getType(bpdAllData.success): - case getType(bpdLoadActivationStatus.request): - return mp.track(action.type); - case getType(bpdLoadActivationStatus.success): - return mp.track(action.type, { - enabled: action.payload.enabled, - hasTechnicalIban: action.payload.technicalAccount !== undefined, - optInStatus: action.payload.optInStatus - }); - case getType(bpdLoadActivationStatus.failure): - return mp.track(action.type, { reason: action.payload.message }); - - // PaymentMethod - case getType(bpdPaymentMethodActivation.request): - case getType(bpdUpdatePaymentMethodActivation.request): - case getType(bpdPaymentMethodActivation.success): - case getType(bpdUpdatePaymentMethodActivation.success): - case getType(bpdPaymentMethodActivation.failure): - case getType(bpdUpdatePaymentMethodActivation.failure): - return mp.track(action.type); - - // Opt-in payment methods - case getType(optInPaymentMethodsStart): - case getType(optInPaymentMethodsCompleted): - case getType(optInPaymentMethodsFailure): - case getType(optInPaymentMethodsDeletionChoice): - case getType(optInPaymentMethodsShowChoice.request): - return mp.track(action.type); - case getType(optInPaymentMethodsShowChoice.success): - return mp.track(action.type, { shouldShow: action.payload }); - case getType(optInPaymentMethodsShowChoice.failure): - case getType(bpdUpdateOptInStatusMethod.failure): - return mp.track(action.type, { reason: getError(action.payload) }); - case getType(bpdUpdateOptInStatusMethod.request): - case getType(bpdUpdateOptInStatusMethod.success): - return mp.track(action.type, { status: action.payload }); - } - return Promise.resolve(); - }; - -const emptyTracking = (_: NonNullable) => (__: Action) => - Promise.resolve(); -export default bpdEnabled ? trackAction : emptyTracking; diff --git a/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx b/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx index c61ea471de5..811bfaa47ae 100644 --- a/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx +++ b/ts/features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer.tsx @@ -2,15 +2,11 @@ import { useNavigation } from "@react-navigation/native"; import * as React from "react"; import { useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; +import { isError, isReady } from "../../../../../common/model/RemoteValue"; import LoadingSpinnerOverlay from "../../../../../components/LoadingSpinnerOverlay"; import { LightModalContext } from "../../../../../components/ui/LightModal"; -import { bpdOptInPaymentMethodsEnabled } from "../../../../../config"; import I18n from "../../../../../i18n"; -import ROUTES from "../../../../../navigation/routes"; import { useIOSelector } from "../../../../../store/hooks"; -import { bpdRemoteConfigSelector } from "../../../../../store/reducers/backendStatus"; -import { isError, isReady } from "../../../../../common/model/RemoteValue"; -import BPD_ROUTES from "../../navigation/routes"; import { optInPaymentMethodsShowChoice } from "../../store/actions/optInPaymentMethods"; import { showOptInChoiceSelector } from "../../store/reducers/details/activation/ui"; import { bpdLastUpdateSelector } from "../../store/reducers/details/lastUpdate"; @@ -20,18 +16,11 @@ const BpdOptInPaymentMethodsContainer = () => { const navigation = useNavigation(); const { showModal, hideModal } = useContext(LightModalContext); const [showOptInChecked, setShowOptInChecked] = useState(false); - const bpdRemoteConfig = useIOSelector(bpdRemoteConfigSelector); const showOptInChoice = useIOSelector(showOptInChoiceSelector); const bpdLastUpdate = useIOSelector(bpdLastUpdateSelector); - const isOptInPaymentMethodsEnabled = - bpdRemoteConfig?.opt_in_payment_methods_v2 && bpdOptInPaymentMethodsEnabled; useEffect(() => { - if ( - isOptInPaymentMethodsEnabled && - !showOptInChecked && - !isReady(showOptInChoice) - ) { + if (!showOptInChecked && !isReady(showOptInChoice)) { setShowOptInChecked(true); // Starts the optInShouldShowChoiceHandler saga dispatch(optInPaymentMethodsShowChoice.request()); @@ -43,31 +32,13 @@ const BpdOptInPaymentMethodsContainer = () => { /> ); } - }, [ - isOptInPaymentMethodsEnabled, - dispatch, - showOptInChecked, - bpdLastUpdate, - showModal, - showOptInChoice - ]); + }, [dispatch, showOptInChecked, bpdLastUpdate, showModal, showOptInChoice]); useEffect(() => { - if ( - isOptInPaymentMethodsEnabled && - (isReady(showOptInChoice) || isError(showOptInChoice)) - ) { + if (isReady(showOptInChoice) || isError(showOptInChoice)) { hideModal(); - if (isReady(showOptInChoice) && showOptInChoice.value) { - navigation.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.MAIN, - params: { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CASHBACK_UPDATE - } - }); - } } - }, [isOptInPaymentMethodsEnabled, hideModal, showOptInChoice, navigation]); + }, [hideModal, showOptInChoice, navigation]); return <>; }; diff --git a/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx b/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx index 777ccbdcf07..5bf2e4268ae 100644 --- a/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx +++ b/ts/features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent.tsx @@ -5,7 +5,6 @@ import * as React from "react"; import { connect } from "react-redux"; import { Dispatch } from "redux"; import { GlobalState } from "../../../../../store/reducers/types"; -import { navigateToBpdDetails } from "../../navigation/actions"; import { bpdSelectPeriod } from "../../store/actions/selectedPeriod"; import { bpdPeriodsAmountWalletVisibleSelector } from "../../store/reducers/details/combiner"; import { BpdPeriodWithInfo } from "../../store/reducers/details/periods"; @@ -51,7 +50,6 @@ const BpdCardsInWalletContainer = (props: Props) => ( const mapDispatchToProps = (dispatch: Dispatch) => ({ navigateToCashbackDetails: (period: BpdPeriodWithInfo) => { dispatch(bpdSelectPeriod(period)); - navigateToBpdDetails(period); } }); diff --git a/ts/features/bonus/bpd/navigation/actions.ts b/ts/features/bonus/bpd/navigation/actions.ts deleted file mode 100644 index dedf66c9d31..00000000000 --- a/ts/features/bonus/bpd/navigation/actions.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { CommonActions } from "@react-navigation/native"; -import NavigationService from "../../../../navigation/NavigationService"; -import ROUTES from "../../../../navigation/routes"; -import { BpdPeriodWithInfo } from "../store/reducers/details/periods"; -import BPD_ROUTES from "./routes"; - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingLoadActivationStatus = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.LOAD_CHECK_ACTIVATION_STATUS - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingInformationTos = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.INFORMATION_TOS - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingDeclaration = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.DECLARATION - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingLoadActivate = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.LOAD_ACTIVATE_BPD - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingEnrollPaymentMethod = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.ENROLL_PAYMENT_METHODS - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingNoPaymentMethods = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.NO_PAYMENT_METHODS - } - }) - ); - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdOnboardingErrorPaymentMethods = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.ONBOARDING.MAIN, - params: { - screen: BPD_ROUTES.ONBOARDING.ERROR_PAYMENT_METHODS - } - }) - ); - -// IBAN - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdIbanInsertion = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.IBAN - }) - ); - -// Details - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdDetails = (specificPeriod?: BpdPeriodWithInfo) => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.DETAILS_MAIN, - params: { - screen: BPD_ROUTES.DETAILS, - params: { specificPeriod } - } - }) - ); - -// Transactions - -/** - * @deprecated Do not use this method when you have access to a navigation prop or useNavigation since it will behave differently, - * and many helper methods specific to screens won't be available. - */ -export const navigateToBpdTransactions = () => - NavigationService.dispatchNavigationAction( - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.DETAILS_MAIN, - params: { - screen: BPD_ROUTES.TRANSACTIONS - } - }) - ); - -// OPT-IN -export const navigateToOptInPaymentMethodsChoiceScreen = () => - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.MAIN, - params: { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CHOICE - } - }); - -export const navigateToOptInPaymentMethodsThankYouDeleteMethodsScreen = () => - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.MAIN, - params: { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.THANK_YOU_DELETE_METHOD - } - }); - -export const navigateToOptInPaymentMethodsThankYouKeepMethodsScreen = () => - CommonActions.navigate(ROUTES.WALLET_NAVIGATOR, { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.MAIN, - params: { - screen: BPD_ROUTES.OPT_IN_PAYMENT_METHODS.THANK_YOU_KEEP_METHOD - } - }); diff --git a/ts/features/bonus/bpd/navigation/navigator.tsx b/ts/features/bonus/bpd/navigation/navigator.tsx deleted file mode 100644 index 897a71ebb68..00000000000 --- a/ts/features/bonus/bpd/navigation/navigator.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import * as React from "react"; -import { createStackNavigator } from "@react-navigation/stack"; -import BpdDetailsScreen from "../screens/details/BpdDetailsScreen"; -import BpdTransactionsRouterScreen from "../screens/details/transaction/v2/BpdTransactionsRouterScreen"; -import CtaLandingScreen from "../screens/onboarding/BpdCTAStartOnboardingScreen"; -import BpdInformationScreen from "../screens/onboarding/BpdInformationScreen"; -import DeclarationScreen from "../screens/onboarding/declaration/DeclarationScreen"; -import EnrollPaymentMethodsScreen from "../screens/onboarding/EnrollPaymentMethodsScreen"; -import ErrorPaymentMethodsScreen from "../screens/onboarding/ErrorPaymentMethodsScreen"; -import LoadActivateBpdScreen from "../screens/onboarding/LoadActivateBpdScreen"; -import LoadBpdActivationStatus from "../screens/onboarding/LoadBpdActivationStatus"; -import NoPaymentMethodsAvailableScreen from "../screens/onboarding/NoPaymentMethodsAvailableScreen"; -import OptInPaymentMethodsCashbackUpdateScreen from "../screens/optInPaymentMethods/OptInPaymentMethodsCashbackUpdateScreen"; -import OptInPaymentMethodsChoiceScreen from "../screens/optInPaymentMethods/OptInPaymentMethodsChoiceScreen"; -import OptInPaymentMethodsThankYouDeleteMethodsScreen from "../screens/optInPaymentMethods/OptInPaymentMethodsThankYouDeleteMethodsScreen"; -import OptInPaymentMethodsThankYouKeepMethodsScreen from "../screens/optInPaymentMethods/OptInPaymentMethodsThankYouKeepMethodsScreen"; -import { isGestureEnabled } from "../../../../utils/navigation"; -import BPD_ROUTES from "./routes"; -import { - BpdDetailsParamsList, - BpdOnboardingParamsList, - BpdOptInParamsList -} from "./params"; - -const BpdOnboardingStack = createStackNavigator(); - -export const BpdOnboardingNavigator = () => ( - - - - - - - - - - -); -const BpdDetailsStack = createStackNavigator(); -export const BpdDetailsNavigator = () => ( - - - - -); - -const OptInPaymentMethodStack = createStackNavigator(); - -export const OptInPaymentMethodNavigator = () => ( - - - - - - -); diff --git a/ts/features/bonus/bpd/navigation/params.ts b/ts/features/bonus/bpd/navigation/params.ts deleted file mode 100644 index e8448a56f24..00000000000 --- a/ts/features/bonus/bpd/navigation/params.ts +++ /dev/null @@ -1,28 +0,0 @@ -import BPD_ROUTES from "./routes"; - -export type BpdOnboardingParamsList = { - [BPD_ROUTES.ONBOARDING.LOAD_CHECK_ACTIVATION_STATUS]: undefined; - [BPD_ROUTES.ONBOARDING.INFORMATION_TOS]: undefined; - [BPD_ROUTES.ONBOARDING.DECLARATION]: undefined; - [BPD_ROUTES.ONBOARDING.LOAD_ACTIVATE_BPD]: undefined; - [BPD_ROUTES.ONBOARDING.ENROLL_PAYMENT_METHODS]: undefined; - [BPD_ROUTES.ONBOARDING.NO_PAYMENT_METHODS]: undefined; - [BPD_ROUTES.ONBOARDING.ERROR_PAYMENT_METHODS]: undefined; - [BPD_ROUTES.CTA_START_BPD]: undefined; -}; - -export type BpdDetailsParamsList = { - [BPD_ROUTES.DETAILS]: undefined; - [BPD_ROUTES.TRANSACTIONS]: undefined; -}; - -export type BpdIbanParamsList = { - [BPD_ROUTES.IBAN]: undefined; -}; - -export type BpdOptInParamsList = { - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CASHBACK_UPDATE]: undefined; - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CHOICE]: undefined; - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.THANK_YOU_DELETE_METHOD]: undefined; - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.THANK_YOU_KEEP_METHOD]: undefined; -}; diff --git a/ts/features/bonus/bpd/navigation/routes.ts b/ts/features/bonus/bpd/navigation/routes.ts deleted file mode 100644 index 006e3543472..00000000000 --- a/ts/features/bonus/bpd/navigation/routes.ts +++ /dev/null @@ -1,32 +0,0 @@ -const BPD_ROUTES = { - MAIN: "BPD_ROUTES_MAIN", - - ONBOARDING: { - MAIN: "BPD_ONBOARDING_ROUTES_MAIN", - LOAD_CHECK_ACTIVATION_STATUS: "BPD_LOAD_CHECK_ACTIVATION_STATUS", - INFORMATION_TOS: "BPD_INFORMATION_TOS", - DECLARATION: "BPD_DECLARATION", - LOAD_ACTIVATE_BPD: "BPD_LOAD_ACTIVATE_BPD", - ENROLL_PAYMENT_METHODS: "BPD_ENROLL_PAYMENT_METHODS", - NO_PAYMENT_METHODS: "BPD_NO_PAYMENT_METHODS", - ERROR_PAYMENT_METHODS: "ERROR_PAYMENT_METHODS" - }, - IBAN_MAIN: "BPD_IBAN_ROUTES_MAIN", - IBAN: "BPD_IBAN", - - DETAILS_MAIN: "BPD_DETAILS_ROUTES_MAIN", - DETAILS: "BPD_DETAILS", - TRANSACTIONS: "BPD_TRANSACTIONS", - // used from message CTA - CTA_START_BPD: "CTA_START_BPD", - CTA_BPD_IBAN_EDIT: "CTA_BPD_IBAN_EDIT", - OPT_IN_PAYMENT_METHODS: { - MAIN: "OPT_IN_PAYMENT_METHODS_MAIN", - CASHBACK_UPDATE: "OPT_IN_PAYMENT_METHODS_CASHBACK_UPDATE", - CHOICE: "OPT_IN_PAYMENT_METHODS_CHOICE", - THANK_YOU_KEEP_METHOD: "OPT_IN_PAYMENT_METHODS_THANK_YOU_KEEP_METHODS", - THANK_YOU_DELETE_METHOD: "OPT_IN_PAYMENT_METHODS_THANK_YOU_DELETE_METHODS" - } -} as const; - -export default BPD_ROUTES; diff --git a/ts/features/bonus/bpd/saga/__tests__/onboarding/startOnboarding.test.ts b/ts/features/bonus/bpd/saga/__tests__/onboarding/startOnboarding.test.ts deleted file mode 100644 index 137eaa66c58..00000000000 --- a/ts/features/bonus/bpd/saga/__tests__/onboarding/startOnboarding.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as E from "fp-ts/lib/Either"; -import { testSaga } from "redux-saga-test-plan"; -import NavigationService from "../../../../../../navigation/NavigationService"; -import { fetchWalletsRequest } from "../../../../../../store/actions/wallet/wallets"; -import { - navigateToBpdOnboardingDeclaration, - navigateToBpdOnboardingInformationTos, - navigateToBpdOnboardingLoadActivationStatus -} from "../../../navigation/actions"; -import { - bpdOnboardingAcceptDeclaration, - bpdUserActivate -} from "../../../store/actions/onboarding"; -import { - bpdStartOnboardingWorker, - isBpdEnabled -} from "../../orchestration/onboarding/startOnboarding"; - -jest.mock("react-native-share", () => ({ - open: jest.fn() -})); - -describe("bpdStartOnboardingWorker", () => { - it("should onboard a user", () => { - const notLoadingScreenRoute = "NotLoadingScreenRoute"; - - testSaga(bpdStartOnboardingWorker) - .next() - .call(NavigationService.getCurrentRouteName) - .next(notLoadingScreenRoute) - .call(navigateToBpdOnboardingLoadActivationStatus) - .next() - .call(isBpdEnabled) - .next(E.right(true)) - .put(fetchWalletsRequest()) - .next() - .call(navigateToBpdOnboardingInformationTos) - .next() - .take(bpdUserActivate) - .next() - .call(navigateToBpdOnboardingDeclaration) - .next() - .take(bpdOnboardingAcceptDeclaration); - }); -}); diff --git a/ts/features/bonus/bpd/saga/index.ts b/ts/features/bonus/bpd/saga/index.ts index 4faf1c157ea..f2ce5a2cdca 100644 --- a/ts/features/bonus/bpd/saga/index.ts +++ b/ts/features/bonus/bpd/saga/index.ts @@ -1,10 +1,7 @@ import { SagaIterator } from "redux-saga"; import { takeEvery, takeLatest } from "typed-redux-saga/macro"; import { getType } from "typesafe-actions"; -import { - bpdApiUrlPrefix, - bpdOptInPaymentMethodsEnabled -} from "../../../../config"; +import { bpdApiUrlPrefix } from "../../../../config"; import { BackendBpdClient } from "../api/backendBpdClient"; import { bpdAllData, bpdLoadActivationStatus } from "../store/actions/details"; import { bpdIbanInsertionStart, bpdUpsertIban } from "../store/actions/iban"; @@ -12,13 +9,8 @@ import { bpdDeleteUserFromProgram, bpdEnrollUserToProgram, bpdOnboardingAcceptDeclaration, - bpdOnboardingStart, - bpdUpdateOptInStatusMethod + bpdOnboardingStart } from "../store/actions/onboarding"; -import { - optInPaymentMethodsDeletionChoice, - optInPaymentMethodsShowChoice -} from "../store/actions/optInPaymentMethods"; import { bpdPaymentMethodActivation, bpdUpdatePaymentMethodActivation @@ -30,12 +22,7 @@ import { bpdTransactionsLoadPage, bpdTransactionsLoadRequiredData } from "../store/actions/transactions"; -import { - deleteCitizen, - getCitizenV2, - putEnrollCitizenV2, - putOptInStatusCitizenV2 -} from "./networking"; +import { deleteCitizen, getCitizenV2, putEnrollCitizenV2 } from "./networking"; import { loadBpdData } from "./networking/loadBpdData"; import { loadPeriodsWithInfo } from "./networking/loadPeriodsWithInfo"; import { patchCitizenIban } from "./networking/patchCitizenIban"; @@ -50,8 +37,6 @@ import { handleTransactionsPage } from "./networking/winning-transactions/transa import { handleBpdIbanInsertion } from "./orchestration/insertIban"; import { handleBpdEnroll } from "./orchestration/onboarding/enrollToBpd"; import { handleBpdStartOnboardingSaga } from "./orchestration/onboarding/startOnboarding"; -import { optInDeletionChoiceHandler } from "./orchestration/optInPaymentMethods/optInDeletionChoiceHandler"; -import { optInShouldShowChoiceHandler } from "./orchestration/optInPaymentMethods/optInShouldShowChoiceHandler"; // watch all events about bpd export function* watchBonusBpdSaga(bpdBearerToken: string): SagaIterator { @@ -84,15 +69,6 @@ export function* watchBonusBpdSaga(bpdBearerToken: string): SagaIterator { bpdBackendClient.updatePaymentMethod ); - if (bpdOptInPaymentMethodsEnabled) { - // update citizen optInStatus - yield* takeLatest( - bpdUpdateOptInStatusMethod.request, - putOptInStatusCitizenV2, - bpdBackendClient.enrollCitizenV2IO - ); - } - // load bpd activation status for a specific payment method yield* takeEvery( bpdPaymentMethodActivation.request, @@ -153,18 +129,4 @@ export function* watchBonusBpdSaga(bpdBearerToken: string): SagaIterator { // The user start the insertion / modification of the IBAN associated with bpd program yield* takeLatest(getType(bpdIbanInsertionStart), handleBpdIbanInsertion); - - if (bpdOptInPaymentMethodsEnabled) { - // The user choice to delete all the payment method with the BPD capability during the opt-in flow - yield* takeLatest( - optInPaymentMethodsDeletionChoice, - optInDeletionChoiceHandler - ); - - // Checks if the user has already see the opt-in payment method choice screens, and if not run the workunit - yield* takeLatest( - optInPaymentMethodsShowChoice.request, - optInShouldShowChoiceHandler - ); - } } diff --git a/ts/features/bonus/bpd/saga/orchestration/__tests__/activateBpdOnNewPaymentMethods.test.tsx b/ts/features/bonus/bpd/saga/orchestration/__tests__/activateBpdOnNewPaymentMethods.test.tsx deleted file mode 100644 index 1859e7ac367..00000000000 --- a/ts/features/bonus/bpd/saga/orchestration/__tests__/activateBpdOnNewPaymentMethods.test.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import * as E from "fp-ts/lib/Either"; -import { View } from "react-native"; -import { createStore } from "redux"; -import { expectSaga } from "redux-saga-test-plan"; -import * as matchers from "redux-saga-test-plan/matchers"; -import { BpdConfig } from "../../../../../../../definitions/content/BpdConfig"; -import { EnableableFunctionsEnum } from "../../../../../../../definitions/pagopa/EnableableFunctions"; -import { applicationChangeState } from "../../../../../../store/actions/application"; -import { navigateToWalletHome } from "../../../../../../store/actions/navigation"; -import { appReducer } from "../../../../../../store/reducers"; -import { bpdRemoteConfigSelector } from "../../../../../../store/reducers/backendStatus"; -import { mockCreditCardPaymentMethod } from "../../../../../../store/reducers/wallet/__mocks__/wallets"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper"; -import { activateBpdOnNewPaymentMethods } from "../activateBpdOnNewAddedPaymentMethods"; -import { isBpdEnabled } from "../onboarding/startOnboarding"; - -const enrollAfterAddTrue: BpdConfig = { - enroll_bpd_after_add_payment_method: true, - program_active: true, - opt_in_payment_methods: false, - opt_in_payment_methods_v2: false -}; - -const enrollAfterAddFalse: BpdConfig = { - enroll_bpd_after_add_payment_method: false, - program_active: true, - opt_in_payment_methods: false, - opt_in_payment_methods_v2: false -}; - -const navFunc = jest.fn(); - -describe("Test activateBpdOnNewPaymentMethods behaviour", () => { - jest.useFakeTimers(); - - beforeEach(() => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const store = createStore(appReducer, globalState as any); - renderScreenWithNavigationStoreContext(View, "DUMMY", {}, store); - }); - - it("With default state and no payment methods, should navigate to wallet home", async () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const store = createStore(appReducer, globalState as any); - - // We trigger the initialization of the NavigationService - renderScreenWithNavigationStoreContext(View, "DUMMY", {}, store); - - await expectSaga(activateBpdOnNewPaymentMethods, [], navFunc) - .withState(store.getState()) - .call(navigateToWalletHome) - .not.call(isBpdEnabled) - .not.select(bpdRemoteConfigSelector) - .not.call(navFunc) - .run(); - }); - - it("With all payment methods without bpd capability, should navigate to navigateToWalletHome", async () => { - await expectSaga( - activateBpdOnNewPaymentMethods, - [ - { - ...mockCreditCardPaymentMethod, - enableableFunctions: [ - EnableableFunctionsEnum.FA, - EnableableFunctionsEnum.pagoPA - ] - } - ], - navFunc - ) - .provide([ - [matchers.call(isBpdEnabled), E.right(true)], - [matchers.select(bpdRemoteConfigSelector), enrollAfterAddFalse] - ]) - .call(navigateToWalletHome) - .not.call(isBpdEnabled) - .not.select(bpdRemoteConfigSelector) - .not.call(navFunc) - .run(); - }); - - it("With at least one payment method with bpd capability, bpd enrolled and program_active === true, should navigate to navFunc", async () => { - await expectSaga( - activateBpdOnNewPaymentMethods, - [mockCreditCardPaymentMethod], - navFunc - ) - .provide([ - [matchers.call(isBpdEnabled), E.right(true)], - [matchers.select(bpdRemoteConfigSelector), enrollAfterAddFalse] - ]) - .not.call(navigateToWalletHome) - .call(isBpdEnabled) - .select(bpdRemoteConfigSelector) - .call(navFunc) - .run(); - }); - - it("With at least one payment method with bpd capability, bpd enrolled and program_active === false, should navigate to navFunc", async () => { - await expectSaga( - activateBpdOnNewPaymentMethods, - [mockCreditCardPaymentMethod], - navFunc - ) - .provide([ - [matchers.call(isBpdEnabled), E.right(true)], - [ - matchers.select(bpdRemoteConfigSelector), - { ...enrollAfterAddFalse, program_active: false } - ] - ]) - .not.call(navigateToWalletHome) - .call(isBpdEnabled) - .select(bpdRemoteConfigSelector) - .not.call(navFunc) - .run(); - }); - - it("With at least one payment method with bpd capability, bpd not enrolled and remote configuration false or undefined should navigate to navigateToWalletHome", async () => { - await expectSaga( - activateBpdOnNewPaymentMethods, - [mockCreditCardPaymentMethod], - navFunc - ) - .provide([ - [matchers.call(isBpdEnabled), E.right(false)], - [matchers.select(bpdRemoteConfigSelector), enrollAfterAddFalse] - ]) - .call(isBpdEnabled) - .select(bpdRemoteConfigSelector) - .not.call(navFunc) - .run(); - }); - - it("With at least one payment method with bpd capability, bpd not enrolled and remote configuration true, should navigate to navigateToWalletHome", async () => { - await expectSaga( - activateBpdOnNewPaymentMethods, - [mockCreditCardPaymentMethod], - navFunc - ) - .provide([ - [matchers.call(isBpdEnabled), E.right(false)], - [matchers.select(bpdRemoteConfigSelector), enrollAfterAddTrue] - ]) - .call(isBpdEnabled) - .select(bpdRemoteConfigSelector) - .not.call(navFunc) - .run(); - }); -}); diff --git a/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts b/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts index fbdd544292e..8c2b6aa8aba 100644 --- a/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts +++ b/ts/features/bonus/bpd/saga/orchestration/activateBpdOnNewAddedPaymentMethods.ts @@ -1,8 +1,7 @@ import * as E from "fp-ts/lib/Either"; -import { call, select } from "typed-redux-saga/macro"; +import { call } from "typed-redux-saga/macro"; import { EnableableFunctionsEnum } from "../../../../../../definitions/pagopa/EnableableFunctions"; import { navigateToWalletHome } from "../../../../../store/actions/navigation"; -import { bpdRemoteConfigSelector } from "../../../../../store/reducers/backendStatus"; import { PaymentMethod } from "../../../../../types/pagopa"; import { SagaCallReturnType } from "../../../../../types/utils"; import { hasFunctionEnabled } from "../../../../../utils/walletv2"; @@ -26,14 +25,11 @@ export function* activateBpdOnNewPaymentMethods( const isBpdEnabledResponse: SagaCallReturnType = yield* call(isBpdEnabled); - const bpdRemoteConfig: ReturnType = - yield* select(bpdRemoteConfigSelector); - // Error while reading the bpdEnabled, return to wallet if (E.isLeft(isBpdEnabledResponse)) { yield* call(navigateToWalletHome); } else { - if (isBpdEnabledResponse.right && bpdRemoteConfig?.program_active) { + if (isBpdEnabledResponse.right) { // navigate to activate cashback on new payment methods if the user is onboarded to the program and is active yield* call(navigateToActivateNewMethods); } diff --git a/ts/features/bonus/bpd/saga/orchestration/insertIban.ts b/ts/features/bonus/bpd/saga/orchestration/insertIban.ts index 6351f5f5bdf..e5e723e1bdf 100644 --- a/ts/features/bonus/bpd/saga/orchestration/insertIban.ts +++ b/ts/features/bonus/bpd/saga/orchestration/insertIban.ts @@ -1,23 +1,11 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; import { SagaIterator } from "redux-saga"; import { call, put, select, take } from "typed-redux-saga/macro"; import { ActionType, isActionOf } from "typesafe-actions"; -import { CommonActions } from "@react-navigation/native"; -import { EnableableFunctionsEnum } from "../../../../../../definitions/pagopa/EnableableFunctions"; -import NavigationService from "../../../../../navigation/NavigationService"; import { navigateBack, navigateToWalletHome } from "../../../../../store/actions/navigation"; import { paymentMethodsSelector } from "../../../../../store/reducers/wallet/wallets"; -import { hasFunctionEnabled } from "../../../../../utils/walletv2"; -import { - navigateToBpdIbanInsertion, - navigateToBpdOnboardingEnrollPaymentMethod, - navigateToBpdOnboardingErrorPaymentMethods, - navigateToBpdOnboardingNoPaymentMethods -} from "../../navigation/actions"; -import BPD_ROUTES from "../../navigation/routes"; import { bpdIbanInsertionCancel, bpdIbanInsertionContinue @@ -27,20 +15,6 @@ import { isBpdOnboardingOngoing } from "../../store/reducers/onboarding/ongoing" // TODO: if isOnboarding===true, change with an action that triggers a saga that choose // which screen to display, (the user already have payment methods or not) -export const chooseContinueAction = (isOnboarding: boolean) => - isOnboarding ? navigateToBpdOnboardingNoPaymentMethods : CommonActions.goBack; - -export const isMainScreen = (screenName: string) => - screenName === BPD_ROUTES.IBAN; - -function* ensureMainScreen() { - const currentRoute: ReturnType = - yield* call(NavigationService.getCurrentRouteName); - - if (currentRoute !== undefined && !isMainScreen(currentRoute)) { - yield* call(navigateToBpdIbanInsertion); - } -} /** * Old style orchestrator, please don't use this as reference for future development @@ -50,7 +24,6 @@ export function* bpdIbanInsertionWorker() { const onboardingOngoing: ReturnType = yield* select(isBpdOnboardingOngoing); // ensure the first screen of the saga is the iban main screen. - yield* call(ensureMainScreen); // wait for the user iban insertion o cancellation const nextAction = yield* take< @@ -65,21 +38,10 @@ export function* bpdIbanInsertionWorker() { // Error while loading the wallet, display a message that informs the user about the error if (paymentMethods.kind === "PotNoneError") { - yield* call(navigateToBpdOnboardingErrorPaymentMethods); yield* put(bpdOnboardingCompleted()); return; } - const hasAtLeastOnePaymentMethodWithBpd = pot.getOrElse( - pot.map(paymentMethods, pm => - pm.some(p => hasFunctionEnabled(p, EnableableFunctionsEnum.BPD)) - ), - false - ); - const nextAction = hasAtLeastOnePaymentMethodWithBpd - ? navigateToBpdOnboardingEnrollPaymentMethod - : navigateToBpdOnboardingNoPaymentMethods; - yield* call(nextAction); yield* put(bpdOnboardingCompleted()); } else { yield* call(navigateBack); diff --git a/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts b/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts index ab119da25eb..cd34de7c194 100644 --- a/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts +++ b/ts/features/bonus/bpd/saga/orchestration/onboarding/enrollToBpd.ts @@ -2,8 +2,6 @@ import { CommonActions } from "@react-navigation/native"; import { call, put, race, take } from "typed-redux-saga/macro"; import { ActionType } from "typesafe-actions"; import NavigationService from "../../../../../../navigation/NavigationService"; -import { navigateToBpdOnboardingLoadActivate } from "../../../navigation/actions"; -import BPD_ROUTES from "../../../navigation/routes"; import { bpdAllData } from "../../../store/actions/details"; import { bpdIbanInsertionStart } from "../../../store/actions/iban"; import { @@ -11,8 +9,7 @@ import { bpdOnboardingCancel } from "../../../store/actions/onboarding"; -export const isLoadingScreen = (screenName: string) => - screenName === BPD_ROUTES.ONBOARDING.LOAD_ACTIVATE_BPD; +export const isLoadingScreen = () => true; /** * Old style orchestrator, please don't use this as reference for future development @@ -22,9 +19,9 @@ function* enrollToBpdWorker() { const currentRoute: ReturnType = yield* call(NavigationService.getCurrentRouteName); - if (currentRoute !== undefined && !isLoadingScreen(currentRoute)) { + if (currentRoute !== undefined && !isLoadingScreen()) { // show the loading page while communicate with the server for the activation - yield* call(navigateToBpdOnboardingLoadActivate); + throw new Error("Not in the loading screen"); } // enroll the user and wait for the result diff --git a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts b/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts index 6fe3babc1de..78012d3cbb6 100644 --- a/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts +++ b/ts/features/bonus/bpd/saga/orchestration/onboarding/startOnboarding.ts @@ -12,12 +12,6 @@ import { SagaCallReturnType } from "../../../../../../types/utils"; import { getAsyncResult } from "../../../../../../utils/saga"; -import { - navigateToBpdOnboardingDeclaration, - navigateToBpdOnboardingInformationTos, - navigateToBpdOnboardingLoadActivationStatus -} from "../../../navigation/actions"; -import BPD_ROUTES from "../../../navigation/routes"; import { bpdLoadActivationStatus } from "../../../store/actions/details"; import { bpdOnboardingAcceptDeclaration, @@ -26,8 +20,7 @@ import { } from "../../../store/actions/onboarding"; import { bpdEnabledSelector } from "../../../store/reducers/details/activation"; -export const isLoadingScreen = (screenName: string) => - screenName === BPD_ROUTES.ONBOARDING.LOAD_CHECK_ACTIVATION_STATUS; +export const isLoadingScreen = () => true; export function* getActivationStatus() { return yield* call(() => getAsyncResult(bpdLoadActivationStatus, undefined)); @@ -61,8 +54,8 @@ export function* bpdStartOnboardingWorker() { yield* call(NavigationService.getCurrentRouteName); // go to the loading page (if I'm not on that screen) - if (currentRoute !== undefined && !isLoadingScreen(currentRoute)) { - yield* call(navigateToBpdOnboardingLoadActivationStatus); + if (currentRoute !== undefined && !isLoadingScreen()) { + throw new Error("Not in the loading screen"); } // read if the bpd is active for the user @@ -74,13 +67,10 @@ export function* bpdStartOnboardingWorker() { // Refresh the wallets to prevent that added cards are not visible yield* put(fetchWalletsRequest()); - yield* call(navigateToBpdOnboardingInformationTos); - // wait for the user that choose to continue yield* take(bpdUserActivate); // Navigate to the Onboarding Declaration and wait for the action that complete the saga - yield* call(navigateToBpdOnboardingDeclaration); } // The saga ends when the user accepts the declaration diff --git a/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx b/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx index 80ca1b10c47..12d88cd55ce 100644 --- a/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx +++ b/ts/features/bonus/bpd/screens/details/BpdDetailsScreen.tsx @@ -20,7 +20,6 @@ import { isLoading, isReady } from "../../../../../common/model/RemoteValue"; -import { navigateToBpdTransactions } from "../../navigation/actions"; import { bpdAllData } from "../../store/actions/details"; import { bpdUnsubscribeCompleted, @@ -154,7 +153,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ dispatch(bpdUnsubscribeCompleted()); navigateBack(); }, - goToTransactions: () => navigateToBpdTransactions(), + goToTransactions: () => null, goBack: () => navigateBack(), completeUnsubscriptionFailure: () => dispatch(bpdUnsubscribeFailure()) }); diff --git a/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx index 66fd8938039..1086496f9f4 100644 --- a/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx +++ b/ts/features/bonus/bpd/screens/details/components/summary/TransactionsGraphicalSummary.tsx @@ -9,7 +9,6 @@ import I18n from "../../../../../../../i18n"; import { Dispatch } from "../../../../../../../store/actions/types"; import { GlobalState } from "../../../../../../../store/reducers/types"; import { formatIntegerNumber } from "../../../../../../../utils/stringBuilder"; -import { navigateToBpdTransactions } from "../../../../navigation/actions"; import { BpdPeriod } from "../../../../store/actions/periods"; import { BpdBaseShadowBoxLayout } from "./base/BpdBaseShadowBoxLayout"; import { ProgressBar } from "./base/ProgressBar"; @@ -113,7 +112,7 @@ const TransactionsGraphicalSummary = (props: Props) => ( const mapStateToProps = (_: GlobalState) => ({}); const mapDispatchToProps = (_: Dispatch) => ({ - goToTransactions: () => navigateToBpdTransactions() + goToTransactions: () => null }); export default connect( diff --git a/ts/features/bonus/bpd/screens/details/components/summary/__test__/bpdSummaryComponent.test.tsx b/ts/features/bonus/bpd/screens/details/components/summary/__test__/bpdSummaryComponent.test.tsx deleted file mode 100644 index 6968ccb18d1..00000000000 --- a/ts/features/bonus/bpd/screens/details/components/summary/__test__/bpdSummaryComponent.test.tsx +++ /dev/null @@ -1,498 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import "@testing-library/jest-native/extend-expect"; -import { render, RenderAPI } from "@testing-library/react-native"; -import MockDate from "mockdate"; -import * as React from "react"; -import { Provider } from "react-redux"; -import configureMockStore from "redux-mock-store"; -import I18n from "../../../../../../../../i18n"; -import { - baseBackendConfig, - baseBackendState, - withBpdRankingConfig -} from "../../../../../../../../store/reducers/__mock__/backendStatus"; -import { dateToAccessibilityReadableFormat } from "../../../../../../../../utils/accessibility"; -import { formatIntegerNumber } from "../../../../../../../../utils/stringBuilder"; -import { - BpdPeriodWithInfo, - isBpdRankingReady -} from "../../../../../store/reducers/details/periods"; -import { - eligibleAmount, - eligibleMaxAmount, - notEligibleAmount, - zeroAmount -} from "../../../../../store/reducers/__mock__/amount"; -import { - activePeriod, - closedPeriod, - inactivePeriod -} from "../../../../../store/reducers/__mock__/periods"; -import { - notReadyRanking, - readyRanking -} from "../../../../../store/reducers/__mock__/ranking"; -import BpdSummaryComponent from "../BpdSummaryComponent"; - -jest.mock("react-native-safe-area-context", () => ({ - useSafeAreaInsets: jest - .fn() - .mockReturnValue({ top: 20, left: 0, right: 0, bottom: 0 }) -})); - -describe("Bpd Summary Component graphical test for different states", () => { - const mockStore = configureMockStore(); - MockDate.set("2020-11-04"); - jest.useFakeTimers(); - - it("Render Inactive period", () => { - const store = mockStore( - mockBpdState({ - ...inactivePeriod, - amount: zeroAmount, - ranking: readyRanking - }) - ); - const component = render( - - - - ); - - expect(component).not.toBeNull(); - - // When the period is "Inactive", the TransactionsGraphicalSummary should be null - expect(component.queryByTestId("progressBar")).toBeNull(); - - // When the period is "Inactive", the SuperCashbackRankingSummary should be null - expect(component.queryByTestId("supercashbackSummary.title")).toBeNull(); - - expect( - component.queryByTestId("textualTransaction.transactions") - ).toBeNull(); - // When the period is "Inactive", the TextualSummary should be in "inactive" mode - const textualSummary = component.queryByTestId("inactivePeriod"); - expect(textualSummary).toBeEnabled(); - // The TextualSummary text should include the start date of the inactive period - expect(textualSummary).toHaveTextContent( - dateToAccessibilityReadableFormat(inactivePeriod.startDate) - ); - }); - - it("Render Active period, transactionNumber { - const store = mockStore( - mockBpdState({ - ...activePeriod, - amount: zeroAmount, - ranking: readyRanking - }) - ); - const component = render( - - - - ); - - // When the period is "Active" and totalCashback = 0 the SuperCashbackRankingSummary should be null - expect(component.queryByTestId("supercashbackSummary.title")).toBeNull(); - - // When the period is "Active" and transactionNumber 0", () => { - const period = { - ...activePeriod, - amount: notEligibleAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - // When the period is "Active" and transactionNumber 0 - const textualSummary = component.queryByTestId("currentPeriodWarning"); - - expectSuperCashback(component, period); - - expect(textualSummary).toBeEnabled(); - // The text description should indicate the minimum transaction required to acquire the cashback - expect(textualSummary).toHaveTextContent( - activePeriod.minTransactionNumber.toString() - ); - }); - - it("Render Active period, transactionNumber < minTransactionNumber, totalCashback > 0, supercashback not ready", () => { - const period = { - ...activePeriod, - amount: notEligibleAmount, - ranking: notReadyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - // When the period is "Active" and transactionNumber 0 - const textualSummary = component.queryByTestId("currentPeriodWarning"); - - expectSuperCashback(component, period); - - expect(textualSummary).toBeEnabled(); - // The text description should indicate the minimum transaction required to acquire the cashback - expect(textualSummary).toHaveTextContent( - activePeriod.minTransactionNumber.toString() - ); - }); - - it("Render Active period, transactionNumber >= minTransactionNumber, ranking <= minPosition, no max amount", () => { - const period = { - ...activePeriod, - amount: eligibleAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - // TextualTransaction should be enabled - const textualTransactionTransactions = component.queryByTestId( - "textualTransaction.transactions" - ); - expect(textualTransactionTransactions).toBeEnabled(); - - expect(textualTransactionTransactions).toHaveTextContent( - eligibleAmount.transactionNumber.toString() - ); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - expect(component.queryByTestId("currentPeriodWarning")).toBeNull(); - - // When ranking <= minPosition - expect(component.queryByTestId("currentPeriodSuperCashback")).toBeEnabled(); - }); - - it("Render Active period, transactionNumber >= minTransactionNumber, ranking <= minPosition, max amount", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: { - ...eligibleAmount, - totalCashback: activePeriod.maxPeriodCashback - }, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - // TextualTransaction should be enabled - const textualTransactionTransactions = component.queryByTestId( - "textualTransaction.transactions" - ); - expect(textualTransactionTransactions).toBeEnabled(); - - expect(textualTransactionTransactions).toHaveTextContent( - eligibleAmount.transactionNumber.toString() - ); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - expect(component.queryByTestId("currentPeriodWarning")).toBeNull(); - - // When ranking <= minPosition - expect(component.queryByTestId("currentPeriodSuperCashback")).toBeEnabled(); - }); - - it("Render Active period, transactionNumber >= minTransactionNumber, ranking > minPosition, no max amount", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: eligibleAmount, - ranking: { ...readyRanking, ranking: 1000000 } - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - // TextualTransaction should be enabled - const textualTransactionTransactions = component.queryByTestId( - "textualTransaction.transactions" - ); - expect(textualTransactionTransactions).toBeEnabled(); - - expect(textualTransactionTransactions).toHaveTextContent( - eligibleAmount.transactionNumber.toString() - ); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - expect(component.queryByTestId("currentPeriodWarning")).toBeNull(); - - expect(component.queryByTestId("currentPeriodUnlock")).toBeEnabled(); - }); - - it("Render Active period, transactionNumber > minTransactionNumber+10, ranking > minPosition, no max amount", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: { - ...eligibleAmount, - transactionNumber: activePeriod.minTransactionNumber + 11 - }, - ranking: { ...readyRanking, ranking: 1000000 } - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - // TextualTransaction should be enabled - const textualTransactionTransactions = component.queryByTestId( - "textualTransaction.transactions" - ); - expect(textualTransactionTransactions).toBeEnabled(); - - expect(textualTransactionTransactions).toHaveTextContent( - period.amount.transactionNumber.toString() - ); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - expect(component.queryByTestId("currentPeriodWarning")).toBeNull(); - - expect(component.queryByTestId("currentPeriodUnlock")).toBeNull(); - }); - - it("Render Active period, transactionNumber >= minTransactionNumber, ranking > minPosition, max amount", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: { - ...eligibleAmount, - totalCashback: activePeriod.maxPeriodCashback - }, - ranking: { ...readyRanking, ranking: 1000000 } - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - // TextualTransaction should be enabled - const textualTransactionTransactions = component.queryByTestId( - "textualTransaction.transactions" - ); - expect(textualTransactionTransactions).toBeEnabled(); - - expect(textualTransactionTransactions).toHaveTextContent( - eligibleAmount.transactionNumber.toString() - ); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - expect(component.queryByTestId("currentPeriodWarning")).toBeNull(); - - expect(component.queryByTestId("currentPeriodMaxAmount")).toBeEnabled(); - }); - - it("Render Closed period, grace period", () => { - MockDate.set("2020-11-04"); - const period = { - ...closedPeriod, - amount: zeroAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const componentGrace = render( - - - - ); - - expectSuperCashback(componentGrace, period); - - // When the period is "Active" and transactionNumber>=minTransactionNumber, - // no TextualSummary should be rendered. - const textualSummary = componentGrace.queryByTestId("gracePeriod"); - expect(textualSummary).toBeEnabled(); - expect(textualSummary).toHaveTextContent( - dateToAccessibilityReadableFormat(closedPeriod.endDate) - ); - MockDate.reset(); - - // Grace period ends - MockDate.set("2020-11-06"); - const componentNoGrace = render( - - - - ); - expect(componentNoGrace.queryByTestId("gracePeriod")).toBeNull(); - }); - - it("Render Closed period, not enough transactions", () => { - MockDate.set("2020-11-09"); - const period = { - ...closedPeriod, - amount: zeroAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - expect(component.queryByTestId("closedPeriodKO")).toBeEnabled(); - - expectSuperCashback(component, period); - }); - - it("Render Closed period, cashback earned", () => { - MockDate.set("2020-11-09"); - const period = { - ...closedPeriod, - amount: eligibleAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - const textualSummary = component.queryByTestId("closedPeriodOK"); - expect(textualSummary).toBeEnabled(); - expect(textualSummary).toHaveTextContent( - eligibleAmount.totalCashback.toString() - ); - }); - - it("Render Closed period, max cashback earned", () => { - MockDate.set("2020-11-09"); - const period = { - ...closedPeriod, - amount: eligibleMaxAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashback(component, period); - - const textualSummary = component.queryByTestId("closedPeriodOK"); - expect(textualSummary).toBeEnabled(); - expect(textualSummary).toHaveTextContent( - eligibleMaxAmount.totalCashback.toString() - ); - const maxAmount = I18n.t( - "bonus.bpd.details.components.transactionsCountOverview.closedPeriodMaxAmount" - ); - expect(textualSummary).toHaveTextContent(maxAmount); - }); - - MockDate.reset(); -}); - -/** - * Generate a mocked state with the fields required for these tests - * @param period - * @param bpdRankingRemoteConfig - */ -export const mockBpdState = ( - period: BpdPeriodWithInfo, - bpdRankingRemoteConfig?: boolean -) => ({ - bonus: { - bpd: { - details: { - selectedPeriod: period - } - } - }, - backendStatus: - bpdRankingRemoteConfig === undefined - ? baseBackendState - : withBpdRankingConfig(baseBackendState, { - ...baseBackendConfig, - bpd_ranking_v2: bpdRankingRemoteConfig - }), - profile: pot.none -}); - -/** - * Test the graphical states for SuperCashbackRankingSummary - * @param component - * @param period - */ -const expectSuperCashback = ( - component: RenderAPI, - period: BpdPeriodWithInfo -) => { - if (isBpdRankingReady(period.ranking)) { - expectSuperCashbackReady(component, period); - } else { - expectSuperCashbackNotReady(component); - } -}; - -export const expectSuperCashbackReady = ( - component: RenderAPI, - period: BpdPeriodWithInfo -) => { - if (isBpdRankingReady(period.ranking)) { - // The SuperCashbackRankingSummary should be visible - expect(component.queryByTestId("supercashbackSummary.title")).toBeEnabled(); - expect( - component.queryByTestId("supercashbackSummary.ranking") - ).toHaveTextContent(formatIntegerNumber(period.ranking.ranking)); - expect( - component.queryByTestId("supercashbackSummary.minRanking") - ).toHaveTextContent(formatIntegerNumber(period.minPosition)); - } else { - fail("Expected BpdRankingReady"); - } -}; - -export const expectSuperCashbackNotReady = (component: RenderAPI) => { - expect(component.queryByTestId("supercashbackSummary.title")).toBeNull(); - expect( - component.queryByTestId("superCashbackRankingNotReady.title") - ).toBeEnabled(); -}; diff --git a/ts/features/bonus/bpd/screens/details/components/summary/__test__/rankingNotReady.test.tsx b/ts/features/bonus/bpd/screens/details/components/summary/__test__/rankingNotReady.test.tsx deleted file mode 100644 index e111e72bb0f..00000000000 --- a/ts/features/bonus/bpd/screens/details/components/summary/__test__/rankingNotReady.test.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { render } from "@testing-library/react-native"; -import * as React from "react"; -import { Provider } from "react-redux"; -import configureMockStore from "redux-mock-store"; -import { notEligibleAmount } from "../../../../../store/reducers/__mock__/amount"; -import { activePeriod } from "../../../../../store/reducers/__mock__/periods"; -import { - notReadyRanking, - readyRanking -} from "../../../../../store/reducers/__mock__/ranking"; -import { BpdPeriodWithInfo } from "../../../../../store/reducers/details/periods"; -import BpdSummaryComponent from "../BpdSummaryComponent"; -import { - expectSuperCashbackNotReady, - expectSuperCashbackReady, - mockBpdState -} from "./bpdSummaryComponent.test"; - -jest.mock("react-native-safe-area-context", () => ({ - useSafeAreaInsets: jest - .fn() - .mockReturnValue({ top: 20, left: 0, right: 0, bottom: 0 }) -})); - -describe("Ranking ready vs not ready", () => { - const mockStore = configureMockStore(); - - it("with ranking: ready, remote ranking: false should display SuperCashbackRankingNotReady", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: notEligibleAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, false)); - const component = render( - - - - ); - - expectSuperCashbackNotReady(component); - }); - - it("with ranking: ready, remote ranking: true should display SuperCashbackRankingReady", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: notEligibleAmount, - ranking: readyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashbackReady(component, period); - }); - - it("with ranking: notReady, remote ranking: true should display SuperCashbackRankingNotReady", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: notEligibleAmount, - ranking: notReadyRanking - }; - const store = mockStore(mockBpdState(period, true)); - const component = render( - - - - ); - - expectSuperCashbackNotReady(component); - }); - - it("with ranking: notReady, remote ranking: false should display SuperCashbackRankingNotReady", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: notEligibleAmount, - ranking: notReadyRanking - }; - const store = mockStore(mockBpdState(period, false)); - const component = render( - - - - ); - - expectSuperCashbackNotReady(component); - }); - - it("with ranking: notReady, remote ranking: undefined should display SuperCashbackRankingNotReady", () => { - const period: BpdPeriodWithInfo = { - ...activePeriod, - amount: notEligibleAmount, - ranking: notReadyRanking - }; - const store = mockStore(mockBpdState(period)); - const component = render( - - - - ); - - expectSuperCashbackNotReady(component); - }); -}); diff --git a/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx b/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx index baa81a83aad..1d8e852dd8a 100644 --- a/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx +++ b/ts/features/bonus/bpd/screens/details/components/summary/ranking/SuperCashbackRankingSummary.tsx @@ -1,13 +1,12 @@ +import { Icon, VSpacer } from "@pagopa/io-app-design-system"; import * as React from "react"; import { StyleSheet, TouchableOpacity, View } from "react-native"; import { connect } from "react-redux"; import { Dispatch } from "redux"; -import { Icon, VSpacer } from "@pagopa/io-app-design-system"; import { H2 } from "../../../../../../../../components/core/typography/H2"; import { H5 } from "../../../../../../../../components/core/typography/H5"; import { IOStyles } from "../../../../../../../../components/core/variables/IOStyles"; import I18n from "../../../../../../../../i18n"; -import { bpdRankingEnabledSelector } from "../../../../../../../../store/reducers/backendStatus"; import { GlobalState } from "../../../../../../../../store/reducers/types"; import { formatIntegerNumber } from "../../../../../../../../utils/stringBuilder"; import { useSuperCashbackRankingBottomSheet } from "../../../../../components/superCashbackRanking/SuperCashbackRanking"; @@ -136,10 +135,7 @@ const shouldDisplayRankingReady = ( * @constructor */ const SuperCashbackRankingSummary = (props: Props): React.ReactElement => - shouldDisplayRankingReady( - props.period.ranking, - props.rankingRemoteEnabled - ) ? ( + shouldDisplayRankingReady(props.period.ranking, undefined) ? ( const mapDispatchToProps = (_: Dispatch) => ({}); -const mapStateToProps = (state: GlobalState) => ({ - rankingRemoteEnabled: bpdRankingEnabledSelector(state) -}); +const mapStateToProps = (_: GlobalState) => ({}); export default connect( mapStateToProps, diff --git a/ts/features/bonus/bpd/screens/details/transaction/__test__/BpdTransactionsScreen.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/__test__/BpdTransactionsScreen.test.tsx deleted file mode 100644 index cc42f21ea00..00000000000 --- a/ts/features/bonus/bpd/screens/details/transaction/__test__/BpdTransactionsScreen.test.tsx +++ /dev/null @@ -1,389 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as React from "react"; - -import { Action, createStore } from "redux"; -import ROUTES from "../../../../../../../navigation/routes"; -import { applicationChangeState } from "../../../../../../../store/actions/application"; -import { appReducer } from "../../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../../store/reducers/types"; -import { reproduceSequence } from "../../../../../../../utils/tests"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../../utils/testWrapper"; -import { bpdAllData } from "../../../../store/actions/details"; -import { AwardPeriodId } from "../../../../store/actions/periods"; -import { - BpdTransactions, - bpdTransactionsLoad -} from "../../../../store/actions/transactions"; -import * as transactionsReducer from "../../../../store/reducers/details/combiner"; -import * as lastUpdateReducer from "../../../../store/reducers/details/lastUpdate"; -import { BpdPeriodWithInfo } from "../../../../store/reducers/details/periods"; -import BpdTransactionsScreen from "../BpdTransactionsScreen"; - -jest.mock("react-native-share", () => ({ - open: jest.fn() -})); -describe("BpdTransactionsScreen", () => { - beforeEach(() => jest.useFakeTimers()); - it("should show the TransactionUnavailable screen if bpdLastUpdate is pot.none", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, globalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("TransactionUnavailable")).toBeTruthy(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.noneLoading", () => { - const sequenceOfActions: ReadonlyArray = [bpdAllData.request()]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.noneUpdating", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - lastUpdate: pot.noneUpdating({} as Date) - } - } - } - }; - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the TransactionUnavailable screen if bpdLastUpdate is pot.noneError", () => { - const myspy = jest - .spyOn(lastUpdateReducer, "bpdLastUpdateSelector") - .mockReturnValue(pot.noneError({} as Error)); - - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.failure({ message: "error" } as Error) - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("TransactionUnavailable")).toBeTruthy(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - - myspy.mockRestore(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.someLoading", () => { - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.success(), - bpdAllData.request() - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the TransactionUnavailable screen if bpdLastUpdate is pot.someError", () => { - const myspy = jest - .spyOn(lastUpdateReducer, "bpdLastUpdateSelector") - .mockReturnValue(pot.someError({} as Date, {} as Error)); - - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.success(), - bpdAllData.request() - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("TransactionUnavailable")).toBeTruthy(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - myspy.mockRestore(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.someUpdating", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - lastUpdate: pot.someUpdating({} as Date, {} as Date) - } - } - } - }; - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the BpdAvailableTransactionsScreen if bpdLastUpdate is pot.some and transactionForSelectedPeriod is pot.none", () => { - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.success() - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.some and transactionForSelectedPeriod is pot.noneUpdating", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - lastUpdate: pot.some({} as Date), - selectedPeriod: { - awardPeriodId: 1 as AwardPeriodId - } as BpdPeriodWithInfo, - transactions: { - 1: pot.noneUpdating([]) - } - } - } - } - }; - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the TransactionUnavailable screen if bpdLastUpdate is pot.some and transactionForSelectedPeriod is pot.noneError", () => { - const lastUpdateSpy = jest - .spyOn(lastUpdateReducer, "bpdLastUpdateSelector") - .mockReturnValue(pot.some({} as Date)); - const transactionsSpy = jest - .spyOn(transactionsReducer, "bpdDisplayTransactionsSelector") - .mockReturnValue(pot.noneError({} as Error)); - - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.success(), - bpdTransactionsLoad.request(1 as AwardPeriodId), - bpdTransactionsLoad.failure({ - awardPeriodId: 1 as AwardPeriodId, - error: {} as Error - }) - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("TransactionUnavailable")).toBeTruthy(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - lastUpdateSpy.mockRestore(); - transactionsSpy.mockRestore(); - }); - it("should show the LoadTransactions screen if bpdLastUpdate is pot.some and transactionForSelectedPeriod is pot.someUpdating", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - lastUpdate: pot.some({} as Date), - selectedPeriod: { - awardPeriodId: 1 as AwardPeriodId - } as BpdPeriodWithInfo, - transactions: { - 1: pot.someUpdating([], []) - } - } - } - } - }; - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - expect(component).toBeDefined(); - expect(component.queryByTestId("LoadTransactions")).toBeTruthy(); - expect(component.queryByTestId("TransactionUnavailable")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - }); - it("should show the TransactionUnavailable screen if bpdLastUpdate is pot.some and transactionForSelectedPeriod is pot.someError", () => { - const lastUpdateSpy = jest - .spyOn(lastUpdateReducer, "bpdLastUpdateSelector") - .mockReturnValue(pot.some({} as Date)); - const transactionsSpy = jest - .spyOn(transactionsReducer, "bpdDisplayTransactionsSelector") - .mockReturnValue(pot.someError([], {} as Error)); - - const sequenceOfActions: ReadonlyArray = [ - bpdAllData.request(), - bpdAllData.success(), - bpdTransactionsLoad.request(1 as AwardPeriodId), - bpdTransactionsLoad.success({} as BpdTransactions), - bpdTransactionsLoad.request(1 as AwardPeriodId), - bpdTransactionsLoad.failure({ - awardPeriodId: 1 as AwardPeriodId, - error: {} as Error - }) - ]; - - const finalState = reproduceSequence( - {} as GlobalState, - appReducer, - sequenceOfActions - ); - const component = renderScreenWithNavigationStoreContext( - () => , - ROUTES.WALLET_BPAY_DETAIL, - {}, - createStore(appReducer, finalState as any) - ); - - // expect(finalState.bonus.bpd.details.transactions).toBe(""); - expect(component).toBeDefined(); - expect(component.queryByTestId("TransactionUnavailable")).toBeTruthy(); - expect(component.queryByTestId("LoadTransactions")).toBeNull(); - expect( - component.queryByTestId("BpdAvailableTransactionsScreen") - ).toBeNull(); - transactionsSpy.mockRestore(); - lastUpdateSpy.mockRestore(); - }); -}); diff --git a/ts/features/bonus/bpd/screens/details/transaction/__test__/LoadTransactions.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/__test__/LoadTransactions.test.tsx deleted file mode 100644 index a06a070f002..00000000000 --- a/ts/features/bonus/bpd/screens/details/transaction/__test__/LoadTransactions.test.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createStore } from "redux"; -import I18n from "../../../../../../../i18n"; -import { applicationChangeState } from "../../../../../../../store/actions/application"; -import { appReducer } from "../../../../../../../store/reducers"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../../utils/testWrapper"; -import LoadTransactions from "../LoadTransactions"; - -describe("LoadTransactions component", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const store = createStore(appReducer, globalState as any); - it("should show the activity indicator", () => { - const component = renderScreenWithNavigationStoreContext( - LoadTransactions, - "DUMMY", - {}, - store - ); - const activityIndicator = component.queryByTestId("activityIndicator"); - - expect(activityIndicator).not.toBe(null); - }); - it("should show the right title", () => { - const component = renderScreenWithNavigationStoreContext( - LoadTransactions, - "DUMMY", - {}, - store - ); - const title = component.getByText( - I18n.t("bonus.bpd.details.transaction.loading") - ); - - expect(title).not.toBeEmpty(); - }); -}); diff --git a/ts/features/bonus/bpd/screens/details/transaction/__test__/TransactionsUnavailable.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/__test__/TransactionsUnavailable.test.tsx deleted file mode 100644 index 538586702e7..00000000000 --- a/ts/features/bonus/bpd/screens/details/transaction/__test__/TransactionsUnavailable.test.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as O from "fp-ts/lib/Option"; -import * as React from "react"; - -import { Store } from "redux"; -import configureMockStore from "redux-mock-store"; -import { ToolEnum } from "../../../../../../../../definitions/content/AssistanceToolConfig"; -import { BackendStatus } from "../../../../../../../../definitions/content/BackendStatus"; -import { Config } from "../../../../../../../../definitions/content/Config"; -import I18n from "../../../../../../../i18n"; -import { GlobalState } from "../../../../../../../store/reducers/types"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../../utils/testWrapper"; -import BPD_ROUTES from "../../../../navigation/routes"; -import TransactionsUnavailable from "../TransactionsUnavailable"; - -jest.mock("../../../../../../../store/reducers/navigation", () => ({ - currentRouteSelector: jest.fn() -})); - -describe("TransactionsUnavailable component", () => { - const mockStore = configureMockStore(); - // eslint-disable-next-line functional/no-let - let store: ReturnType; - - beforeEach(() => { - jest.useFakeTimers(); - store = mockStore({ - search: { isSearchEnabled: false }, - persistedPreferences: { isPagoPATestEnabled: false }, - network: { isConnected: true }, - authentication: { - kind: "LoggedOutWithoutIdp", - reason: "NOT_LOGGED_IN" - }, - backendStatus: { - status: O.some({ - config: { - assistanceTool: { tool: ToolEnum.none }, - cgn: { enabled: true }, - fims: { enabled: true } - } as Config - } as BackendStatus) - }, - profile: pot.some({ is_email_validated: true }) - }); - }); - - it("should show the payment-unavailable-icon.png", () => { - const component = getComponent(store); - const rasterImageComponent = component.queryByTestId("rasterImage"); - const paymentUnavailableIconPath = - "../../../img/wallet/errors/payment-unavailable-icon.png"; - - expect(rasterImageComponent).toHaveProp("source", { - testUri: paymentUnavailableIconPath - }); - }); - it("should use the right string as header, title and body", () => { - const component = getComponent(store); - const headerTitle = component.getByText( - I18n.t("bonus.bpd.details.transaction.goToButton") - ); - const title = component.getByText( - I18n.t("bonus.bpd.details.transaction.error.title") - ); - const body = component.getByText( - I18n.t("bonus.bpd.details.transaction.error.body") - ); - - expect(headerTitle).not.toBeEmpty(); - expect(title).not.toBeEmpty(); - expect(body).not.toBeEmpty(); - }); -}); -const getComponent = (store: Store) => - renderScreenWithNavigationStoreContext( - () => , - BPD_ROUTES.TRANSACTIONS, - {}, - store - ); diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/BpdTransactionsRouterScreen.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/BpdTransactionsRouterScreen.test.tsx deleted file mode 100644 index 7d4c8dea9c9..00000000000 --- a/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/BpdTransactionsRouterScreen.test.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { fireEvent } from "@testing-library/react-native"; -import * as React from "react"; - -import { createStore, Store } from "redux"; -import I18n from "../../../../../../../../i18n"; -import { applicationChangeState } from "../../../../../../../../store/actions/application"; -import { appReducer } from "../../../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../../../store/reducers/types"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../../../utils/testWrapper"; -import BPD_ROUTES from "../../../../../navigation/routes"; -import { AwardPeriodId } from "../../../../../store/actions/periods"; -import { bpdTransactionsLoadRequiredData } from "../../../../../store/actions/transactions"; -import { eligibleAmount } from "../../../../../store/reducers/__mock__/amount"; -import { activePeriod } from "../../../../../store/reducers/__mock__/periods"; -import { readyRanking } from "../../../../../store/reducers/__mock__/ranking"; -import BpdTransactionsRouterScreen from "../BpdTransactionsRouterScreen"; - -jest.mock("react-native-share", () => ({ - open: jest.fn() -})); - -describe("Test BpdTransactionsRouterScreen behaviour and states", () => { - jest.useFakeTimers(); - it("With unexpected state should render the fallback error screen", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const store = createStore(appReducer, globalState as any); - const testComponent = renderComponent(store); - expect( - testComponent.queryByTestId("WorkunitGenericFailure") - ).not.toBeNull(); - }); - it("With initial cashback information should render loading screen", () => { - const store = getStateWithBpdInitialized(); - const testComponent = renderComponent(store); - expect(testComponent.queryByTestId("LoadTransactions")).not.toBeNull(); - }); - it("With a failure should render the TransactionsUnavailableV2Base screen", () => { - const store = getStateWithBpdInitialized(); - const testComponent = renderComponent(store); - expect(testComponent.queryByTestId("LoadTransactions")).not.toBeNull(); - store.dispatch( - bpdTransactionsLoadRequiredData.failure({ - awardPeriodId: 1 as AwardPeriodId, - error: new Error("An error") - }) - ); - expect( - testComponent.queryByTestId("TransactionUnavailableV2") - ).not.toBeNull(); - - const retryButton = testComponent.queryByText( - I18n.t("global.buttons.retry") - ); - - expect(retryButton).not.toBeNull(); - - if (retryButton !== null) { - // tap retry button - fireEvent.press(retryButton); - // the component changes to load - expect(testComponent.queryByTestId("LoadTransactions")).not.toBeNull(); - // the retry is successful - store.dispatch( - bpdTransactionsLoadRequiredData.success(1 as AwardPeriodId) - ); - // the component is updated - expect( - testComponent.queryByTestId("BpdAvailableTransactionsScreenV2") - ).not.toBeNull(); - } - }); - it("With a success should render the BpdAvailableTransactionsScreenV2 screen", () => { - const store = getStateWithBpdInitialized(); - const testComponent = renderComponent(store); - expect(testComponent.queryByTestId("LoadTransactions")).not.toBeNull(); - store.dispatch(bpdTransactionsLoadRequiredData.success(1 as AwardPeriodId)); - expect( - testComponent.queryByTestId("BpdAvailableTransactionsScreenV2") - ).not.toBeNull(); - }); -}); - -const getStateWithBpdInitialized = (): Store => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - selectedPeriod: { - ...activePeriod, - ranking: readyRanking, - amount: eligibleAmount - }, - lastUpdate: pot.noneUpdating({} as Date) - } - } - } - }; - return createStore(appReducer, finalState as any); -}; - -const renderComponent = (store: Store) => - renderScreenWithNavigationStoreContext( - () => , - BPD_ROUTES.TRANSACTIONS, - {}, - store - ); diff --git a/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/TransactionsSectionList.test.tsx b/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/TransactionsSectionList.test.tsx deleted file mode 100644 index cf6bda471b0..00000000000 --- a/ts/features/bonus/bpd/screens/details/transaction/v2/__test__/TransactionsSectionList.test.tsx +++ /dev/null @@ -1,165 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import * as React from "react"; - -import { createStore, Store } from "redux"; -import { applicationChangeState } from "../../../../../../../../store/actions/application"; -import { appReducer } from "../../../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../../../store/reducers/types"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../../../utils/testWrapper"; -import BPD_ROUTES from "../../../../../navigation/routes"; -import { - BpdTransactionId, - bpdTransactionsLoadCountByDay, - bpdTransactionsLoadMilestone, - bpdTransactionsLoadPage, - bpdTransactionsLoadRequiredData -} from "../../../../../store/actions/transactions"; -import { transactionTemplate } from "../../../../../store/reducers/details/transactionsv2/__mock__/transactions"; -import { eligibleAmount } from "../../../../../store/reducers/__mock__/amount"; -import { activePeriod } from "../../../../../store/reducers/__mock__/periods"; -import { readyRanking } from "../../../../../store/reducers/__mock__/ranking"; -import TransactionsSectionList from "../TransactionsSectionList"; - -jest.mock("react-native-share", () => ({ - open: jest.fn() -})); - -describe("Test TransactionsSectionList behaviour and states", () => { - jest.useFakeTimers(); - it("When the transactions list length is zero, should render BpdEmptyTransactionsList (wallet is pot.none)", () => { - const store = getStateWithBpdInitialized(); - store.dispatch( - bpdTransactionsLoadRequiredData.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadMilestone.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadMilestone.success({ - awardPeriodId: activePeriod.awardPeriodId, - result: undefined - }) - ); - store.dispatch( - bpdTransactionsLoadCountByDay.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadCountByDay.success({ - awardPeriodId: activePeriod.awardPeriodId, - results: [] - }) - ); - store.dispatch( - bpdTransactionsLoadPage.request({ - awardPeriodId: activePeriod.awardPeriodId - }) - ); - store.dispatch( - bpdTransactionsLoadPage.success({ - awardPeriodId: activePeriod.awardPeriodId, - results: { transactions: [] } - }) - ); - store.dispatch( - bpdTransactionsLoadRequiredData.success(activePeriod.awardPeriodId) - ); - const testComponent = renderComponent(store); - expect( - testComponent.queryByTestId("BpdEmptyTransactionsList") - ).not.toBeNull(); - }); -}); - -it("When the transactions list length is > 0, should render the transactions list", () => { - const store = getStateWithBpdInitialized(); - const trxDate = new Date("2021-01-01"); - - store.dispatch( - bpdTransactionsLoadRequiredData.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadMilestone.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadMilestone.success({ - awardPeriodId: activePeriod.awardPeriodId, - result: { - idTrx: "trxPivot" as BpdTransactionId, - amount: 9.99 - } - }) - ); - store.dispatch( - bpdTransactionsLoadCountByDay.request(activePeriod.awardPeriodId) - ); - store.dispatch( - bpdTransactionsLoadCountByDay.success({ - awardPeriodId: activePeriod.awardPeriodId, - results: [{ trxDate, count: 2 }] - }) - ); - store.dispatch( - bpdTransactionsLoadPage.request({ - awardPeriodId: activePeriod.awardPeriodId - }) - ); - store.dispatch( - bpdTransactionsLoadPage.success({ - awardPeriodId: activePeriod.awardPeriodId, - results: { - transactions: [ - { - date: trxDate, - transactions: [ - { ...transactionTemplate }, - { ...transactionTemplate, idTrx: "2" } - ] - } - ] - } - }) - ); - store.dispatch( - bpdTransactionsLoadRequiredData.success(activePeriod.awardPeriodId) - ); - const testComponent = renderComponent(store); - // Shouldn't render the ListEmptyComponent - expect(testComponent.queryByTestId("ListEmptyComponent")).toBeNull(); - expect( - testComponent.queryAllByTestId("BaseDailyTransactionHeader").length - ).toBe(1); - expect(testComponent.queryAllByTestId("BaseBpdTransactionItem").length).toBe( - 2 - ); -}); - -const getStateWithBpdInitialized = (): Store => { - const globalState = appReducer(undefined, applicationChangeState("active")); - const finalState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - selectedPeriod: { - ...activePeriod, - ranking: readyRanking, - amount: eligibleAmount - }, - lastUpdate: pot.noneUpdating({} as Date) - } - } - } - }; - return createStore(appReducer, finalState as any); -}; - -const renderComponent = (store: Store) => - renderScreenWithNavigationStoreContext( - () => , - BPD_ROUTES.TRANSACTIONS, - {}, - store - ); diff --git a/ts/features/bonus/bpd/screens/iban/IbanCTAEditScreen.tsx b/ts/features/bonus/bpd/screens/iban/IbanCTAEditScreen.tsx index 851b006f2b9..21f138ca4ae 100644 --- a/ts/features/bonus/bpd/screens/iban/IbanCTAEditScreen.tsx +++ b/ts/features/bonus/bpd/screens/iban/IbanCTAEditScreen.tsx @@ -1,18 +1,15 @@ import * as pot from "@pagopa/ts-commons/lib/pot"; -import { useNavigation } from "@react-navigation/native"; import * as React from "react"; import { Alert } from "react-native"; import { connect } from "react-redux"; import { Dispatch } from "redux"; +import { LoadingErrorComponent } from "../../../../../components/LoadingErrorComponent"; import BaseScreenComponent from "../../../../../components/screens/BaseScreenComponent"; import I18n from "../../../../../i18n"; import { navigateBack } from "../../../../../store/actions/navigation"; -import { bpdRemoteConfigSelector } from "../../../../../store/reducers/backendStatus"; import { GlobalState } from "../../../../../store/reducers/types"; import { useActionOnFocus } from "../../../../../utils/hooks/useOnFocus"; import { isStrictSome } from "../../../../../utils/pot"; -import { LoadingErrorComponent } from "../../../../../components/LoadingErrorComponent"; -import { navigateToBpdDetails } from "../../navigation/actions"; import { bpdAllData } from "../../store/actions/details"; import { bpdSelectPeriod } from "../../store/actions/selectedPeriod"; import { bpdEnabledSelector } from "../../store/reducers/details/activation"; @@ -114,18 +111,9 @@ const InnerIbanCTAEditScreen = (props: Props) => { /** * Landing screen from the CTA message that asks to review user's IBAN insertion */ -const IbanCTAEditScreen: React.FC = (props: Props) => { - const navigation = useNavigation(); - if (!props.bpdRemoteConfig?.program_active) { - Alert.alert( - I18n.t("bonus.bpd.title"), - I18n.t("bonus.bpd.iban.bpdCompletedMessage") - ); - navigation.goBack(); - return null; - } - return ; -}; +const IbanCTAEditScreen: React.FC = (props: Props) => ( + +); const mapDispatchToProps = (dispatch: Dispatch) => ({ load: () => { @@ -134,7 +122,6 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ goBack: () => navigateBack(), navigateToBPDPeriodDetails: (bpdPeriod: BpdPeriodWithInfo) => { dispatch(bpdSelectPeriod(bpdPeriod)); - navigateToBpdDetails(bpdPeriod); } }); @@ -142,7 +129,7 @@ const mapStateToProps = (state: GlobalState) => ({ bpdLoadState: bpdLastUpdateSelector(state), bpdPeriods: bpdPeriodsSelector(state), bpdEnabled: bpdEnabledSelector(state), - bpdRemoteConfig: bpdRemoteConfigSelector(state) + bpdRemoteConfig: {} }); export default connect(mapStateToProps, mapDispatchToProps)(IbanCTAEditScreen); diff --git a/ts/features/bonus/bpd/screens/onboarding/BpdCTAStartOnboardingScreen.tsx b/ts/features/bonus/bpd/screens/onboarding/BpdCTAStartOnboardingScreen.tsx deleted file mode 100644 index d586ce069a5..00000000000 --- a/ts/features/bonus/bpd/screens/onboarding/BpdCTAStartOnboardingScreen.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { useNavigation } from "@react-navigation/native"; -import * as React from "react"; -import { useEffect } from "react"; -import { Alert } from "react-native"; -import { connect } from "react-redux"; -import { Dispatch } from "redux"; -import BaseScreenComponent from "../../../../../components/screens/BaseScreenComponent"; -import I18n from "../../../../../i18n"; -import { bpdRemoteConfigSelector } from "../../../../../store/reducers/backendStatus"; -import { GlobalState } from "../../../../../store/reducers/types"; -import { useActionOnFocus } from "../../../../../utils/hooks/useOnFocus"; -import { LoadingErrorComponent } from "../../../../../components/LoadingErrorComponent"; -import { loadAvailableBonuses } from "../../../common/store/actions/availableBonusesTypes"; -import { - isAvailableBonusErrorSelector, - supportedAvailableBonusSelector -} from "../../../common/store/selectors"; -import { bpdOnboardingStart } from "../../store/actions/onboarding"; - -export type Props = ReturnType & - ReturnType; -const loadingCaption = () => I18n.t("global.remoteStates.loading"); - -const BaseBpdCTAStartOnboardingComponent = (props: Props) => { - const { availableBonus, startBpd } = props; - // load available bonus when component is focused - useActionOnFocus(props.loadAvailableBonus); - - useEffect(() => { - // bpdOnboardingStart navigate to ToS screen that needs availableBonus data - if (availableBonus.length > 0) { - startBpd(); - } - }, [availableBonus, startBpd]); - - return ( - - - - ); -}; - -/** - * this is a dummy screen reachable only from a message CTA - */ -const BpdCTAStartOnboardingScreen: React.FC = (props: Props) => { - const navigation = useNavigation(); - if (!props.bpdRemoteConfig?.program_active) { - Alert.alert( - I18n.t("bonus.bpd.title"), - I18n.t("bonus.state.completed.description") - ); - navigation.goBack(); - return null; - } else { - return ; - } -}; - -const mapDispatchToProps = (dispatch: Dispatch) => ({ - startBpd: () => { - dispatch(bpdOnboardingStart()); - }, - loadAvailableBonus: () => dispatch(loadAvailableBonuses.request()) -}); - -const mapStateToProps = (globalState: GlobalState) => ({ - availableBonus: supportedAvailableBonusSelector(globalState), - bpdRemoteConfig: bpdRemoteConfigSelector(globalState), - hasError: isAvailableBonusErrorSelector(globalState) -}); - -export default connect( - mapStateToProps, - mapDispatchToProps -)(BpdCTAStartOnboardingScreen); diff --git a/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx b/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx index 20fc4642779..8c397896958 100644 --- a/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx +++ b/ts/features/bonus/bpd/screens/onboarding/BpdInformationScreen.tsx @@ -6,14 +6,12 @@ import { Dispatch } from "../../../../../store/actions/types"; import { GlobalState } from "../../../../../store/reducers/types"; import { emptyContextualHelp } from "../../../../../utils/emptyContextualHelp"; import { actionWithAlert } from "../../../common/components/alert/ActionWithAlert"; -import { ID_BPD_TYPE } from "../../../common/utils"; import BonusInformationComponent from "../../../common/components/BonusInformationComponent"; import { bpdOnboardingCancel, bpdUserActivate } from "../../store/actions/onboarding"; import { bpdEnabledSelector } from "../../store/reducers/details/activation"; -import { availableBonusTypesSelectorFromId } from "../../../common/store/selectors"; export type Props = ReturnType & ReturnType; @@ -50,7 +48,7 @@ const BpdInformationScreen: React.FunctionComponent = (props: Props) => { }; const mapStateToProps = (state: GlobalState) => ({ - bonus: availableBonusTypesSelectorFromId(ID_BPD_TYPE)(state), + bonus: undefined, bpdActiveBonus: bpdEnabledSelector(state) }); diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsCashbackUpdateScreen.tsx b/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsCashbackUpdateScreen.tsx index 8ae4a763571..e7ea628da1b 100644 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsCashbackUpdateScreen.tsx +++ b/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsCashbackUpdateScreen.tsx @@ -1,8 +1,8 @@ -import { useNavigation } from "@react-navigation/native"; -import React from "react"; -import { View, SafeAreaView, ScrollView, StyleSheet } from "react-native"; import { VSpacer } from "@pagopa/io-app-design-system"; +import React from "react"; +import { SafeAreaView, ScrollView, StyleSheet, View } from "react-native"; import ButtonDefaultOpacity from "../../../../../components/ButtonDefaultOpacity"; +import { confirmButtonProps } from "../../../../../components/buttons/ButtonConfigurations"; import { IORenderHtml } from "../../../../../components/core/IORenderHtml"; import { H1 } from "../../../../../components/core/typography/H1"; import { IOStyles } from "../../../../../components/core/variables/IOStyles"; @@ -14,8 +14,6 @@ import { getBPDMethodsSelector, paymentMethodsSelector } from "../../../../../store/reducers/wallet/wallets"; -import { confirmButtonProps } from "../../../../../components/buttons/ButtonConfigurations"; -import { navigateToOptInPaymentMethodsChoiceScreen } from "../../navigation/actions"; import { optInPaymentMethodsCompleted, optInPaymentMethodsFailure @@ -28,7 +26,6 @@ const styles = StyleSheet.create({ } }); const OptInPaymentMethodsCashbackUpdateScreen = () => { - const navigation = useNavigation(); const dispatch = useIODispatch(); const bpdPaymentMethods = useIOSelector(getBPDMethodsSelector); const paymentMethods = useIOSelector(paymentMethodsSelector); @@ -40,7 +37,7 @@ const OptInPaymentMethodsCashbackUpdateScreen = () => { const handleOnContinuePress = () => { if (bpdPaymentMethods.length > 0) { - navigation.dispatch(navigateToOptInPaymentMethodsChoiceScreen()); + throw new Error("bpdPaymentMethods should be empty"); } else { dispatch(optInPaymentMethodsCompleted()); } diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsChoiceScreen.tsx b/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsChoiceScreen.tsx index 56dd1217c4f..1edc207743a 100644 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsChoiceScreen.tsx +++ b/ts/features/bonus/bpd/screens/optInPaymentMethods/OptInPaymentMethodsChoiceScreen.tsx @@ -31,10 +31,6 @@ import { isReady, isUndefined } from "../../../../../common/model/RemoteValue"; -import { - navigateToOptInPaymentMethodsThankYouDeleteMethodsScreen, - navigateToOptInPaymentMethodsThankYouKeepMethodsScreen -} from "../../navigation/actions"; import { optInPaymentMethodsShowChoice } from "../../store/actions/optInPaymentMethods"; import { showOptInChoiceSelector } from "../../store/reducers/details/activation/ui"; @@ -102,10 +98,9 @@ const OptInPaymentMethodsChoiceScreen = () => { const renderingRef = useRef(false); const { presentBottomSheet, bottomSheet } = useBottomSheetMethodsToDelete({ - onDeletePress: () => - navigation.dispatch( - navigateToOptInPaymentMethodsThankYouDeleteMethodsScreen() - ) + onDeletePress: () => { + throw new Error(); + } }); const bottomButtons: { @@ -113,10 +108,9 @@ const OptInPaymentMethodsChoiceScreen = () => { } = useMemo( () => ({ keepPaymentMethods: confirmButtonProps( - () => - navigation.dispatch( - navigateToOptInPaymentMethodsThankYouKeepMethodsScreen() - ), + () => { + throw new Error(); + }, I18n.t("global.buttons.continue"), undefined, "continueButton" @@ -128,7 +122,7 @@ const OptInPaymentMethodsChoiceScreen = () => { undefined ) }), - [navigation, presentBottomSheet] + [presentBottomSheet] ); const computedBottomButtonProps = useMemo( diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsCashbackUpdateScreen.test.tsx b/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsCashbackUpdateScreen.test.tsx deleted file mode 100644 index 7fbbe7c52e6..00000000000 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsCashbackUpdateScreen.test.tsx +++ /dev/null @@ -1,149 +0,0 @@ -import { createStore, Store } from "redux"; - -import { fireEvent, RenderAPI } from "@testing-library/react-native"; -import { EnableableFunctionsEnum } from "../../../../../../../definitions/pagopa/EnableableFunctions"; -import I18n from "../../../../../../i18n"; -import ROUTES from "../../../../../../navigation/routes"; -import { applicationChangeState } from "../../../../../../store/actions/application"; -import { - fetchWalletsFailure, - fetchWalletsRequest, - fetchWalletsSuccess -} from "../../../../../../store/actions/wallet/wallets"; -import { appReducer } from "../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../store/reducers/types"; -import { - RawBancomatPaymentMethod, - Wallet -} from "../../../../../../types/pagopa"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper"; -import * as navigationAction from "../../../navigation/actions"; -import * as optInPaymentMethodsActions from "../../../store/actions/optInPaymentMethods"; -import OptInPaymentMethodsCashbackUpdateScreen from "../OptInPaymentMethodsCashbackUpdateScreen"; - -jest.useFakeTimers(); -const mockPaymentMethodWithBPD = { - idWallet: 23216, - paymentMethod: { - kind: "Bancomat", - enableableFunctions: [EnableableFunctionsEnum.BPD], - info: {} - } as unknown as RawBancomatPaymentMethod -} as Wallet; -const mockPaymentMethodWithoutBPD = { - idWallet: 23216, - paymentMethod: { - kind: "Bancomat", - enableableFunctions: [EnableableFunctionsEnum.pagoPA], - info: {} - } as unknown as RawBancomatPaymentMethod -} as Wallet; -describe("the OptInPaymentMethodsCashbackUpdateScreen screen", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - it("if the payment methods are a pot of kind PotSome, should show the title and the subtitle", () => { - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - store.dispatch(fetchWalletsSuccess([mockPaymentMethodWithoutBPD])); - expect( - component.getByText( - I18n.t("bonus.bpd.optInPaymentMethods.cashbackUpdate.title") - ) - ).toBeDefined(); - }); - - describe("if the payment methods are a pot of kind PotSome, when the button continue is pressed", () => { - afterEach(() => { - jest.clearAllMocks(); - }); - it("should dispatch the optInPaymentMethodsCompleted action if there isn't at least a payment method with the BPD capability", () => { - const optInPaymentMethodsCompletedSpy = jest.spyOn( - optInPaymentMethodsActions, - "optInPaymentMethodsCompleted" - ); - const navigateToOptInPaymentMethodsChoiceScreenSpy = jest.spyOn( - navigationAction, - "navigateToOptInPaymentMethodsChoiceScreen" - ); - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - const continueButton = component.getByTestId("continueButton"); - - fireEvent(continueButton, "onPress"); - expect(optInPaymentMethodsCompletedSpy).toBeCalled(); - expect(navigateToOptInPaymentMethodsChoiceScreenSpy).not.toBeCalled(); - - store.dispatch(fetchWalletsSuccess([mockPaymentMethodWithoutBPD])); - fireEvent(continueButton, "onPress"); - expect(optInPaymentMethodsCompletedSpy).toBeCalled(); - expect(navigateToOptInPaymentMethodsChoiceScreenSpy).not.toBeCalled(); - }); - it("should dispatch the navigateToOptInPaymentMethodsChoiceScreen action if there is at least a payment method with the BPD capability", () => { - const optInPaymentMethodsCompletedSpy = jest.spyOn( - optInPaymentMethodsActions, - "optInPaymentMethodsCompleted" - ); - const navigateToOptInPaymentMethodsChoiceScreenSpy = jest.spyOn( - navigationAction, - "navigateToOptInPaymentMethodsChoiceScreen" - ); - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - store.dispatch(fetchWalletsSuccess([mockPaymentMethodWithBPD])); - const continueButton = component.getByTestId("continueButton"); - - fireEvent(continueButton, "onPress"); - expect(navigateToOptInPaymentMethodsChoiceScreenSpy).toBeCalled(); - expect(optInPaymentMethodsCompletedSpy).not.toBeCalled(); - }); - }); - - it("if the payment methods are not a pot of kind PotSome, should dispatch the optInPaymentMethodsFailure action", () => { - const optInPaymentMethodsFailureSpy = jest.spyOn( - optInPaymentMethodsActions, - "optInPaymentMethodsFailure" - ); - const store: Store = createStore( - appReducer, - globalState as any - ); - renderComponent(store); - - // PotNone case - expect(optInPaymentMethodsFailureSpy).toBeCalled(); - - // PotNoneLoading case - store.dispatch(fetchWalletsRequest()); - expect(optInPaymentMethodsFailureSpy).toBeCalled(); - - // PotNoneError case - store.dispatch(fetchWalletsFailure(new Error("mockedError"))); - expect(optInPaymentMethodsFailureSpy).toBeCalled(); - - // PotSomeError case - store.dispatch(fetchWalletsSuccess([mockPaymentMethodWithBPD])); - store.dispatch(fetchWalletsFailure(new Error("mockedError"))); - expect(optInPaymentMethodsFailureSpy).toBeCalled(); - - // PotSomeLoading case - store.dispatch(fetchWalletsRequest()); - expect(optInPaymentMethodsFailureSpy).toBeCalled(); - }); -}); - -function renderComponent(store: Store) { - return renderScreenWithNavigationStoreContext( - OptInPaymentMethodsCashbackUpdateScreen, - ROUTES.MAIN, - {}, - store - ); -} diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsChoiceScreen.test.tsx b/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsChoiceScreen.test.tsx deleted file mode 100644 index f66abfd675a..00000000000 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsChoiceScreen.test.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { fireEvent } from "@testing-library/react-native"; -import React from "react"; - -import { createStore } from "redux"; -import I18n from "../../../../../../i18n"; -import { appReducer } from "../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../store/reducers/types"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper"; -import BPD_ROUTES from "../../../navigation/routes"; -import OptInPaymentMethodsChoiceScreen from "../OptInPaymentMethodsChoiceScreen"; - -jest.useFakeTimers(); - -describe("the OptInPaymentMethodsChoiceScreen screen", () => { - it("should first render with a disabled button", () => { - const component = renderComponent(); - const disabledButton = component.getByTestId("disabledContinueButton"); - - expect(disabledButton).toBeTruthy(); - }); - - it("should show the activated primary button after selecting the `Keep` option", () => { - const component = renderComponent(); - - const firstOptionTitle = component.getByText( - I18n.t("bonus.bpd.optInPaymentMethods.choice.options.keepAll.title") - ); - - fireEvent.press(firstOptionTitle); - - const activeButton = component.getByTestId("continueButton"); - - expect(activeButton).toBeTruthy(); - }); -}); - -const renderComponent = () => - renderScreenWithNavigationStoreContext( - () => , - BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CHOICE, - {}, - createStore(appReducer) - ); diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouDeleteMethodsScreen.test.ts b/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouDeleteMethodsScreen.test.ts deleted file mode 100644 index 5e0663cc88d..00000000000 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouDeleteMethodsScreen.test.ts +++ /dev/null @@ -1,172 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { RenderAPI } from "@testing-library/react-native"; -import { createStore, Store } from "redux"; - -import { CitizenOptInStatusEnum } from "../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus"; -import ROUTES from "../../../../../../navigation/routes"; -import { applicationChangeState } from "../../../../../../store/actions/application"; -import { deleteAllPaymentMethodsByFunction } from "../../../../../../store/actions/wallet/delete"; -import { appReducer } from "../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../store/reducers/types"; -import { WalletsState } from "../../../../../../store/reducers/wallet/wallets"; -import * as showToast from "../../../../../../utils/showToast"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper"; -import { - remoteLoading, - remoteReady, - remoteUndefined -} from "../../../../../../common/model/RemoteValue"; -import { bpdUpdateOptInStatusMethod } from "../../../store/actions/onboarding"; -import OptInPaymentMethodsThankYouDeleteMethodsScreen from "../OptInPaymentMethodsThankYouDeleteMethodsScreen"; - -const loadingCases: ReadonlyArray< - [ - deletePaymentMethodsStatus: WalletsState["deleteAllByFunction"], - optInStatus: pot.Pot - ] -> = [ - [remoteUndefined, pot.none], - [remoteUndefined, pot.noneLoading], - [remoteUndefined, pot.noneUpdating(CitizenOptInStatusEnum.DENIED)], - [remoteUndefined, pot.noneError(new Error())], - [remoteUndefined, pot.some(CitizenOptInStatusEnum.DENIED)], - [remoteUndefined, pot.someLoading(CitizenOptInStatusEnum.DENIED)], - [ - remoteUndefined, - pot.someUpdating( - CitizenOptInStatusEnum.NOREQ, - CitizenOptInStatusEnum.DENIED - ) - ], - [remoteUndefined, pot.someError(CitizenOptInStatusEnum.DENIED, new Error())], - [remoteLoading, pot.none], - [remoteLoading, pot.noneLoading], - [remoteLoading, pot.noneUpdating(CitizenOptInStatusEnum.DENIED)], - [remoteLoading, pot.noneError(new Error())], - [remoteLoading, pot.some(CitizenOptInStatusEnum.DENIED)], - [remoteLoading, pot.someLoading(CitizenOptInStatusEnum.DENIED)], - [ - remoteLoading, - pot.someUpdating( - CitizenOptInStatusEnum.NOREQ, - CitizenOptInStatusEnum.DENIED - ) - ], - [remoteLoading, pot.someError(CitizenOptInStatusEnum.DENIED, new Error())], - [remoteReady({ deletedMethodsCount: 1 }), pot.none], - [remoteReady({ deletedMethodsCount: 1 }), pot.noneLoading], - [ - remoteReady({ deletedMethodsCount: 1 }), - pot.noneUpdating(CitizenOptInStatusEnum.DENIED) - ], - [ - remoteReady({ deletedMethodsCount: 1 }), - pot.someLoading(CitizenOptInStatusEnum.DENIED) - ], - [ - remoteReady({ deletedMethodsCount: 1 }), - pot.someUpdating( - CitizenOptInStatusEnum.NOREQ, - CitizenOptInStatusEnum.DENIED - ) - ] -]; - -jest.useFakeTimers(); -jest.mock("../../../../../../utils/showToast", () => ({ - showToast: jest.fn() -})); -describe("the OptInPaymentMethodsThankYouDeleteMethodsScreen screen", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - test.each(loadingCases)( - "Should render the loading component if delete payment methods status is %p and the opt-in status is %p", - (deleteAllByFunction, optInStatus) => { - const loadingState: GlobalState = { - ...globalState, - wallet: { - ...globalState.wallet, - wallets: { - ...globalState.wallet.wallets, - deleteAllByFunction - } - }, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - activation: { - ...globalState.bonus.bpd.details.activation, - optInStatus - } - } - } - } - }; - const store: Store = createStore( - appReducer, - loadingState as any - ); - const component: RenderAPI = renderComponent(store); - expect(component.getByTestId("loadingComponent")).toBeDefined(); - } - ); - it("Should render the RetryAfterDeletionFailsComponent if the delete payment methods status is error", () => { - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - store.dispatch( - deleteAllPaymentMethodsByFunction.failure({ error: new Error() }) - ); - - expect( - component.getByTestId("RetryAfterDeletionFailsComponent") - ).toBeDefined(); - }); - it("Should call the showToast and the optInPaymentMethodsCompleted functions if the delete payment methods status is ready and the opt-in status is error", () => { - const showToastSpy = jest.spyOn(showToast, "showToast"); - const store: Store = createStore( - appReducer, - globalState as any - ); - - store.dispatch( - deleteAllPaymentMethodsByFunction.success({ - wallets: [], - deletedMethodsCount: 0 - }) - ); - store.dispatch(bpdUpdateOptInStatusMethod.failure(new Error())); - renderComponent(store); - expect(showToastSpy).toBeCalledTimes(1); - }); - it("Should render the ThankYouSuccessComponent if the delete payment methods status is ready and the opt-in status is some", () => { - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - store.dispatch( - deleteAllPaymentMethodsByFunction.success({ - wallets: [], - deletedMethodsCount: 0 - }) - ); - store.dispatch( - bpdUpdateOptInStatusMethod.success(CitizenOptInStatusEnum.DENIED) - ); - expect(component.getByTestId("ThankYouSuccessComponent")).toBeDefined(); - }); -}); - -function renderComponent(store: Store) { - return renderScreenWithNavigationStoreContext( - OptInPaymentMethodsThankYouDeleteMethodsScreen, - ROUTES.MAIN, - {}, - store - ); -} diff --git a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouKeepMethodsScreen.test.ts b/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouKeepMethodsScreen.test.ts deleted file mode 100644 index 68951c772fa..00000000000 --- a/ts/features/bonus/bpd/screens/optInPaymentMethods/__tests__/OptInPaymentMethodsThankYouKeepMethodsScreen.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { RenderAPI } from "@testing-library/react-native"; -import { createStore, Store } from "redux"; - -import { CitizenOptInStatusEnum } from "../../../../../../../definitions/bpd/citizen_v2/CitizenOptInStatus"; -import ROUTES from "../../../../../../navigation/routes"; -import { applicationChangeState } from "../../../../../../store/actions/application"; -import { appReducer } from "../../../../../../store/reducers"; -import { GlobalState } from "../../../../../../store/reducers/types"; -import * as showToast from "../../../../../../utils/showToast"; -import { renderScreenWithNavigationStoreContext } from "../../../../../../utils/testWrapper"; -import { bpdUpdateOptInStatusMethod } from "../../../store/actions/onboarding"; -import OptInPaymentMethodsThankYouKeepMethodsScreen from "../OptInPaymentMethodsThankYouKeepMethodsScreen"; - -const loadingCases: ReadonlyArray< - [optInStatus: pot.Pot] -> = [ - [pot.none], - [pot.noneLoading], - [pot.noneUpdating(CitizenOptInStatusEnum.DENIED)], - [pot.someLoading(CitizenOptInStatusEnum.DENIED)], - [ - pot.someUpdating( - CitizenOptInStatusEnum.NOREQ, - CitizenOptInStatusEnum.DENIED - ) - ] -]; - -jest.useFakeTimers(); -jest.mock("../../../../../../utils/showToast", () => ({ - showToast: jest.fn() -})); -describe("the OptInPaymentMethodsThankYouKeepMethodsScreen screen", () => { - const globalState = appReducer(undefined, applicationChangeState("active")); - test.each(loadingCases)( - "Should render the loading component if the opt-in status is %p", - optInStatus => { - const loadingState: GlobalState = { - ...globalState, - bonus: { - ...globalState.bonus, - bpd: { - ...globalState.bonus.bpd, - details: { - ...globalState.bonus.bpd.details, - activation: { - ...globalState.bonus.bpd.details.activation, - optInStatus - } - } - } - } - }; - const store: Store = createStore( - appReducer, - loadingState as any - ); - const component: RenderAPI = renderComponent(store); - expect(component.getByTestId("loadingComponent")).toBeDefined(); - } - ); - it("Should call the showToast and the optInPaymentMethodsCompleted functions if the opt-in status is error", () => { - const showToastSpy = jest.spyOn(showToast, "showToast"); - const store: Store = createStore( - appReducer, - globalState as any - ); - - store.dispatch(bpdUpdateOptInStatusMethod.failure(new Error())); - renderComponent(store); - expect(showToastSpy).toBeCalledTimes(1); - }); - it("Should render the ThankYouSuccessComponent if the opt-in status is some", () => { - const store: Store = createStore( - appReducer, - globalState as any - ); - const component: RenderAPI = renderComponent(store); - store.dispatch( - bpdUpdateOptInStatusMethod.success(CitizenOptInStatusEnum.DENIED) - ); - expect(component.getByTestId("ThankYouSuccessComponent")).toBeDefined(); - }); -}); - -function renderComponent(store: Store) { - return renderScreenWithNavigationStoreContext( - OptInPaymentMethodsThankYouKeepMethodsScreen, - ROUTES.MAIN, - {}, - store - ); -} diff --git a/ts/features/bonus/common/screens/AvailableBonusScreen.tsx b/ts/features/bonus/common/screens/AvailableBonusScreen.tsx index 539893c07d2..d4720d971d6 100644 --- a/ts/features/bonus/common/screens/AvailableBonusScreen.tsx +++ b/ts/features/bonus/common/screens/AvailableBonusScreen.tsx @@ -4,7 +4,6 @@ import { pipe } from "fp-ts/lib/function"; import { Content } from "native-base"; import * as React from "react"; import { - Alert, FlatList, Linking, ListRenderItemInfo, @@ -17,7 +16,6 @@ import { connect } from "react-redux"; import { ServiceId } from "../../../../../definitions/backend/ServiceId"; import { ServicePublic } from "../../../../../definitions/backend/ServicePublic"; import { BonusAvailable } from "../../../../../definitions/content/BonusAvailable"; -import { BpdConfig } from "../../../../../definitions/content/BpdConfig"; import ItemSeparatorComponent from "../../../../components/ItemSeparatorComponent"; import { IOStyles } from "../../../../components/core/variables/IOStyles"; import { withLoadingSpinner } from "../../../../components/helpers/withLoadingSpinner"; @@ -26,7 +24,6 @@ import BaseScreenComponent, { } from "../../../../components/screens/BaseScreenComponent"; import GenericErrorComponent from "../../../../components/screens/GenericErrorComponent"; import FooterWithButtons from "../../../../components/ui/FooterWithButtons"; -import { bpdEnabled } from "../../../../config"; import I18n from "../../../../i18n"; import { ServiceDetailsScreenNavigationParams } from "../../../../screens/services/ServiceDetailsScreen"; import { @@ -39,7 +36,6 @@ import { } from "../../../../store/actions/services"; import { Dispatch } from "../../../../store/actions/types"; import { - bpdRemoteConfigSelector, isCGNEnabledSelector, isCdcEnabledSelector } from "../../../../store/reducers/backendStatus"; @@ -47,7 +43,6 @@ import { GlobalState } from "../../../../store/reducers/types"; import variables from "../../../../theme/variables"; import { storeUrl } from "../../../../utils/appVersion"; import { showToast } from "../../../../utils/showToast"; -import { getRemoteLocale } from "../../../messages/utils/messages"; import { bpdOnboardingStart } from "../../bpd/store/actions/onboarding"; import { cgnActivationStart } from "../../cgn/store/actions/activation"; import { @@ -63,7 +58,7 @@ import { serviceFromAvailableBonusSelector, supportedAvailableBonusSelector } from "../store/selectors"; -import { ID_BPD_TYPE, ID_CDC_TYPE, ID_CGN_TYPE } from "../utils"; +import { ID_CDC_TYPE, ID_CGN_TYPE } from "../utils"; export type Props = ReturnType & ReturnType; @@ -114,14 +109,7 @@ class AvailableBonusScreen extends React.PureComponent { }); }; - private completedAlert = (title: string) => { - Alert.alert(title, I18n.t("bonus.state.completed.description")); - }; - - private renderListItem = ( - info: ListRenderItemInfo, - bpdConfig: BpdConfig | undefined - ) => { + private renderListItem = (info: ListRenderItemInfo) => { const item = info.item; const handlersMap: Map void> = new Map< @@ -129,13 +117,6 @@ class AvailableBonusScreen extends React.PureComponent { (bonus: BonusAvailable) => void >(); - if (bpdEnabled) { - const bpdHandler = () => - this.completedAlert(info.item[getRemoteLocale()].name); - - handlersMap.set(ID_BPD_TYPE, _ => bpdHandler()); - } - if (this.props.isCgnEnabled) { handlersMap.set(ID_CGN_TYPE, _ => this.props.startCgnActivation()); } @@ -202,16 +183,8 @@ class AvailableBonusScreen extends React.PureComponent { const maybeIncoming: O.Option = item.visibility === "visible" && !handled ? O.some("incoming") : O.none; - // TODO: Atm only a custom case for the cashback, using the remote bpdConfiguration to choose if is finished - // see https://pagopa.atlassian.net/browse/IAI-22 for the complete bonus refactoring - const maybeFinished: O.Option = - info.item.id_type === ID_BPD_TYPE && !bpdConfig?.program_active - ? O.some("completed") - : O.none; - const state: AvailableBonusItemState = pipe( maybeIncoming, - O.alt(() => maybeFinished), O.getOrElseW(() => "active" as const) ); @@ -257,7 +230,7 @@ class AvailableBonusScreen extends React.PureComponent { this.renderListItem(b, this.props.bpdConfig)} + renderItem={b => this.renderListItem(b)} keyExtractor={item => item.id_type.toString()} ItemSeparatorComponent={() => ( @@ -280,7 +253,6 @@ const mapStateToProps = (state: GlobalState) => ({ isLoading: isAvailableBonusLoadingSelector(state), // show error only when we have an error and no data to show isError: isAvailableBonusNoneErrorSelector(state), - bpdConfig: bpdRemoteConfigSelector(state), isCgnEnabled: isCGNEnabledSelector(state), isCdcEnabled: isCdcEnabledSelector(state), cdcService: () => serviceFromAvailableBonusSelector(ID_CDC_TYPE)(state) diff --git a/ts/features/bonus/common/store/reducers/__tests__/availableBonusesTypes.test.ts b/ts/features/bonus/common/store/reducers/__tests__/availableBonusesTypes.test.ts index ef95773fcd3..9a02fcd16f8 100644 --- a/ts/features/bonus/common/store/reducers/__tests__/availableBonusesTypes.test.ts +++ b/ts/features/bonus/common/store/reducers/__tests__/availableBonusesTypes.test.ts @@ -6,7 +6,7 @@ import { } from "../../../../__mock__/availableBonuses"; import { BonusesAvailable } from "../../../../../../../definitions/content/BonusesAvailable"; import { BonusVisibilityEnum } from "../../../../../../../definitions/content/BonusVisibility"; -import { ID_BPD_TYPE, ID_CGN_TYPE } from "../../../../common/utils"; +import { ID_CGN_TYPE } from "../../../../common/utils"; import { BonusAvailable } from "../../../../../../../definitions/content/BonusAvailable"; import * as bonus from "../../../utils"; import { @@ -40,11 +40,7 @@ describe("availableBonusesTypes with FF enabled", () => { it("should return 1 bonus available", () => { jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, true] - ]) + () => new Map([[ID_CGN_TYPE, true]]) ); expect( supportedAvailableBonusSelector.resultFunc( @@ -58,7 +54,6 @@ describe("availableBonusesTypes with FF enabled", () => { // eslint-disable-next-line sonarjs/no-identical-functions () => new Map([ - [ID_BPD_TYPE, true], [ID_CGN_TYPE, true], [4, true] ]) @@ -80,7 +75,6 @@ describe("availableBonusesTypes with FF enabled", () => { // eslint-disable-next-line sonarjs/no-identical-functions () => new Map([ - [ID_BPD_TYPE, true], [ID_CGN_TYPE, true], [4, true] ]) @@ -115,15 +109,11 @@ describe("availableBonusesTypes with FF enabled", () => { // eslint-disable-next-line sonarjs/no-identical-functions () => new Map([ - [ID_BPD_TYPE, true], [ID_CGN_TYPE, true], [4, true] ]) ); - const visibility = BonusVisibilityEnum.experimental; - const bonuses: BonusesAvailable = [ - { ...mockBonus, id_type: ID_BPD_TYPE, visibility } - ]; + const bonuses: BonusesAvailable = []; const result = supportedAvailableBonusSelector.resultFunc( pot.some(bonuses) ); @@ -135,18 +125,12 @@ describe("availableBonusesTypes with FF enabled", () => { // eslint-disable-next-line sonarjs/no-identical-functions () => new Map([ - [ID_BPD_TYPE, true], [ID_CGN_TYPE, true], [4, true] ]) ); const visibility = BonusVisibilityEnum.experimental; const bonuses: BonusesAvailable = [ - { - ...mockBonus, - id_type: ID_BPD_TYPE, - visibility - }, { ...mockBonus, id_type: ID_CGN_TYPE, @@ -162,7 +146,7 @@ describe("availableBonusesTypes with FF enabled", () => { pot.some(bonuses) ); expect(result.length).toBe(1); - expect(result).toEqual([bonuses[1]]); + expect(result).toEqual([bonuses[0]]); }); }); diff --git a/ts/features/bonus/common/store/selectors/index.ts b/ts/features/bonus/common/store/selectors/index.ts index 786fa69ad04..9967af718e6 100644 --- a/ts/features/bonus/common/store/selectors/index.ts +++ b/ts/features/bonus/common/store/selectors/index.ts @@ -9,7 +9,7 @@ import { GlobalState } from "../../../../../store/reducers/types"; import { ServicePublic } from "../../../../../../definitions/backend/ServicePublic"; import { BonusVisibilityEnum } from "../../../../../../definitions/content/BonusVisibility"; import { servicesByIdSelector } from "../../../../../store/reducers/entities/services/servicesById"; -import { ID_BPD_TYPE, mapBonusIdFeatureFlag } from "../../utils"; +import { mapBonusIdFeatureFlag } from "../../utils"; import { AvailableBonusTypesState } from "../reducers/availableBonusesTypes"; /** @@ -38,11 +38,7 @@ export const supportedAvailableBonusSelector = createSelector( O.fromNullable, O.getOrElse(() => false) ); - return ( - b.id_type !== ID_BPD_TYPE && - isFeatureFlagEnabled && - experimentalAndVisibleBonus(b) - ); + return isFeatureFlagEnabled && experimentalAndVisibleBonus(b); }) ), [] @@ -99,19 +95,3 @@ export const serviceFromAvailableBonusSelector = (idBonusType: number) => O.chainNullableK(pot.toUndefined) ) ); - -/** - * Return the uri of the bonus vacanze image logo - */ -export const bonusVacanzeLogo = createSelector( - availableBonusTypesSelectorFromId(1), // BV ID - bonus => - pipe( - bonus, - O.fromNullable, - O.fold( - () => undefined, - b => b.cover - ) - ) -); diff --git a/ts/features/bonus/common/utils/index.ts b/ts/features/bonus/common/utils/index.ts index 463747970dd..6730c9cf796 100644 --- a/ts/features/bonus/common/utils/index.ts +++ b/ts/features/bonus/common/utils/index.ts @@ -1,6 +1,5 @@ -import { bpdEnabled, cdcEnabled } from "../../../../config"; +import { cdcEnabled } from "../../../../config"; -export const ID_BPD_TYPE = 2; export const ID_CGN_TYPE = 3; export const ID_CDC_TYPE = 4; @@ -11,7 +10,6 @@ export const ID_CDC_TYPE = 4; */ export const mapBonusIdFeatureFlag = () => new Map([ - [ID_BPD_TYPE, bpdEnabled], [ID_CGN_TYPE, true], [ID_CDC_TYPE, cdcEnabled] ]); diff --git a/ts/features/wallet/component/__test__/FeaturedCardCarousel.test.tsx b/ts/features/wallet/component/__test__/FeaturedCardCarousel.test.tsx index d32cd1bac97..955d882402f 100644 --- a/ts/features/wallet/component/__test__/FeaturedCardCarousel.test.tsx +++ b/ts/features/wallet/component/__test__/FeaturedCardCarousel.test.tsx @@ -1,186 +1,37 @@ import * as React from "react"; import configureMockStore, { MockStoreEnhanced } from "redux-mock-store"; -import FeaturedCardCarousel from "../card/FeaturedCardCarousel"; +import { BonusVisibilityEnum } from "../../../../../definitions/content/BonusVisibility"; import { appReducer } from "../../../../store/reducers"; -import { bpdLoadActivationStatus } from "../../../bonus/bpd/store/actions/details"; import { GlobalState } from "../../../../store/reducers/types"; +import { renderScreenWithNavigationStoreContext } from "../../../../utils/testWrapper"; import { availableBonuses } from "../../../bonus/__mock__/availableBonuses"; -import * as bonus from "../../../bonus/common/utils"; -import { ID_BPD_TYPE, ID_CGN_TYPE } from "../../../bonus/common/utils"; -import { BonusVisibilityEnum } from "../../../../../definitions/content/BonusVisibility"; import * as cgnDetailSelectors from "../../../bonus/cgn/store/reducers/details"; -import { renderScreenWithNavigationStoreContext } from "../../../../utils/testWrapper"; -import { MESSAGES_ROUTES } from "../../../messages/navigation/routes"; import { loadAvailableBonuses } from "../../../bonus/common/store/actions/availableBonusesTypes"; +import * as bonus from "../../../bonus/common/utils"; +import { ID_CGN_TYPE } from "../../../bonus/common/utils"; +import { MESSAGES_ROUTES } from "../../../messages/navigation/routes"; +import FeaturedCardCarousel from "../card/FeaturedCardCarousel"; jest.mock("react-native-share", () => jest.fn()); describe("FeaturedCardCarousel", () => { - it("BPD should not be displayed (FF enabled and BPD enrolled)", () => { - jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, false] - ]) - ); - const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: true, - activationStatus: "subscribed", - payoffInstr: undefined - }) - ); - const withBonusAvailable = appReducer( - withBpdEnabled, - loadAvailableBonuses.success(availableBonuses) - ); - - const component = getComponent(mockStore(withBonusAvailable)); - expect(component).toBeDefined(); - const featuredCardCarousel = component.queryByTestId( - "FeaturedCardCarousel" - ); - expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - // bpd is enrolled so the item should be not displayed - expect(bpdItem).toBeNull(); - }); - - it("BPD should not be displayed (FF not enabled and BPD enrolled)", () => { - jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( - () => - new Map([ - [ID_BPD_TYPE, false], - [ID_CGN_TYPE, false] - ]) - ); - const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: true, - activationStatus: "subscribed", - payoffInstr: undefined - }) - ); - const withBonusAvailable = appReducer( - withBpdEnabled, - loadAvailableBonuses.success(availableBonuses) - ); - - const component = getComponent(mockStore(withBonusAvailable)); - expect(component).toBeDefined(); - const featuredCardCarousel = component.queryByTestId( - "FeaturedCardCarousel" - ); - expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); - }); - - it("BPD should not be displayed (FF not enabled and BPD not enrolled)", () => { + it("CGN should be not displayed (FF off, CGN not enrolled)", () => { jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, false], - [ID_CGN_TYPE, false] - ]) - ); - const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: false, - activationStatus: "never", - payoffInstr: undefined - }) - ); - const withBonusAvailable = appReducer( - withBpdEnabled, - loadAvailableBonuses.success(availableBonuses) - ); - - const component = getComponent(mockStore(withBonusAvailable)); - expect(component).toBeDefined(); - const featuredCardCarousel = component.queryByTestId( - "FeaturedCardCarousel" - ); - expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); - }); - - it("BPD should not be displayed (FF enabled and BPD enrolled loading and visibility visible)", () => { - jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( - // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, false] - ]) - ); - const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.request() - ); - const bpdBonus = availableBonuses[1]; - const updatedAvailableBonuses = availableBonuses.filter( - b => b.id_type !== ID_BPD_TYPE - ); - const withBonusAvailable = appReducer( - withBpdEnabled, - loadAvailableBonuses.success([ - ...updatedAvailableBonuses, - { ...bpdBonus, visibility: BonusVisibilityEnum.visible } - ]) - ); - - const component = getComponent(mockStore(withBonusAvailable)); - expect(component).toBeDefined(); - const featuredCardCarousel = component.queryByTestId( - "FeaturedCardCarousel" - ); - expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); - }); - - it("BPD and CGN should be not displayed (FF off, BPD not enrolled, CGN not enrolled)", () => { - jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( - // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, false], - [ID_CGN_TYPE, false] - ]) + () => new Map([[ID_CGN_TYPE, false]]) ); jest .spyOn(cgnDetailSelectors, "isCgnEnrolledSelector") .mockImplementation(() => false); const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: false, - activationStatus: "never", - payoffInstr: undefined - }) - ); - const bpdBonus = availableBonuses[1]; const cgnBonus = availableBonuses[2]; const updatedAvailableBonuses = availableBonuses.filter( - b => b.id_type !== ID_BPD_TYPE && b.id_type !== ID_CGN_TYPE + b => b.id_type !== ID_CGN_TYPE ); const withBonusAvailable = appReducer( - withBpdEnabled, + undefined, loadAvailableBonuses.success([ ...updatedAvailableBonuses, - { ...bpdBonus, visibility: BonusVisibilityEnum.visible }, { ...cgnBonus, visibility: BonusVisibilityEnum.visible } ]) ); @@ -191,44 +42,28 @@ describe("FeaturedCardCarousel", () => { "FeaturedCardCarousel" ); expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); const cgnItem = component.queryByTestId("FeaturedCardCGNTestID"); expect(cgnItem).toBeNull(); }); - it("BPD and CGN should be not displayed (FF on, BPD enrolled, CGN enrolled)", () => { + it("CGN should be not displayed (FF on, CGN enrolled)", () => { jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, true] - ]) + () => new Map([[ID_CGN_TYPE, true]]) ); jest .spyOn(cgnDetailSelectors, "isCgnEnrolledSelector") .mockImplementation(() => true); const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: true, - activationStatus: "subscribed", - payoffInstr: undefined - }) - ); - const bpdBonus = availableBonuses[1]; const cgnBonus = availableBonuses[2]; const updatedAvailableBonuses = availableBonuses.filter( - b => b.id_type !== ID_BPD_TYPE && b.id_type !== ID_CGN_TYPE + b => b.id_type !== ID_CGN_TYPE ); const withBonusAvailable = appReducer( - withBpdEnabled, + undefined, loadAvailableBonuses.success([ ...updatedAvailableBonuses, - { ...bpdBonus, visibility: BonusVisibilityEnum.visible }, { ...cgnBonus, visibility: BonusVisibilityEnum.visible } ]) ); @@ -239,40 +74,28 @@ describe("FeaturedCardCarousel", () => { "FeaturedCardCarousel" ); expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); const cgnItem = component.queryByTestId("FeaturedCardCGNTestID"); expect(cgnItem).toBeNull(); }); - it("BPD and CGN should be not displayed (FF on, BPD loading, CGN undefined)", () => { + it("CGN should be not displayed (FF on, CGN undefined)", () => { jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, true] - ]) + () => new Map([[ID_CGN_TYPE, true]]) ); jest .spyOn(cgnDetailSelectors, "isCgnEnrolledSelector") .mockImplementation(() => undefined); const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.request() - ); - const bpdBonus = availableBonuses[1]; const cgnBonus = availableBonuses[2]; const updatedAvailableBonuses = availableBonuses.filter( - b => b.id_type !== ID_BPD_TYPE && b.id_type !== ID_CGN_TYPE + b => b.id_type !== ID_CGN_TYPE ); const withBonusAvailable = appReducer( - withBpdEnabled, + undefined, loadAvailableBonuses.success([ ...updatedAvailableBonuses, - { ...bpdBonus, visibility: BonusVisibilityEnum.visible }, { ...cgnBonus, visibility: BonusVisibilityEnum.visible } ]) ); @@ -283,44 +106,28 @@ describe("FeaturedCardCarousel", () => { "FeaturedCardCarousel" ); expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); const cgnItem = component.queryByTestId("FeaturedCardCGNTestID"); expect(cgnItem).toBeNull(); }); - it("BPD and CGN should be not displayed (FF on, BPD not enrolled, CGN not enrolled, bonus visibility hidden)", () => { + it("CGN should be not displayed (FF on, CGN not enrolled, bonus visibility hidden)", () => { jest.spyOn(bonus, "mapBonusIdFeatureFlag").mockImplementation( // eslint-disable-next-line sonarjs/no-identical-functions - () => - new Map([ - [ID_BPD_TYPE, true], - [ID_CGN_TYPE, true] - ]) + () => new Map([[ID_CGN_TYPE, true]]) ); jest .spyOn(cgnDetailSelectors, "isCgnEnrolledSelector") .mockImplementation(() => false); const mockStore = configureMockStore(); - const withBpdEnabled: GlobalState = appReducer( - undefined, - bpdLoadActivationStatus.success({ - enabled: true, - activationStatus: "subscribed", - payoffInstr: undefined - }) - ); - const bpdBonus = availableBonuses[1]; const cgnBonus = availableBonuses[2]; const updatedAvailableBonuses = availableBonuses.filter( - b => b.id_type !== ID_BPD_TYPE && b.id_type !== ID_CGN_TYPE + b => b.id_type !== ID_CGN_TYPE ); const withBonusAvailable = appReducer( - withBpdEnabled, + undefined, loadAvailableBonuses.success([ ...updatedAvailableBonuses, - { ...bpdBonus, visibility: BonusVisibilityEnum.hidden }, { ...cgnBonus, visibility: BonusVisibilityEnum.hidden } ]) ); @@ -331,8 +138,6 @@ describe("FeaturedCardCarousel", () => { "FeaturedCardCarousel" ); expect(featuredCardCarousel).toBeNull(); - const bpdItem = component.queryByTestId("FeaturedCardBPDTestID"); - expect(bpdItem).toBeNull(); const cgnItem = component.queryByTestId("FeaturedCardCGNTestID"); expect(cgnItem).toBeNull(); }); diff --git a/ts/navigation/AppStackNavigator.tsx b/ts/navigation/AppStackNavigator.tsx index 35c0e5be766..63e73a3ad5f 100644 --- a/ts/navigation/AppStackNavigator.tsx +++ b/ts/navigation/AppStackNavigator.tsx @@ -7,20 +7,15 @@ import { import * as React from "react"; import { useRef } from "react"; import { View } from "react-native"; +import { useStoredExperimentalDesign } from "../common/context/DSExperimentalContext"; import LoadingSpinnerOverlay from "../components/LoadingSpinnerOverlay"; -import { - bpdEnabled, - bpdOptInPaymentMethodsEnabled, - fimsEnabled, - myPortalEnabled, - svEnabled -} from "../config"; -import BPD_ROUTES from "../features/bonus/bpd/navigation/routes"; +import { fimsEnabled, myPortalEnabled, svEnabled } from "../config"; import { cgnLinkingOptions } from "../features/bonus/cgn/navigation/navigator"; import { svLinkingOptions } from "../features/bonus/siciliaVola/navigation/navigator"; import { fciLinkingOptions } from "../features/fci/navigation/FciStackNavigator"; import { fimsLinkingOptions } from "../features/fims/navigation/navigator"; import { idPayLinkingOptions } from "../features/idpay/common/navigation/linking"; +import { MESSAGES_ROUTES } from "../features/messages/navigation/routes"; import UADONATION_ROUTES from "../features/uaDonations/navigation/routes"; import IngressScreen from "../screens/ingress/IngressScreen"; import { startApplicationInitialization } from "../store/actions/application"; @@ -28,19 +23,16 @@ import { setDebugCurrentRouteName } from "../store/actions/debug"; import { useIODispatch, useIOSelector } from "../store/hooks"; import { trackScreen } from "../store/middlewares/navigation"; import { - bpdRemoteConfigSelector, isCGNEnabledSelector, isFIMSEnabledSelector } from "../store/reducers/backendStatus"; import { StartupStatusEnum, isStartupLoaded } from "../store/reducers/startup"; +import { IONavigationLightTheme } from "../theme/navigations"; import { isTestEnv } from "../utils/environment"; import { IO_INTERNAL_LINK_PREFIX, IO_UNIVERSAL_LINK_PREFIX } from "../utils/navigation"; -import { useStoredExperimentalDesign } from "../common/context/DSExperimentalContext"; -import { IONavigationLightTheme } from "../theme/navigations"; -import { MESSAGES_ROUTES } from "../features/messages/navigation/routes"; import AuthenticatedStackNavigator from "./AuthenticatedStackNavigator"; import NavigationService, { navigationRef, @@ -90,10 +82,6 @@ const InnerNavigationContainer = (props: { children: React.ReactElement }) => { const cgnEnabled = useIOSelector(isCGNEnabledSelector); const isFimsEnabled = useIOSelector(isFIMSEnabledSelector) && fimsEnabled; - const bpdRemoteConfig = useIOSelector(bpdRemoteConfigSelector); - const isOptInPaymentMethodsEnabled = - bpdRemoteConfig?.opt_in_payment_methods_v2 && bpdOptInPaymentMethodsEnabled; - const linking: LinkingOptions = { enabled: !isTestEnv, // disable linking in test env prefixes: [IO_INTERNAL_LINK_PREFIX, IO_UNIVERSAL_LINK_PREFIX], @@ -122,18 +110,7 @@ const InnerNavigationContainer = (props: { children: React.ReactElement }) => { screens: { [ROUTES.PAYMENTS_HISTORY_SCREEN]: "payments-history", [ROUTES.CREDIT_CARD_ONBOARDING_ATTEMPTS_SCREEN]: - "card-onboarding-attempts", - ...(bpdEnabled && { - [BPD_ROUTES.CTA_BPD_IBAN_EDIT]: "bpd-iban-update" - }), - ...(isOptInPaymentMethodsEnabled && { - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.MAIN]: { - path: "bpd-opt-in", - screens: { - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS.CHOICE]: "choice" - } - } - }) + "card-onboarding-attempts" } }, [ROUTES.SERVICES_NAVIGATOR]: { diff --git a/ts/navigation/WalletNavigator.tsx b/ts/navigation/WalletNavigator.tsx index c2c56e87e34..ebfcf759141 100644 --- a/ts/navigation/WalletNavigator.tsx +++ b/ts/navigation/WalletNavigator.tsx @@ -1,14 +1,5 @@ import { createStackNavigator } from "@react-navigation/stack"; import * as React from "react"; -import { bpdOptInPaymentMethodsEnabled } from "../config"; -import { - BpdDetailsNavigator, - BpdOnboardingNavigator, - OptInPaymentMethodNavigator -} from "../features/bonus/bpd/navigation/navigator"; -import BPD_ROUTES from "../features/bonus/bpd/navigation/routes"; -import IbanCTAEditScreen from "../features/bonus/bpd/screens/iban/IbanCTAEditScreen"; -import MainIbanScreen from "../features/bonus/bpd/screens/iban/MainIbanScreen"; import { BONUS_ROUTES, BonusNavigator @@ -20,10 +11,8 @@ import CobadgeDetailScreen from "../features/wallet/cobadge/screen/CobadgeDetail import CreditCardDetailScreen from "../features/wallet/creditCard/screen/CreditCardDetailScreen"; import PaymentMethodOnboardingBPayNavigator from "../features/wallet/onboarding/bancomatPay/navigation/navigator"; import WALLET_ONBOARDING_BPAY_ROUTES from "../features/wallet/onboarding/bancomatPay/navigation/routes"; -import ActivateBpdOnNewBPayScreen from "../features/wallet/onboarding/bancomatPay/screens/ActivateBpdOnNewBPayScreen"; import PaymentMethodOnboardingCoBadgeNavigator from "../features/wallet/onboarding/cobadge/navigation/navigator"; import WALLET_ONBOARDING_COBADGE_ROUTES from "../features/wallet/onboarding/cobadge/navigation/routes"; -import ActivateBpdOnNewCoBadgeScreen from "../features/wallet/onboarding/cobadge/screens/ActivateBpdOnNewCoBadgeScreen"; import { PaymentMethodOnboardingPayPalOnboardingNavigator } from "../features/wallet/onboarding/paypal/navigation/navigator"; import PAYPAL_ROUTES from "../features/wallet/onboarding/paypal/navigation/routes"; import PayPalPspUpdateScreen from "../features/wallet/paypal/screen/PayPalPspUpdateScreen"; @@ -45,166 +34,130 @@ import PickPspScreen from "../screens/wallet/payment/PickPspScreen"; import ScanQrCodeScreen from "../screens/wallet/payment/ScanQrCodeScreen"; import TransactionErrorScreen from "../screens/wallet/payment/TransactionErrorScreen"; import TransactionSummaryScreen from "../screens/wallet/payment/TransactionSummaryScreen"; -import { useIOSelector } from "../store/hooks"; -import { bpdRemoteConfigSelector } from "../store/reducers/backendStatus"; import ROUTES from "./routes"; const Stack = createStackNavigator(); -const bptRoutes = () => ( +const bpay_cobadge_routes = () => ( <> - + +); + +const WalletNavigator = () => ( + - -); - -const WalletNavigator = () => { - const bpdRemoteConfig = useIOSelector(bpdRemoteConfigSelector); - const isOptInPaymentMethodsEnabled = - bpdRemoteConfig?.opt_in_payment_methods_v2 && bpdOptInPaymentMethodsEnabled; - - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - {/* Paypal */} - - {/* Bonus */} - + + + + + + + + + + + + + + + + + + + + {/* Paypal */} + + {/* Bonus */} + - {/* BPD */} - {bptRoutes()} - {/* BPD Opt-In */} - {isOptInPaymentMethodsEnabled && ( - - )} - - ); -}; + {/* BPD */} + {bpay_cobadge_routes()} + +); export default WalletNavigator; diff --git a/ts/navigation/params/WalletParamsList.ts b/ts/navigation/params/WalletParamsList.ts index e228a78851f..1aeea2ef5b0 100644 --- a/ts/navigation/params/WalletParamsList.ts +++ b/ts/navigation/params/WalletParamsList.ts @@ -1,10 +1,4 @@ import { NavigatorScreenParams } from "@react-navigation/native"; -import { - BpdDetailsParamsList, - BpdOnboardingParamsList, - BpdOptInParamsList -} from "../../features/bonus/bpd/navigation/params"; -import BPD_ROUTES from "../../features/bonus/bpd/navigation/routes"; import { IdPayInstrumentInitiativesScreenRouteParams } from "../../features/idpay/wallet/screens/IdPayInstrumentInitiativesScreen"; import { BancomatDetailScreenNavigationParams } from "../../features/wallet/bancomat/screen/BancomatDetailScreen"; import { BPayDetailScreenNavigationParams } from "../../features/wallet/bancomatpay/screen/BPayDetailScreen"; @@ -62,14 +56,6 @@ export type WalletParamsList = { [BONUS_ROUTES.MAIN]: undefined; - [BPD_ROUTES.ONBOARDING.MAIN]: NavigatorScreenParams; - [BPD_ROUTES.DETAILS_MAIN]: NavigatorScreenParams; - [BPD_ROUTES.CTA_BPD_IBAN_EDIT]: undefined; - [BPD_ROUTES.IBAN]: undefined; - - [BPD_ROUTES.OPT_IN_PAYMENT_METHODS - .MAIN]: NavigatorScreenParams; - [WALLET_ONBOARDING_BPAY_ROUTES.MAIN]: NavigatorScreenParams; [WALLET_ONBOARDING_COBADGE_ROUTES.MAIN]: NavigatorScreenParams; [PAYPAL_ROUTES.ONBOARDING diff --git a/ts/sagas/startup.ts b/ts/sagas/startup.ts index e8d0594bb0d..82cb9d94987 100644 --- a/ts/sagas/startup.ts +++ b/ts/sagas/startup.ts @@ -1,7 +1,9 @@ -import * as O from "fp-ts/lib/Option"; import * as pot from "@pagopa/ts-commons/lib/pot"; import { Millisecond } from "@pagopa/ts-commons/lib/units"; +import * as O from "fp-ts/lib/Option"; +import { pipe } from "fp-ts/lib/function"; import { Alert } from "react-native"; +import PushNotification from "react-native-push-notification"; import { channel } from "redux-saga"; import { call, @@ -16,14 +18,11 @@ import { takeLatest } from "typed-redux-saga/macro"; import { ActionType, getType } from "typesafe-actions"; -import { pipe } from "fp-ts/lib/function"; -import PushNotification from "react-native-push-notification"; import { UserDataProcessingChoiceEnum } from "../../definitions/backend/UserDataProcessingChoice"; import { UserDataProcessingStatusEnum } from "../../definitions/backend/UserDataProcessingStatus"; import { BackendClient } from "../api/backend"; import { apiUrlPrefix, - bpdEnabled, cdcEnabled, euCovidCertificateEnabled, pagoPaApiUrlPrefix, @@ -31,17 +30,34 @@ import { svEnabled, zendeskEnabled } from "../config"; -import { watchBonusSaga } from "../features/bonus/common/store/sagas/bonusSaga"; -import { watchBonusBpdSaga } from "../features/bonus/bpd/saga"; +import { watchBonusCdcSaga } from "../features/bonus/cdc/saga"; import { watchBonusCgnSaga } from "../features/bonus/cgn/saga"; +import { watchBonusSaga } from "../features/bonus/common/store/sagas/bonusSaga"; import { watchBonusSvSaga } from "../features/bonus/siciliaVola/saga"; import { watchEUCovidCertificateSaga } from "../features/euCovidCert/saga"; +import { setSecurityAdviceReadyToShow } from "../features/fastLogin/store/actions/securityAdviceActions"; +import { refreshSessionToken } from "../features/fastLogin/store/actions/tokenRefreshActions"; +import { + isFastLoginEnabledSelector, + tokenRefreshSelector +} from "../features/fastLogin/store/selectors"; +import { watchFciSaga } from "../features/fci/saga"; +import { watchIDPaySaga } from "../features/idpay/common/saga"; +import { checkPublicKeyAndBlockIfNeeded } from "../features/lollipop/navigation"; +import { + checkLollipopSessionAssertionAndInvalidateIfNeeded, + generateLollipopKeySaga, + getKeyInfo +} from "../features/lollipop/saga"; +import { lollipopPublicKeySelector } from "../features/lollipop/store/reducers/lollipop"; +import { watchMessagesSaga } from "../features/messages/saga"; +import { handleClearAllAttachments } from "../features/messages/saga/handleClearAttachments"; +import { watchPnSaga } from "../features/pn/store/sagas/watchPnSaga"; +import { watchWalletSaga as watchWalletV3Saga } from "../features/walletV3/common/saga"; import { watchZendeskGetSessionSaga, watchZendeskSupportSaga } from "../features/zendesk/saga"; -import { watchFciSaga } from "../features/fci/saga"; -import { watchWalletSaga as watchWalletV3Saga } from "../features/walletV3/common/saga"; import I18n from "../i18n"; import { mixpanelTrack } from "../mixpanel"; import NavigationService from "../navigation/NavigationService"; @@ -50,6 +66,11 @@ import { startApplicationInitialization } from "../store/actions/application"; import { sessionExpired } from "../store/actions/authentication"; +import { backendStatusLoadSuccess } from "../store/actions/backendStatus"; +import { + differentProfileLoggedIn, + setProfileHashedFiscalCode +} from "../store/actions/crossSessions"; import { previousInstallationDataDeleteSuccess } from "../store/actions/installation"; import { setMixpanelEnabled } from "../store/actions/mixpanel"; import { navigateToPrivacyScreen } from "../store/actions/navigation"; @@ -59,16 +80,16 @@ import { profileLoadSuccess, resetProfileState } from "../store/actions/profile"; +import { startupLoadSuccess } from "../store/actions/startup"; import { loadUserDataProcessing } from "../store/actions/userDataProcessing"; import { sessionInfoSelector, sessionTokenSelector } from "../store/reducers/authentication"; import { - checkLollipopSessionAssertionAndInvalidateIfNeeded, - generateLollipopKeySaga, - getKeyInfo -} from "../features/lollipop/saga"; + backendStatusSelector, + isPnEnabledSelector +} from "../store/reducers/backendStatus"; import { IdentificationResult } from "../store/reducers/identification"; import { isIdPayTestEnabledSelector, @@ -78,34 +99,15 @@ import { isProfileFirstOnBoarding, profileSelector } from "../store/reducers/profile"; +import { StartupStatusEnum } from "../store/reducers/startup"; import { ReduxSagaEffect, SagaCallReturnType } from "../types/utils"; +import { trackKeychainGetFailure } from "../utils/analytics"; import { isTestEnv } from "../utils/environment"; import { deletePin, getPin } from "../utils/keychain"; -import { watchBonusCdcSaga } from "../features/bonus/cdc/saga"; -import { - differentProfileLoggedIn, - setProfileHashedFiscalCode -} from "../store/actions/crossSessions"; -import { handleClearAllAttachments } from "../features/messages/saga/handleClearAttachments"; -import { watchMessagesSaga } from "../features/messages/saga"; -import { watchPnSaga } from "../features/pn/store/sagas/watchPnSaga"; -import { startupLoadSuccess } from "../store/actions/startup"; -import { watchIDPaySaga } from "../features/idpay/common/saga"; -import { StartupStatusEnum } from "../store/reducers/startup"; -import { trackKeychainGetFailure } from "../utils/analytics"; -import { checkPublicKeyAndBlockIfNeeded } from "../features/lollipop/navigation"; -import { lollipopPublicKeySelector } from "../features/lollipop/store/reducers/lollipop"; import { - isFastLoginEnabledSelector, - tokenRefreshSelector -} from "../features/fastLogin/store/selectors"; -import { backendStatusLoadSuccess } from "../store/actions/backendStatus"; -import { - backendStatusSelector, - isPnEnabledSelector -} from "../store/reducers/backendStatus"; -import { refreshSessionToken } from "../features/fastLogin/store/actions/tokenRefreshActions"; -import { setSecurityAdviceReadyToShow } from "../features/fastLogin/store/actions/securityAdviceActions"; + clearKeychainError, + keychainError +} from "./../store/storages/keychain"; import { startAndReturnIdentificationResult } from "./identification"; import { previousInstallationDataDeleteSaga } from "./installation"; import { @@ -118,6 +120,7 @@ import { handlePendingMessageStateIfAllowedSaga, updateInstallationSaga } from "./notifications"; +import { setLanguageFromProfileIfExists } from "./preferences"; import { loadProfile, watchProfile, @@ -130,11 +133,14 @@ import { checkAppHistoryVersionSaga } from "./startup/appVersionHistorySaga"; import { authenticationSaga } from "./startup/authenticationSaga"; import { checkAcceptedTosSaga } from "./startup/checkAcceptedTosSaga"; import { checkAcknowledgedEmailSaga } from "./startup/checkAcknowledgedEmailSaga"; -import { checkAcknowledgedFingerprintSaga } from "./startup/onboarding/biometric/checkAcknowledgedFingerprintSaga"; import { checkConfiguredPinSaga } from "./startup/checkConfiguredPinSaga"; import { watchEmailNotificationPreferencesSaga } from "./startup/checkEmailNotificationPreferencesSaga"; +import { checkEmailSaga } from "./startup/checkEmailSaga"; +import { checkNotificationsPreferencesSaga } from "./startup/checkNotificationsPreferencesSaga"; import { checkProfileEnabledSaga } from "./startup/checkProfileEnabledSaga"; +import { completeOnboardingSaga } from "./startup/completeOnboardingSaga"; import { loadSessionInformationSaga } from "./startup/loadSessionInformationSaga"; +import { checkAcknowledgedFingerprintSaga } from "./startup/onboarding/biometric/checkAcknowledgedFingerprintSaga"; import { watchAbortOnboardingSaga } from "./startup/watchAbortOnboardingSaga"; import { checkSession, @@ -150,14 +156,6 @@ import { } from "./user/userMetadata"; import { watchWalletSaga } from "./wallet"; import { watchProfileEmailValidationChangedSaga } from "./watchProfileEmailValidationChangedSaga"; -import { completeOnboardingSaga } from "./startup/completeOnboardingSaga"; -import { checkNotificationsPreferencesSaga } from "./startup/checkNotificationsPreferencesSaga"; -import { - clearKeychainError, - keychainError -} from "./../store/storages/keychain"; -import { setLanguageFromProfileIfExists } from "./preferences"; -import { checkEmailSaga } from "./startup/checkEmailSaga"; const WAIT_INITIALIZE_SAGA = 5000 as Millisecond; const navigatorPollingTime = 125 as Millisecond; @@ -523,11 +521,6 @@ export function* initializeApplicationSaga( yield* fork(watchZendeskGetSessionSaga, backendClient.getSession); } - if (bpdEnabled) { - // Start watching for bpd actions - yield* fork(watchBonusBpdSaga, maybeSessionInformation.value.bpdToken); - } - if (cdcEnabled) { // Start watching for cdc actions yield* fork(watchBonusCdcSaga, maybeSessionInformation.value.bpdToken); diff --git a/ts/sagas/wallet.ts b/ts/sagas/wallet.ts index 2aa95bc7c20..c117adb37a5 100644 --- a/ts/sagas/wallet.ts +++ b/ts/sagas/wallet.ts @@ -6,7 +6,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot"; import { DeferredPromise } from "@pagopa/ts-commons/lib/promises"; import { Millisecond } from "@pagopa/ts-commons/lib/units"; -import { CommonActions, StackActions } from "@react-navigation/native"; +import { CommonActions } from "@react-navigation/native"; import * as E from "fp-ts/lib/Either"; import * as O from "fp-ts/lib/Option"; import { pipe } from "fp-ts/lib/function"; @@ -21,18 +21,15 @@ import { takeLatest } from "typed-redux-saga/macro"; import { ActionType, getType, isActionOf } from "typesafe-actions"; -import { EnableableFunctionsEnum } from "../../definitions/pagopa/EnableableFunctions"; import { TypeEnum } from "../../definitions/pagopa/Wallet"; import { BackendClient } from "../api/backend"; import { ContentClient } from "../api/content"; import { PaymentManagerClient } from "../api/pagopa"; import { apiUrlPrefix, - bpdEnabled, fetchPagoPaTimeout, fetchPaymentManagerLongTimeout } from "../config"; -import { bpdEnabledSelector } from "../features/bonus/bpd/store/reducers/details/activation"; import { handleAddPan, handleLoadAbi, @@ -118,18 +115,14 @@ import { setWalletSessionEnabled, updatePaymentStatus } from "../store/actions/wallet/wallets"; -import { bpdRemoteConfigSelector } from "../store/reducers/backendStatus"; + import { isProfileEmailValidatedSelector } from "../store/reducers/profile"; import { GlobalState } from "../store/reducers/types"; import { lastPaymentOutcomeCodeSelector } from "../store/reducers/wallet/outcomeCode"; import { paymentIdSelector } from "../store/reducers/wallet/payment"; import { getAllWallets } from "../store/reducers/wallet/wallets"; import { SessionToken } from "../types/SessionToken"; -import { - NullableWallet, - PaymentManagerToken, - isRawCreditCard -} from "../types/pagopa"; +import { NullableWallet, PaymentManagerToken } from "../types/pagopa"; import { ReduxSagaEffect } from "../types/utils"; import { SessionManager } from "../utils/SessionManager"; import { waitBackoffError } from "../utils/backoffError"; @@ -137,7 +130,6 @@ import { isTestEnv } from "../utils/environment"; import { convertUnknownToError } from "../utils/errors"; import { defaultRetryingFetch } from "../utils/fetch"; import { newLookUpId, resetLookUpId } from "../utils/pmLookUpId"; -import { hasFunctionEnabled } from "../utils/walletv2"; import { paymentsDeleteUncompletedSaga } from "./payments"; import { sendAddCobadgeMessageSaga } from "./wallet/cobadgeReminder"; import { @@ -305,35 +297,6 @@ function* startOrResumeAddCreditCardSaga( if (maybeAddedWallet !== undefined) { // Add a delay to allow the user to see the thank you page yield* delay(successScreenDelay); - // check if the new method is compliant with bpd - if (bpdEnabled) { - const bpdEnroll: ReturnType = - yield* select(bpdEnabledSelector); - const hasBpdFeature = hasFunctionEnabled( - maybeAddedWallet.paymentMethod, - EnableableFunctionsEnum.BPD - ); - // if the method is bpd compliant check if we have info about bpd activation - if (hasBpdFeature && pot.isSome(bpdEnroll)) { - const bpdRemoteConfig: ReturnType< - typeof bpdRemoteConfigSelector - > = yield* select(bpdRemoteConfigSelector); - // if bdp is active navigate to a screen where it asked to enroll that method in bpd - // otherwise navigate to a screen where is asked to join bpd - if ( - bpdEnroll.value && - isRawCreditCard(maybeAddedWallet.paymentMethod) && - bpdRemoteConfig?.program_active - ) { - // remove all the screens from the add credit card screen - // beware this is very dangerous if the screen number changes, but is the only way with this legacy flow - yield* call( - NavigationService.dispatchNavigationAction, - StackActions.pop(5) - ); - } - } - } // signal the completion if (action.payload.onSuccess) { action.payload.onSuccess(maybeAddedWallet); @@ -785,77 +748,77 @@ export function* watchWalletSaga( getPspV2WithCallbacks ); - if (bpdEnabled) { - const contentClient = ContentClient(); + // here it used to check for BPD enabled + const contentClient = ContentClient(); - // watch for load abi request - yield* takeLatest(loadAbi.request, handleLoadAbi, contentClient.getAbiList); + // watch for load abi request + yield* takeLatest(loadAbi.request, handleLoadAbi, contentClient.getAbiList); - // watch for load pans request - yield* takeLatest( - searchUserPans.request, - handleLoadPans, - paymentManagerClient.getPans, - pmSessionManager - ); + // watch for load pans request + yield* takeLatest( + searchUserPans.request, + handleLoadPans, + paymentManagerClient.getPans, + pmSessionManager + ); - // watch for add pan request - yield* takeLatest( - addBancomatToWallet.request, - handleAddPan, - paymentManagerClient.addPans, - pmSessionManager - ); + // watch for add pan request + yield* takeLatest( + addBancomatToWallet.request, + handleAddPan, + paymentManagerClient.addPans, + pmSessionManager + ); - // watch for add BPay to Wallet workflow - yield* takeLatest(walletAddBPayStart, addBPayToWalletAndActivateBpd); + // watch for add BPay to Wallet workflow + yield* takeLatest(walletAddBPayStart, addBPayToWalletAndActivateBpd); - // watch for BancomatPay search request - yield* takeLatest( - searchUserBPay.request, - handleSearchUserBPay, - paymentManagerClient.searchBPay, - pmSessionManager - ); - // watch for add BancomatPay to the user's wallet - yield* takeLatest( - addBPayToWallet.request, - handleAddpayToWallet, - paymentManagerClient.addBPayToWallet, - pmSessionManager - ); + // watch for BancomatPay search request + yield* takeLatest( + searchUserBPay.request, + handleSearchUserBPay, + paymentManagerClient.searchBPay, + pmSessionManager + ); + // watch for add BancomatPay to the user's wallet + yield* takeLatest( + addBPayToWallet.request, + handleAddpayToWallet, + paymentManagerClient.addBPayToWallet, + pmSessionManager + ); - // watch for CoBadge search request - yield* takeLatest( - searchUserCoBadge.request, - handleSearchUserCoBadge, - paymentManagerClient.getCobadgePans, - paymentManagerClient.searchCobadgePans, - pmSessionManager - ); - // watch for add CoBadge to the user's wallet - yield* takeLatest( - addCoBadgeToWallet.request, - handleAddCoBadgeToWallet, - paymentManagerClient.addCobadgeToWallet, - pmSessionManager - ); - // watch for CoBadge configuration request - yield* takeLatest( - loadCoBadgeAbiConfiguration.request, - handleLoadCoBadgeConfiguration, - contentClient.getCobadgeServices - ); + // watch for CoBadge search request + yield* takeLatest( + searchUserCoBadge.request, + handleSearchUserCoBadge, + paymentManagerClient.getCobadgePans, + paymentManagerClient.searchCobadgePans, + pmSessionManager + ); + // watch for add CoBadge to the user's wallet + yield* takeLatest( + addCoBadgeToWallet.request, + handleAddCoBadgeToWallet, + paymentManagerClient.addCobadgeToWallet, + pmSessionManager + ); + // watch for CoBadge configuration request + yield* takeLatest( + loadCoBadgeAbiConfiguration.request, + handleLoadCoBadgeConfiguration, + contentClient.getCobadgeServices + ); - // watch for add co-badge to Wallet workflow - yield* takeLatest(walletAddCoBadgeStart, addCoBadgeToWalletAndActivateBpd); + // watch for add co-badge to Wallet workflow + yield* takeLatest(walletAddCoBadgeStart, addCoBadgeToWalletAndActivateBpd); - yield* fork( - watchPaypalOnboardingSaga, - paymentManagerClient, - pmSessionManager - ); - } + yield* fork( + watchPaypalOnboardingSaga, + paymentManagerClient, + pmSessionManager + ); + // end of BPDEnabled check // Check if a user has a bancomat and has not requested a cobadge yet and send // the information to mixpanel diff --git a/ts/screens/wallet/WalletHomeScreen.tsx b/ts/screens/wallet/WalletHomeScreen.tsx index be7681d74ac..feaf4384e31 100644 --- a/ts/screens/wallet/WalletHomeScreen.tsx +++ b/ts/screens/wallet/WalletHomeScreen.tsx @@ -33,12 +33,6 @@ import WalletLayout from "../../components/wallet/WalletLayout"; import SectionCardComponent, { SectionCardStatus } from "../../components/wallet/card/SectionCardComponent"; -import { bpdEnabled } from "../../config"; -import BpdOptInPaymentMethodsContainer from "../../features/bonus/bpd/components/optInPaymentMethods/BpdOptInPaymentMethodsContainer"; -import BpdCardsInWalletContainer from "../../features/bonus/bpd/components/walletCardContainer/BpdCardsInWalletComponent"; -import { bpdAllData } from "../../features/bonus/bpd/store/actions/details"; -import { bpdPeriodsAmountWalletVisibleSelector } from "../../features/bonus/bpd/store/reducers/details/combiner"; -import { bpdLastUpdateSelector } from "../../features/bonus/bpd/store/reducers/details/lastUpdate"; import CgnCardInWalletContainer from "../../features/bonus/cgn/components/CgnCardInWalletComponent"; import { cgnDetails } from "../../features/bonus/cgn/store/actions/details"; import { @@ -49,6 +43,7 @@ import { loadAvailableBonuses } from "../../features/bonus/common/store/actions/ import { supportedAvailableBonusSelector } from "../../features/bonus/common/store/selectors"; import IDPayCardsInWalletContainer from "../../features/idpay/wallet/components/IDPayCardsInWalletContainer"; import { idPayWalletGet } from "../../features/idpay/wallet/store/actions"; +import { idPayWalletInitiativeListSelector } from "../../features/idpay/wallet/store/reducers"; import NewPaymentMethodAddedNotifier from "../../features/wallet/component/NewMethodAddedNotifier"; import FeaturedCardCarousel from "../../features/wallet/component/card/FeaturedCardCarousel"; import WalletV2PreviewCards from "../../features/wallet/component/card/WalletV2PreviewCards"; @@ -73,7 +68,6 @@ import { runSendAddCobadgeTrackSaga } from "../../store/actions/wallet/wallets"; import { - bpdRemoteConfigSelector, isCGNEnabledSelector, isIdPayEnabledSelector } from "../../store/reducers/backendStatus"; @@ -173,12 +167,6 @@ class WalletHomeScreen extends React.PureComponent { this.setState({ hasFocus: false }); }; - private loadBonusBpd = () => { - if (bpdEnabled) { - this.props.loadBpdData(); - } - }; - private loadBonusCgn = () => { if (this.props.isCgnEnabled) { this.props.loadCgnData(); @@ -209,7 +197,6 @@ class WalletHomeScreen extends React.PureComponent { this.props.loadWallets(); // load the bonus information on Wallet mount - this.loadBonusBpd(); // FIXME restore loadTransactions see https://www.pivotaltracker.com/story/show/176051000 // eslint-disable-next-line functional/immutable-data @@ -242,12 +229,8 @@ class WalletHomeScreen extends React.PureComponent { } if ( this.state.hasFocus && - // error loading: bpd bonus - ((!pot.isError(prevProps.bpdLoadState) && - pot.isError(this.props.bpdLoadState)) || - // error loading: wallet - (!pot.isError(prevProps.potWallets) && - pot.isError(this.props.potWallets))) + !pot.isError(prevProps.potWallets) && + pot.isError(this.props.potWallets) ) { showToast(I18n.t("wallet.errors.loadingData")); } @@ -306,17 +289,17 @@ class WalletHomeScreen extends React.PureComponent { .filter(w => w.type === TypeEnum.CREDIT_CARD); private getBonusLoadingStatus = (): SectionCardStatus => { + const isCgnLoading = pot.isLoading(this.props.cgnDetails); + const isIdPayLoading = pot.isLoading(this.props.idPayDetails); + const areBonusesLoading = isCgnLoading || isIdPayLoading; + const areBonusesSome = + pot.isSome(this.props.cgnDetails) || pot.isSome(this.props.idPayDetails); // if any bonus is loading or updating - // note: in the BPD case, we are watching for loading on one of several steps - // so this loading state is very weak - if ( - pot.isLoading(this.props.bpdLoadState) || - pot.isLoading(this.props.cgnDetails) - ) { + if (areBonusesLoading) { return "loading"; } // if at least one bonus is some - if (pot.isSome(this.props.bpdLoadState)) { + if (areBonusesSome) { return "refresh"; } return "show"; @@ -324,35 +307,32 @@ class WalletHomeScreen extends React.PureComponent { private cardPreview() { const bonusLoadingStatus = this.getBonusLoadingStatus(); + const { isCgnEnabled, isIdPayEnabled } = this.props; return ( {this.cardHeader(false)} - {/* new payment methods rendering */} - - {/* Display this item only if the flag is enabled */} - {bpdEnabled && ( - { - if (bonusLoadingStatus !== "loading") { - this.props.loadAvailableBonuses(); - this.loadBonusBpd(); + { + if (bonusLoadingStatus !== "loading") { + this.props.loadAvailableBonuses(); + if (isCgnEnabled) { this.loadBonusCgn(); + } + if (isIdPayEnabled) { this.loadBonusIDPay(); } - }} - /> - )} - - {bpdEnabled && } - - {this.props.isIdPayEnabled && } + } + }} + /> + {isCgnEnabled && } + {isIdPayEnabled && } ); } @@ -507,9 +487,8 @@ class WalletHomeScreen extends React.PureComponent { headerPaddingMin={true} footerFullWidth={} > - <> - {(bpdEnabled || this.props.isCgnEnabled) && } + {this.props.isCgnEnabled && } {transactionContent} @@ -520,9 +499,6 @@ class WalletHomeScreen extends React.PureComponent { private getHeaderHeight() { return ( 250 + - (bpdEnabled - ? pot.getOrElse(this.props.periodsWithAmount, []).length * 88 - : 0) + (this.props.isCgnEnabled && this.props.isCgnInfoAvailable ? 88 : 0) + this.getCreditCards().length * 56 ); @@ -530,7 +506,6 @@ class WalletHomeScreen extends React.PureComponent { } const mapStateToProps = (state: GlobalState) => ({ - periodsWithAmount: bpdPeriodsAmountWalletVisibleSelector(state), availableBonusesList: supportedAvailableBonusSelector(state), // TODO: This selector (pagoPaCreditCardWalletV1Selector) should return the credit cards // available for display in the wallet, so the cards added with the APP or with the WISP. @@ -542,19 +517,17 @@ const mapStateToProps = (state: GlobalState) => ({ transactionsLoadedLength: getTransactionsLoadedLength(state), areMoreTransactionsAvailable: areMoreTransactionsAvailable(state), isPagoPATestEnabled: isPagoPATestEnabledSelector(state), - bpdLoadState: bpdLastUpdateSelector(state), cgnDetails: cgnDetailSelector(state), + idPayDetails: idPayWalletInitiativeListSelector(state), isCgnInfoAvailable: isCgnInformationAvailableSelector(state), isCgnEnabled: isCGNEnabledSelector(state), bancomatListVisibleInWallet: bancomatListVisibleInWalletSelector(state), coBadgeListVisibleInWallet: cobadgeListVisibleInWalletSelector(state), - bpdConfig: bpdRemoteConfigSelector(state), isDesignSystemEnabled: isDesignSystemEnabledSelector(state), isIdPayEnabled: isIdPayEnabledSelector(state) }); const mapDispatchToProps = (dispatch: Dispatch) => ({ - loadBpdData: () => dispatch(bpdAllData.request()), loadCgnData: () => dispatch(cgnDetails.request()), loadIdPayWalletData: () => dispatch(idPayWalletGet.request()), navigateToWalletAddPaymentMethod: (keyFrom?: string) => diff --git a/ts/store/middlewares/analytics.ts b/ts/store/middlewares/analytics.ts index 45ef8b11cf7..c8a074a678b 100644 --- a/ts/store/middlewares/analytics.ts +++ b/ts/store/middlewares/analytics.ts @@ -3,7 +3,6 @@ import * as O from "fp-ts/lib/Option"; import { getType } from "typesafe-actions"; -import trackBpdAction from "../../features/bonus/bpd/analytics/index"; import trackCdc from "../../features/bonus/cdc/analytics/index"; import trackCgnAction from "../../features/bonus/cgn/analytics/index"; import { loadAvailableBonuses } from "../../features/bonus/common/store/actions/availableBonusesTypes"; @@ -386,7 +385,6 @@ export const actionTracking = // call mixpanel tracking only after we have initialized mixpanel with the // API token void trackAction(mixpanel)(action); - void trackBpdAction(mixpanel)(action); void trackBPayAction(mixpanel)(action); void trackCoBadgeAction(mixpanel)(action); void trackCgnAction(mixpanel)(action); diff --git a/ts/store/reducers/__tests__/backendStatus.test.ts b/ts/store/reducers/__tests__/backendStatus.test.ts index 34e05f3c53a..11f8fe9dbad 100644 --- a/ts/store/reducers/__tests__/backendStatus.test.ts +++ b/ts/store/reducers/__tests__/backendStatus.test.ts @@ -6,10 +6,8 @@ import { areSystemsDeadReducer, BackendStatusState, barcodesScannerConfigSelector, - bpdRankingEnabledSelector, isPremiumMessagesOptInOutEnabledSelector, isUaDonationsEnabledSelector, - sectionStatusSelector, uaDonationsBannerConfigSelector } from "../backendStatus"; import { GlobalState } from "../types"; @@ -220,54 +218,12 @@ describe("test selectors", () => { } }; - const someStore = { - backendStatus: { - status: O.some(status) - } - } as any as GlobalState; - const noneStore = { backendStatus: { status: O.none } } as any as GlobalState; - it("should return the cashback status", () => { - const section = sectionStatusSelector("cashback")(someStore); - expect(section).not.toBeNull(); - expect(section).toEqual(status.sections.cashback); - }); - - it("should return undefined - sectionStatusSelector", () => { - const section = sectionStatusSelector("cashback")(noneStore); - expect(section).toBeUndefined(); - }); - - it("should return undefined - configSelector", () => { - const config = bpdRankingEnabledSelector(noneStore); - expect(config).toBeUndefined(); - }); - - it("should return true - someStoreConfig", () => { - const someStoreConfig = { - backendStatus: { - status: O.some({ ...status, config: { bpd_ranking_v2: true } }) - } - } as any as GlobalState; - const bpd_ranking = bpdRankingEnabledSelector(someStoreConfig); - expect(bpd_ranking).toBeTruthy(); - }); - - it("should return false - someStoreConfig", () => { - const someStoreConfig = { - backendStatus: { - status: O.some({ ...status, config: { bpd_ranking_v2: false } }) - } - } as any as GlobalState; - const bpd_ranking = bpdRankingEnabledSelector(someStoreConfig); - expect(bpd_ranking).toBeFalsy(); - }); - describe("donation selectors", () => { it("isUaDonationsEnabledSelector should return false if bs.config.donation.enabled is undefined", () => { const donationFeatureFlag = isUaDonationsEnabledSelector(noneStore); diff --git a/ts/store/reducers/backendStatus.ts b/ts/store/reducers/backendStatus.ts index 2723e3cbb35..b3ee4527ea0 100644 --- a/ts/store/reducers/backendStatus.ts +++ b/ts/store/reducers/backendStatus.ts @@ -2,9 +2,9 @@ * Implements the reducers for BackendServicesState. */ -import { Platform } from "react-native"; -import { pipe } from "fp-ts/lib/function"; import * as O from "fp-ts/lib/Option"; +import { pipe } from "fp-ts/lib/function"; +import { Platform } from "react-native"; import { createSelector } from "reselect"; import { getType } from "typesafe-actions"; @@ -13,9 +13,8 @@ import { ToolEnum } from "../../../definitions/content/AssistanceToolConfig"; import { BackendStatus } from "../../../definitions/content/BackendStatus"; import { BancomatPayConfig } from "../../../definitions/content/BancomatPayConfig"; import { BarcodesScannerConfig } from "../../../definitions/content/BarcodesScannerConfig"; -import { BpdConfig } from "../../../definitions/content/BpdConfig"; -import { Sections } from "../../../definitions/content/Sections"; import { SectionStatus } from "../../../definitions/content/SectionStatus"; +import { Sections } from "../../../definitions/content/Sections"; import { UaDonationsBanner } from "../../../definitions/content/UaDonationsBanner"; import { UaDonationsConfig } from "../../../definitions/content/UaDonationsConfig"; import { @@ -27,13 +26,13 @@ import { uaDonationsEnabled } from "../../config"; import { LocalizedMessageKeys } from "../../i18n"; -import { isStringNullyOrEmpty } from "../../utils/strings"; import { getAppVersion, isVersionSupported } from "../../utils/appVersion"; +import { isStringNullyOrEmpty } from "../../utils/strings"; import { backendStatusLoadSuccess } from "../actions/backendStatus"; import { Action } from "../actions/types"; -import { GlobalState } from "./types"; import { isIdPayTestEnabledSelector } from "./persistedPreferences"; +import { GlobalState } from "./types"; export type SectionStatusKey = keyof Sections; /** note that this state is not persisted so Option type is accepted @@ -71,26 +70,6 @@ export const sectionStatusSelector = (sectionStatusKey: SectionStatusKey) => ) ); -export const bpdRankingEnabledSelector = createSelector( - backendStatusSelector, - (backendStatus): boolean | undefined => - pipe( - backendStatus, - O.map(bs => bs.config.bpd_ranking_v2), - O.toUndefined - ) -); - -export const bpdRemoteConfigSelector = createSelector( - backendStatusSelector, - (backendStatus): BpdConfig | undefined => - pipe( - backendStatus, - O.map(bs => bs.config.bpd), - O.toUndefined - ) -); - export const cgnMerchantVersionSelector = createSelector( backendStatusSelector, (backendStatus): boolean | undefined => diff --git a/ts/utils/internalLink.ts b/ts/utils/internalLink.ts index bfaa6ab48af..3d904fce5a3 100644 --- a/ts/utils/internalLink.ts +++ b/ts/utils/internalLink.ts @@ -5,14 +5,12 @@ import * as A from "fp-ts/lib/Array"; import * as O from "fp-ts/lib/Option"; import { pipe } from "fp-ts/lib/function"; import { - bpdEnabled, fciEnabled, fimsEnabled, myPortalEnabled, svEnabled, uaDonationsEnabled } from "../config"; -import BPD_ROUTES from "../features/bonus/bpd/navigation/routes"; import CGN_ROUTES from "../features/bonus/cgn/navigation/routes"; import SV_ROUTES from "../features/bonus/siciliaVola/navigation/routes"; import { FCI_ROUTES } from "../features/fci/navigation/routes"; @@ -55,10 +53,6 @@ const legacyRoutesToNavigationLink: Record = { PREFERENCES_HOME: "/profile/preferences" }; -const bpdRoutesToNavigationLink: Record = { - [BPD_ROUTES.CTA_BPD_IBAN_EDIT]: "/wallet/bpd-iban-update" -}; - const cgnRoutesToNavigationLink: Record = { [CGN_ROUTES.ACTIVATION.CTA_START_CGN]: "/cgn-activation/start", [CGN_ROUTES.DETAILS.DETAILS]: "/cgn-details/detail" @@ -91,7 +85,6 @@ const allowedRoutes = { ...cgnRoutesToNavigationLink, ...legacyRoutesToNavigationLink, ...(myPortalEnabled ? myPortalRoutesToNavigationLink : {}), - ...(bpdEnabled ? bpdRoutesToNavigationLink : {}), ...(svEnabled ? svRoutesToNavigationLink : {}), ...(uaDonationsEnabled ? uaDonationsRoutesToNavigationLink : {}), ...(fimsEnabled ? fimsRoutesToNavigationLink : {}),