Skip to content

Commit

Permalink
Merge branch 'master' into IOAPPX-448-update-ds-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnplb authored Dec 19, 2024
2 parents 34694fa + 1ddf587 commit f2aae62
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ authentication:
title: We can't find the CieID app
description: To login, you must have the app installed on your device.
primary_action_label: Get the app
link_error: We could not direct you to the store. Open it manually and search for CieID
cie:
genericTitle: Login with CIE
cie: CIE
Expand Down
1 change: 1 addition & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ authentication:
title: Non riusciamo a trovare l'app CieID
description: Per accedere, devi avere l'app installata sul tuo dispositivo.
primary_action_label: Scarica CieID
link_error: Non siamo riusciti a indirizzarti allo store. Aprilo manualmente e cerca CieID
cie:
genericTitle: Entra con CIE
cie: CIE
Expand Down
23 changes: 13 additions & 10 deletions ts/features/cie/__tests__/CieIdNotInstalled.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Linking, Platform } from "react-native";
import { Platform } from "react-native";
import { fireEvent, render } from "@testing-library/react-native";
import React from "react";
import CieIdNotInstalled, {
CIE_ID_ANDROID_COLL_LINK,
CIE_ID_ANDROID_LINK,
CIE_ID_IOS_LINK
} from "../components/CieIdNotInstalled";
import * as urlUtils from "../../../utils/url";

const UAT_ENV_ENABLE_STATES = [true, false];

const mockPopToTop = jest.fn();
const mockOpenUrl = jest.spyOn(urlUtils, "openWebUrl");
const anyFunction = expect.any(Function);

jest.mock("@react-navigation/native", () => ({
...jest.requireActual("@react-navigation/native"),
Expand All @@ -28,15 +31,13 @@ describe(CieIdNotInstalled, () => {

describe("Behavior on iOS", () => {
UAT_ENV_ENABLE_STATES.forEach(uatState => {
it("Should open CIE_ID_IOS_LINK", () => {
it("Should open CIE_ID_IOS_LINK", async () => {
const { getByTestId } = render(<CieIdNotInstalled isUat={uatState} />);

const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);

expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
CIE_ID_IOS_LINK
);
expect(mockOpenUrl).toHaveBeenCalledWith(CIE_ID_IOS_LINK, anyFunction);
expect(mockPopToTop).not.toHaveBeenCalled();
});
});
Expand All @@ -50,8 +51,9 @@ describe(CieIdNotInstalled, () => {
const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);

expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
CIE_ID_ANDROID_LINK
expect(mockOpenUrl).toHaveBeenCalledWith(
CIE_ID_ANDROID_LINK,
anyFunction
);
expect(mockPopToTop).not.toHaveBeenCalled();
});
Expand All @@ -63,8 +65,9 @@ describe(CieIdNotInstalled, () => {
const openStore = getByTestId("cie-id-not-installed-open-store");
fireEvent.press(openStore);

expect(jest.spyOn(Linking, "openURL")).toHaveBeenCalledWith(
CIE_ID_ANDROID_COLL_LINK
expect(mockOpenUrl).toHaveBeenCalledWith(
CIE_ID_ANDROID_COLL_LINK,
anyFunction
);
expect(mockPopToTop).not.toHaveBeenCalled();
});
Expand All @@ -76,7 +79,7 @@ describe(CieIdNotInstalled, () => {
const popToTop = getByTestId("cie-id-not-installed-pop-to-top");
fireEvent.press(popToTop);

expect(jest.spyOn(Linking, "openURL")).not.toHaveBeenCalled();
expect(mockOpenUrl).not.toHaveBeenCalled();
expect(mockPopToTop).toHaveBeenCalledTimes(1);
});
});
Expand Down
14 changes: 11 additions & 3 deletions ts/features/cie/components/CieIdNotInstalled.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import { Linking, Platform } from "react-native";
import { Platform } from "react-native";
import { useIOToast } from "@pagopa/io-app-design-system";
import { OperationResultScreenContent } from "../../../components/screens/OperationResultScreenContent";
import { useIONavigation } from "../../../navigation/params/AppParamsList";
import I18n from "../../../i18n";
import { trackCieIdNotInstalledDownloadAction } from "../analytics";
import { openWebUrl } from "../../../utils/url";

export const CIE_ID_IOS_LINK =
"https://apps.apple.com/it/app/cieid/id1504644677";
Expand All @@ -17,6 +19,7 @@ export type CieIdNotInstalledProps = {

const CieIdNotInstalled = ({ isUat }: CieIdNotInstalledProps) => {
const { popToTop } = useIONavigation();
const { error } = useIOToast();

return (
<OperationResultScreenContent
Expand All @@ -30,12 +33,17 @@ const CieIdNotInstalled = ({ isUat }: CieIdNotInstalledProps) => {
),
onPress: () => {
void trackCieIdNotInstalledDownloadAction();
void Linking.openURL(
openWebUrl(
Platform.select({
ios: CIE_ID_IOS_LINK,
android: isUat ? CIE_ID_ANDROID_COLL_LINK : CIE_ID_ANDROID_LINK,
default: ""
})
}),
() => {
error(
I18n.t("authentication.cie_id.cie_not_installed.link_error")
);
}
);
}
}}
Expand Down

0 comments on commit f2aae62

Please sign in to comment.