From da9509516e9dfc9707d0e9d003e132f9d6139e0c Mon Sep 17 00:00:00 2001 From: ChrisMattew Date: Wed, 29 Jan 2025 14:41:04 +0100 Subject: [PATCH 1/4] chore: remove CieID local and remote FF references --- locales/en/index.yml | 3 - locales/it/index.yml | 3 - ts/components/cie/CieNotSupported.tsx | 96 - ts/features/cieLogin/store/actions/index.ts | 5 - ts/features/cieLogin/store/reducers/index.ts | 23 +- ts/features/cieLogin/store/selectors/index.ts | 26 +- .../__snapshots__/index.test.ts.snap | 1 - ts/navigation/AuthenticationNavigator.tsx | 6 - .../params/AuthenticationParamsList.ts | 1 - ts/navigation/routes.ts | 1 - ts/screens/authentication/LandingScreen.tsx | 35 +- .../__tests__/LandingScreen.test.tsx | 31 +- .../__snapshots__/LandingScreen.test.tsx.snap | 3016 +---------------- ts/screens/profile/DeveloperModeSection.tsx | 13 - ts/store/reducers/index.ts | 2 - 15 files changed, 20 insertions(+), 3242 deletions(-) delete mode 100644 ts/components/cie/CieNotSupported.tsx diff --git a/locales/en/index.yml b/locales/en/index.yml index 573ecc3d19d..dc9faaa3dd9 100644 --- a/locales/en/index.yml +++ b/locales/en/index.yml @@ -483,9 +483,6 @@ profile: idpay: idpayTest: IDPay idpayTestAlert: This change requires app reboot - cieID: - cieIdTest: - title: CieID designSystemEnvironment: Experimental Design System newScanSection: New 'Scan' feature sessionRefresh: Activate Session Refresh diff --git a/locales/it/index.yml b/locales/it/index.yml index 7e2c24f382a..4bac4679836 100644 --- a/locales/it/index.yml +++ b/locales/it/index.yml @@ -483,9 +483,6 @@ profile: idpay: idpayTest: IDPay idpayTestAlert: La modifica richiede il riavvio dell'app - cieID: - cieIdTest: - title: CieID trial: titleSection: Partecipa alla sperimentazione designSystemEnvironment: Design System sperimentale diff --git a/ts/components/cie/CieNotSupported.tsx b/ts/components/cie/CieNotSupported.tsx deleted file mode 100644 index 312c71b86ce..00000000000 --- a/ts/components/cie/CieNotSupported.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - Alert, - Body, - ContentWrapper, - FeatureInfo, - GradientScrollView, - H3, - IOStyles, - Pictogram, - VSpacer -} from "@pagopa/io-app-design-system"; -import * as pot from "@pagopa/ts-commons/lib/pot"; -import { useFocusEffect, useNavigation } from "@react-navigation/native"; -import { useRef } from "react"; -import { Platform, View } from "react-native"; -import I18n from "../../i18n"; -import { useIOSelector } from "../../store/hooks"; -import { - hasApiLevelSupportSelector, - hasNFCFeatureSelector -} from "../../store/reducers/cie"; -import { setAccessibilityFocus } from "../../utils/accessibility"; - -const CieNotSupported = () => { - const hasApiLevelSupport = useIOSelector(hasApiLevelSupportSelector); - const hasCieApiLevelSupport = pot.getOrElse(hasApiLevelSupport, false); - const hasNFCFeature = useIOSelector(hasNFCFeatureSelector); - const hasCieNFCFeature = pot.getOrElse(hasNFCFeature, false); - const accessibilityFirstFocuseViewRef = useRef(null); - const navigation = useNavigation(); - - useFocusEffect(() => setAccessibilityFocus(accessibilityFirstFocuseViewRef)); - - return ( - navigation.goBack(), - testID: "close-button" - }} - > - - - - - - -

- {I18n.t("authentication.landing.cie_unsupported.title")} -

