From f408381d1864ecec945f1f3ff2ca136ceeae2258 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 31 May 2024 09:53:22 -0300 Subject: [PATCH] Fix backup/restore instrumentation tests --- .../seedvault/e2e/LargeRestoreTestBase.kt | 15 +++++++++++++++ .../seedvault/e2e/screen/impl/RestoreScreen.kt | 2 ++ 2 files changed, 17 insertions(+) diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt index 60de45bc..76a9f7d4 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeRestoreTestBase.kt @@ -72,6 +72,10 @@ internal interface LargeRestoreTestBase : LargeTestBase { backupListItem.clickAndWaitForNewWindow() waitUntilIdle() + waitForAppSelectionLoaded() + // just tap next in app selection + appsSelectedButton.clickAndWaitForNewWindow() + waitForInstallResult() if (someAppsNotInstalledText.exists()) { @@ -104,6 +108,17 @@ internal interface LargeRestoreTestBase : LargeTestBase { spyOnKVRestoreData(result) } + private fun waitForAppSelectionLoaded() = runBlocking { + withContext(Dispatchers.Main) { + withTimeout(RESTORE_TIMEOUT) { + while (spyRestoreViewModel.selectedApps.value?.apps?.isNotEmpty() != true) { + delay(100) + } + } + } + waitUntilIdle() + } + private fun waitForInstallResult() = runBlocking { withContext(Dispatchers.Main) { diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RestoreScreen.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RestoreScreen.kt index 9808621c..e17e6d1e 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RestoreScreen.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RestoreScreen.kt @@ -11,6 +11,8 @@ object RestoreScreen : UiDeviceScreen() { val backupListItem = findObject { textContains("Last backup") } + val appsSelectedButton = findObject { text("Restore backup") } + val nextButton = findObject { text("Next") } val finishButton = findObject { text("Finish") }