From a40506e8064854255750f76bd6eae985c801eb0a Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Mon, 13 May 2024 14:55:45 +0200 Subject: [PATCH 1/2] fix: handle push-notifications permission granting failure --- tests/e2e/utils/installApp.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/e2e/utils/installApp.ts b/tests/e2e/utils/installApp.ts index 82d0066c885b..5c86590fd446 100644 --- a/tests/e2e/utils/installApp.ts +++ b/tests/e2e/utils/installApp.ts @@ -21,6 +21,15 @@ export default function (packageName: string, path: string, platform = 'android' }) // install and grant push notifications permissions right away (the popup may block e2e tests sometimes) // eslint-disable-next-line @typescript-eslint/no-misused-promises - .finally(() => execAsync(`adb install ${path}`).then(() => execAsync(`adb shell pm grant ${packageName.split('/')[0]} android.permission.POST_NOTIFICATIONS`))) + .finally(() => + // install the app + execAsync(`adb install ${path}`).then(() => + // and grant push notifications permissions right away (the popup may block e2e tests sometimes) + execAsync(`adb shell pm grant ${packageName.split('/')[0]} android.permission.POST_NOTIFICATIONS`).catch((error: ExecException) => + // in case of error - just log it and continue (if we request this permission on Android < 13 it'll fail because there is no such permission) + Logger.warn('Failed to grant push notifications permissions:', error.message), + ), + ), + ) ); } From d5d9d02cf97465fd26a7452db96559bbae4d9a30 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Mon, 13 May 2024 15:21:53 +0200 Subject: [PATCH 2/2] chore: don't log the error two times (the first one is already logged on level) --- tests/e2e/utils/installApp.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/e2e/utils/installApp.ts b/tests/e2e/utils/installApp.ts index 5c86590fd446..9c2f82e47336 100644 --- a/tests/e2e/utils/installApp.ts +++ b/tests/e2e/utils/installApp.ts @@ -25,9 +25,12 @@ export default function (packageName: string, path: string, platform = 'android' // install the app execAsync(`adb install ${path}`).then(() => // and grant push notifications permissions right away (the popup may block e2e tests sometimes) - execAsync(`adb shell pm grant ${packageName.split('/')[0]} android.permission.POST_NOTIFICATIONS`).catch((error: ExecException) => + // eslint-disable-next-line @typescript-eslint/no-unused-vars + execAsync(`adb shell pm grant ${packageName.split('/')[0]} android.permission.POST_NOTIFICATIONS`).catch((_: ExecException) => // in case of error - just log it and continue (if we request this permission on Android < 13 it'll fail because there is no such permission) - Logger.warn('Failed to grant push notifications permissions:', error.message), + Logger.warn( + 'Failed to grant push notifications permissions. It might be due to the fact that push-notifications permission type is not supported on this OS version yet. Continue tests execution...', + ), ), ), )