-
- - - {I18n.t("authentication.landing.cie_unsupported.body")} - - - - - - - {Platform.OS === "android" && !hasCieNFCFeature ? ( - - ) : ( - Platform.OS === "android" && - hasCieApiLevelSupport && ( - - ) - )} -
-
- ); -}; - -export default CieNotSupported; diff --git a/ts/features/cieLogin/store/actions/index.ts b/ts/features/cieLogin/store/actions/index.ts index 23b8c799f52..906e2b7784a 100644 --- a/ts/features/cieLogin/store/actions/index.ts +++ b/ts/features/cieLogin/store/actions/index.ts @@ -7,10 +7,6 @@ export const cieLoginDisableUat = createStandardAction( "CIE_LOGIN_DISABLE_UAT" )(); -export const cieIDFeatureSetEnabled = createStandardAction( - "PREFERENCES_CIE_ID_FEATURE_SET_ENABLED" -)<{ isCieIDFeatureEnabled: boolean }>(); - export const cieIDDisableTourGuide = createStandardAction( "CIE_ID_DISABLE_TOUR_GUIDE" )(); @@ -21,6 +17,5 @@ export const cieIDSetSelectedSecurityLevel = createStandardAction( export type CieLoginConfigActions = | ActionType | ActionType - | ActionType | ActionType | ActionType; diff --git a/ts/features/cieLogin/store/reducers/index.ts b/ts/features/cieLogin/store/reducers/index.ts index 6c69c544c16..6d4dbeabc9e 100644 --- a/ts/features/cieLogin/store/reducers/index.ts +++ b/ts/features/cieLogin/store/reducers/index.ts @@ -7,10 +7,9 @@ import { PersistedState, persistReducer } from "redux-persist"; -import { merge } from "lodash"; +import { merge, omit } from "lodash"; import { cieIDDisableTourGuide, - cieIDFeatureSetEnabled, cieIDSetSelectedSecurityLevel, cieLoginDisableUat, cieLoginEnableUat @@ -21,14 +20,12 @@ import { SpidLevel } from "../../utils"; export type CieLoginState = { useUat: boolean; - isCieIDFeatureEnabled: boolean; isCieIDTourGuideEnabled: boolean; cieIDSelectedSecurityLevel?: SpidLevel; }; export const cieLoginInitialState = { useUat: false, - isCieIDFeatureEnabled: false, isCieIDTourGuideEnabled: true }; @@ -47,11 +44,6 @@ const cieLoginReducer = ( ...state, useUat: false }; - case getType(cieIDFeatureSetEnabled): - return { - ...state, - ...action.payload - }; case getType(cieIDDisableTourGuide): return { ...state, @@ -67,11 +59,18 @@ const cieLoginReducer = ( } }; -const CURRENT_REDUX_CIE_LOGIN_STORE_VERSION = 0; +const CURRENT_REDUX_CIE_LOGIN_STORE_VERSION = 1; const migrations: MigrationManifest = { "0": (state: PersistedState) => - merge(state, "features.loginFeatures.cieLogin.isCieIDTourGuideEnabled") + merge(state, { + isCieIDTourGuideEnabled: true + }), + /** + * @param state The slice state + * Removes `isCieIDFeatureEnabled` from the persist rehydration actions + */ + "1": (state: PersistedState) => omit(state, "isCieIDFeatureEnabled") }; const persistConfig: PersistConfig = { @@ -79,7 +78,7 @@ const persistConfig: PersistConfig = { storage: AsyncStorage, migrate: createMigrate(migrations, { debug: isDevEnv }), version: CURRENT_REDUX_CIE_LOGIN_STORE_VERSION, - whitelist: ["isCieIDFeatureEnabled", "isCieIDTourGuideEnabled"] + whitelist: ["isCieIDTourGuideEnabled"] }; export const cieLoginPersistor = persistReducer( diff --git a/ts/features/cieLogin/store/selectors/index.ts b/ts/features/cieLogin/store/selectors/index.ts index 3043a191240..530ac17ebcc 100644 --- a/ts/features/cieLogin/store/selectors/index.ts +++ b/ts/features/cieLogin/store/selectors/index.ts @@ -1,34 +1,10 @@ -import { createSelector } from "reselect"; import { GlobalState } from "../../../../store/reducers/types"; -import { remoteConfigSelector } from "../../../../store/reducers/backendStatus/remoteConfig"; -import { isPropertyWithMinAppVersionEnabled } from "../../../../store/reducers/featureFlagWithMinAppVersionStatus"; export const isCieLoginUatEnabledSelector = (state: GlobalState) => state.features.loginFeatures.cieLogin.useUat; -const isCieIdMinAppVersionEnabledSelector = createSelector( - remoteConfigSelector, - remoteConfig => - isPropertyWithMinAppVersionEnabled({ - remoteConfig, - mainLocalFlag: true, - configPropertyName: "cie_id" - }) -); - -export const isCieIDLocalFeatureEnabledSelector = (state: GlobalState) => - state.features.loginFeatures.cieLogin.isCieIDFeatureEnabled; - -export const isCieIDFFEnabledSelector = (state: GlobalState) => - isCieIDLocalFeatureEnabledSelector(state) || - isCieIdMinAppVersionEnabledSelector(state); - -/** - * Both `isCieIDTourGuideEnabled` and `isCieIDFFEnabledSelector` return value must be `true` - */ export const isCieIDTourGuideEnabledSelector = (state: GlobalState) => - state.features.loginFeatures.cieLogin.isCieIDTourGuideEnabled && - isCieIDFFEnabledSelector(state); + state.features.loginFeatures.cieLogin.isCieIDTourGuideEnabled; export const cieIDSelectedSecurityLevelSelector = (state: GlobalState) => state.features.loginFeatures.cieLogin.cieIDSelectedSecurityLevel; diff --git a/ts/features/common/store/reducers/__tests__/__snapshots__/index.test.ts.snap b/ts/features/common/store/reducers/__tests__/__snapshots__/index.test.ts.snap index ba2227b2b05..84c5861d5b6 100644 --- a/ts/features/common/store/reducers/__tests__/__snapshots__/index.test.ts.snap +++ b/ts/features/common/store/reducers/__tests__/__snapshots__/index.test.ts.snap @@ -144,7 +144,6 @@ exports[`featuresPersistor should match snapshot 1`] = ` }, "loginFeatures": { "cieLogin": { - "isCieIDFeatureEnabled": false, "isCieIDTourGuideEnabled": true, "useUat": false, }, diff --git a/ts/navigation/AuthenticationNavigator.tsx b/ts/navigation/AuthenticationNavigator.tsx index add39492cc9..e30400bf83a 100644 --- a/ts/navigation/AuthenticationNavigator.tsx +++ b/ts/navigation/AuthenticationNavigator.tsx @@ -16,7 +16,6 @@ import CieExpiredOrInvalidScreen from "../screens/authentication/cie/CieExpiredO import CiePinScreen from "../screens/authentication/cie/CiePinScreen"; import CieWrongCiePinScreen from "../screens/authentication/cie/CieWrongCiePinScreen"; import { AuthSessionPage } from "../screens/authentication/idpAuthSessionHandler"; -import CieNotSupported from "../components/cie/CieNotSupported"; import RootedDeviceModal from "../screens/modal/RootedDeviceModal"; import { isGestureEnabled } from "../utils/navigation"; import CieUnexpectedErrorScreen from "../screens/authentication/cie/CieUnexpectedErrorScreen"; @@ -207,11 +206,6 @@ const AuthenticationStackNavigator = () => ( headerShown: true }} > - - { const isCieIDTourGuideEnabled = useIOSelector( isCieIDTourGuideEnabledSelector ); - const isCieIDFFEnabled = useIOSelector(isCieIDFFEnabledSelector); const accessibilityFirstFocuseViewRef = useRef(null); const { navigateToIdpSelection, @@ -236,35 +234,15 @@ export const LandingScreen = () => { } }, [hasTabletCompatibilityAlertAlreadyShown]); - const handleLegacyCieLogin = useCallback(() => { - if (isCieSupported) { - handleNavigateToCiePinScreen(); - } else { - navigation.navigate(ROUTES.AUTHENTICATION, { - screen: ROUTES.CIE_NOT_SUPPORTED - }); - } - }, [isCieSupported, navigation, handleNavigateToCiePinScreen]); - const navigateToCiePinScreen = useCallback(() => { void trackCieLoginSelected(); - if (isCieIDFFEnabled) { - if (isCieSupported) { - void trackCieBottomSheetScreenView(); - present(); - } else { - handleNavigateToCieIdLoginScreen(); - } + if (isCieSupported) { + void trackCieBottomSheetScreenView(); + present(); } else { - handleLegacyCieLogin(); + handleNavigateToCieIdLoginScreen(); } - }, [ - present, - isCieSupported, - isCieIDFFEnabled, - handleLegacyCieLogin, - handleNavigateToCieIdLoginScreen - ]); + }, [present, isCieSupported, handleNavigateToCieIdLoginScreen]); const navigateToPrivacyUrl = useCallback(() => { trackMethodInfo(); @@ -320,7 +298,7 @@ export const LandingScreen = () => { /> ); - if (isCieIDFFEnabled || isCieSupported) { + if (isCieSupported) { return [loginCieButton, loginSpidButton]; } @@ -330,7 +308,6 @@ export const LandingScreen = () => { isCieUatEnabled, navigateToCiePinScreen, navigateToIdpSelection, - isCieIDFFEnabled, isCieSupported, dispatch ]); diff --git a/ts/screens/authentication/__tests__/LandingScreen.test.tsx b/ts/screens/authentication/__tests__/LandingScreen.test.tsx index 38c46d9d9f9..3c6ef6b419c 100644 --- a/ts/screens/authentication/__tests__/LandingScreen.test.tsx +++ b/ts/screens/authentication/__tests__/LandingScreen.test.tsx @@ -5,7 +5,6 @@ import { appReducer } from "../../../store/reducers"; import { LandingScreen } from "../LandingScreen"; import { renderScreenWithNavigationStoreContext } from "../../../utils/testWrapper"; import ROUTES from "../../../navigation/routes"; -import * as cieSelectors from "../../../features/cieLogin/store/selectors"; const mockNavigateToCiePinInsertion = jest.fn(); const mockNavigateToIdpSelection = jest.fn(); @@ -32,12 +31,6 @@ jest.mock("../../../hooks/useNavigateToLoginMethod", () => ({ }) })); -jest.mock("../../../features/cieLogin/store/selectors", () => ({ - ...jest.requireActual("../../../features/cieLogin/store/selectors"), - __esModule: true, - isCieIDFFEnabledSelector: jest.fn() -})); - jest.mock("@gorhom/bottom-sheet", () => jest.requireActual("../../../__mocks__/@gorhom/bottom-sheet.ts") ); @@ -63,29 +56,7 @@ const toMatchSnapshot = () => { expect(component).toMatchSnapshot(); }; -describe("LandingScreen with both local and remote CieID FF disabled", () => { - afterEach(jest.clearAllMocks); - - it("Should be defined", toBeDefined); - it("Should match the snapshot", toMatchSnapshot); - it("Should navigate to login with cie + pin", () => { - const { getByTestId } = renderComponent(); - - const loginWithCie = getByTestId("landing-button-login-cie"); - fireEvent.press(loginWithCie); - - expect(mockNavigateToCiePinInsertion).toHaveBeenCalled(); - expect(mockNavigateToIdpSelection).not.toHaveBeenCalled(); - }); - it("Should navigate to idp selection screen", navigateToIdpSelection); -}); - -describe("LandingScreen with CieID FF enabled", () => { - beforeAll(() => - jest - .spyOn(cieSelectors, "isCieIDFFEnabledSelector") - .mockImplementation(() => true) - ); +describe(LandingScreen, () => { afterEach(jest.clearAllMocks); it("Should be defined", toBeDefined); diff --git a/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap b/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap index a83529e7405..418ca362079 100644 --- a/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap +++ b/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap @@ -1,3020 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`LandingScreen with CieID FF enabled Should match the snapshot 1`] = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Welcome to IO! - - - - Swipe left to see what you can do in the app - - - - - - - - - - - - - - - - - - - - - - - - - Keep your personal documents safe - - - - With Documenti su IO you always have the digital version of your documents, such as driving licence and health card, at your fingertips - - - - - - - - - - - - - - - - - - - - - - - - - Receive communications, also with legal value - - - - Read incoming communications from organisations: by activating the SEND service, you will also receive communications with legal value and save on notification costs. - - - - - - - - - - - - - - - - - - Pay pagoPA notice by the method you prefer - - - - On IO, you can view and download receipts for your pagoPA payments, even if you have not paid in the app - - - - - - - - - - - - - - - - - - Access to the services you are most interested in - - - - Direct access to government services related to health, education, mobility, work and more - - - - - - - - - - - - - - - - - - - - - - - - - - - - Login with CIE - - - - - - - - - - - - - - - - - Login with SPID - - - - - - - - - - Privacy - - - - - - - - - - - - - - - - - - - - Login with CIE + PIN - - - Use Electronic Identity Card and PIN - - - - - - - - - - - - - - - - - - - - - - - - Login with CieID - - - Use the CieID app - - - - - - New - - - - - - - - - - - Not sure what to choose? - - - - - - We give you a hand - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; - -exports[`LandingScreen with both local and remote CieID FF disabled Should match the snapshot 1`] = ` +exports[`LandingScreen Should match the snapshot 1`] = ` { if (enabled) { @@ -492,9 +487,6 @@ const DeveloperTestEnvironmentSection = ({ dispatch(preferencesIdPayTestSetEnabled({ isIdPayTestEnabled: enabled })); handleShowModal(); }; - const onCieIDFeatureToggle = (enabled: boolean) => { - dispatch(cieIDFeatureSetEnabled({ isCieIDFeatureEnabled: enabled })); - }; const testEnvironmentsListItems: ReadonlyArray = [ { @@ -513,11 +505,6 @@ const DeveloperTestEnvironmentSection = ({ description: I18n.t("profile.main.idpay.idpayTestAlert"), value: isIdPayTestEnabled, onSwitchValueChange: onIdPayTestToggle - }, - { - label: I18n.t("profile.main.cieID.cieIdTest.title"), - value: isCieIDFeatureEnabled, - onSwitchValueChange: onCieIDFeatureToggle } ]; diff --git a/ts/store/reducers/index.ts b/ts/store/reducers/index.ts index 560b0352c11..9dcad9d883f 100644 --- a/ts/store/reducers/index.ts +++ b/ts/store/reducers/index.ts @@ -242,8 +242,6 @@ export function createRootReducer( }, cieLogin: { ...cieLoginInitialState, - isCieIDFeatureEnabled: - state.features.loginFeatures.cieLogin.isCieIDFeatureEnabled, isCieIDTourGuideEnabled: state.features.loginFeatures.cieLogin .isCieIDTourGuideEnabled, From 32231bb852c548eefc4f76898891dea929b99335 Mon Sep 17 00:00:00 2001 From: ChrisMattew Date: Wed, 29 Jan 2025 16:17:11 +0100 Subject: [PATCH 2/4] refactor: remove login buttons inversion logic --- ts/screens/authentication/LandingScreen.tsx | 89 ++++++++------------- 1 file changed, 32 insertions(+), 57 deletions(-) diff --git a/ts/screens/authentication/LandingScreen.tsx b/ts/screens/authentication/LandingScreen.tsx index 81f52288e5e..9305b4689b9 100644 --- a/ts/screens/authentication/LandingScreen.tsx +++ b/ts/screens/authentication/LandingScreen.tsx @@ -257,61 +257,6 @@ export const LandingScreen = () => { } }, [isCieSupported, navigation]); - const [firstButton, secondButton] = useMemo((): [ - JSX.Element, - JSX.Element - ] => { - const loginCieButton = ( - dispatch(cieIDDisableTourGuide())} - title={I18n.t("authentication.landing.tour_guide.title")} - content={I18n.t("authentication.landing.tour_guide.content")} - > - - - ); - const loginSpidButton = ( - { - void trackSpidLoginSelected(); - navigateToIdpSelection(); - }} - /> - ); - - if (isCieSupported) { - return [loginCieButton, loginSpidButton]; - } - - return [loginSpidButton, loginCieButton]; - }, [ - isCieIDTourGuideEnabled, - isCieUatEnabled, - navigateToCiePinScreen, - navigateToIdpSelection, - isCieSupported, - dispatch - ]); - const LandingScreenComponent = () => { useHeaderSecondLevel({ title: "", @@ -408,9 +353,39 @@ export const LandingScreen = () => { - {firstButton} + dispatch(cieIDDisableTourGuide())} + title={I18n.t("authentication.landing.tour_guide.title")} + content={I18n.t("authentication.landing.tour_guide.content")} + > + + - {secondButton} + { + void trackSpidLoginSelected(); + navigateToIdpSelection(); + }} + /> Date: Wed, 29 Jan 2025 16:19:33 +0100 Subject: [PATCH 3/4] chore: remove lodash merge from 0 index migration --- ts/features/cieLogin/store/reducers/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/features/cieLogin/store/reducers/index.ts b/ts/features/cieLogin/store/reducers/index.ts index 6d4dbeabc9e..ef6ad8d984a 100644 --- a/ts/features/cieLogin/store/reducers/index.ts +++ b/ts/features/cieLogin/store/reducers/index.ts @@ -7,7 +7,7 @@ import { PersistedState, persistReducer } from "redux-persist"; -import { merge, omit } from "lodash"; +import { omit } from "lodash"; import { cieIDDisableTourGuide, cieIDSetSelectedSecurityLevel, @@ -62,10 +62,10 @@ const cieLoginReducer = ( const CURRENT_REDUX_CIE_LOGIN_STORE_VERSION = 1; const migrations: MigrationManifest = { - "0": (state: PersistedState) => - merge(state, { - isCieIDTourGuideEnabled: true - }), + "0": (state: PersistedState) => ({ + ...state, + isCieIDTourGuideEnabled: true + }), /** * @param state The slice state * Removes `isCieIDFeatureEnabled` from the persist rehydration actions From 170f00d29ac02588a31a445e22c5be8cb319f824 Mon Sep 17 00:00:00 2001 From: ChrisMattew Date: Wed, 29 Jan 2025 17:20:45 +0100 Subject: [PATCH 4/4] chore(LandingScreen): update snapshots --- .../__snapshots__/LandingScreen.test.tsx.snap | 299 ++++++------------ 1 file changed, 89 insertions(+), 210 deletions(-) diff --git a/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap b/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap index 418ca362079..1410d876f06 100644 --- a/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap +++ b/ts/screens/authentication/__tests__/__snapshots__/LandingScreen.test.tsx.snap @@ -379,10 +379,10 @@ exports[`LandingScreen Should match the snapshot 1`] = ` } /> - - @@ -2028,67 +2026,6 @@ exports[`LandingScreen Should match the snapshot 1`] = ` } } > - - - - - - - - - -