Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-navigation-v6
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisTofani committed Jan 19, 2024
2 parents d4abf89 + 0a08463 commit 4fd9f34
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
7 changes: 6 additions & 1 deletion ts/features/bonus/cgn/components/detail/CgnUnsubscribe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { isError, isReady } from "../../../../../common/model/RemoteValue";
import { navigateBack } from "../../../../../store/actions/navigation";
import { cgnDetails } from "../../store/actions/details";
import { IOToast } from "../../../../../components/Toast";
import { skipToastShowingDueToE2ECrash } from "./ToastPatch";

const CgnUnsubscribe = () => {
const dispatch = useIODispatch();
Expand Down Expand Up @@ -38,7 +39,11 @@ const CgnUnsubscribe = () => {
if (isReady(unsubscriptionStatus)) {
navigateBack();
dispatch(cgnDetails.request());
IOToast.success(I18n.t("bonus.cgn.activation.deactivate.toast"));
// This is needed to prevent a crash while running E2E tests. Showing
// the toast causes random crashes upon calling device.reloadReactNative
if (!skipToastShowingDueToE2ECrash) {
IOToast.success(I18n.t("bonus.cgn.activation.deactivate.toast"));
}
}
if (isError(unsubscriptionStatus) && !isFirstRender.current) {
IOToast.error(I18n.t("global.genericError"));
Expand Down
1 change: 1 addition & 0 deletions ts/features/bonus/cgn/components/detail/ToastPatch.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const skipToastShowingDueToE2ECrash = true;
1 change: 1 addition & 0 deletions ts/features/bonus/cgn/components/detail/ToastPatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const skipToastShowingDueToE2ECrash = false;
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ describe("Credit Card onboarding", () => {
// Footer, Wallet icon
await element(by.text(I18n.t("global.navigator.wallet"))).tap();

await waitFor(
element(by.text(I18n.t("wallet.newPaymentMethod.add").toUpperCase()))
)
await waitFor(element(by.id("walletAddNewPaymentMethodTestId")))
.toBeVisible()
.withTimeout(e2eWaitRenderTimeout);

// Button "+ Add"
await element(
by.text(I18n.t("wallet.newPaymentMethod.add").toUpperCase())
).tap();
await element(by.id("walletAddNewPaymentMethodTestId")).tap();

await waitFor(element(by.text(I18n.t("wallet.paymentMethod"))))
.toBeVisible()
Expand Down
4 changes: 3 additions & 1 deletion ts/navigation/components/HeaderFirstLevelHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ export const HeaderFirstLevelHandler = () => {
type: "twoActions",
firstAction: helpAction,
backgroundColor: "dark",
testID: "wallet-home-header-title",
secondAction: {
icon: "add",
accessibilityLabel: I18n.t("wallet.accessibility.addElement"),
onPress: presentWalletHomeHeaderBottomsheet
onPress: presentWalletHomeHeaderBottomsheet,
testID: "walletAddNewPaymentMethodTestId"
}
};
break;
Expand Down
13 changes: 10 additions & 3 deletions ts/utils/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export const requestIOPermission = async (
permission: RNPermissions.Permission,
rationale?: RNPermissions.Rationale
): Promise<boolean> => {
// Be aware that some permissions may return "unavailable" event if the library
// documents them as supported. One notorious case is the iOS PHOTO_LIBRARY_ADD_ONLY
// permission. If such permission is automatically handled by the system upon request
// (such as PHOTO_LIBRARY_ADD_ONLY is), then you should not use this function to
// check nor to request such permission
const checkResult = await RNPermissions.check(permission);
if (checkResult === "granted") {
return true;
Expand Down Expand Up @@ -83,8 +88,10 @@ export const requestSaveToGalleryPermission = async (
RNPermissions.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE,
rationale
),
ios: requestIOPermission(
RNPermissions.PERMISSIONS.IOS.PHOTO_LIBRARY_ADD_ONLY
),
// on iOS the permission is handled by adding NSPhotoLibraryAddUsageDescription and NSPhotoLibraryUsageDescription
// into the Info.plist file and the permission request is automatically handled by the system when using the
// Cameraroll.save method. Asking for the PHOTO_LIBRARY_ADD_ONLY permission results in an "unavailable" response
// from the react-native-permissions library (even if the library documentation declares that it is supported) so
// it cannot be used to determine the permission status.
default: Promise.resolve(true)
});

0 comments on commit 4fd9f34

Please sign in to comment.