From 3af7fedd9bec40bf9f1bca6be83bc349285cb1df Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 24 Mar 2025 10:55:18 +0100 Subject: [PATCH] Test hotfixes --- .../ui/design/component/ZashiSeedTextField.kt | 2 + .../component/ZashiSeedWordTextField.kt | 3 +- .../restore/height/RestoreBDHeightTags.kt | 5 + .../restore/height/RestoreBDHeightView.kt | 5 +- .../ui/screen/restore/seed/RestoreSeedView.kt | 3 +- .../ui/security_warning/values-es/strings.xml | 11 -- .../ui/security_warning/values/strings.xml | 16 --- .../zcash/ui/screenshot/ScreenshotTest.kt | 110 +++++++----------- 8 files changed, 54 insertions(+), 101 deletions(-) create mode 100644 ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightTags.kt delete mode 100644 ui-lib/src/main/res/ui/security_warning/values-es/strings.xml delete mode 100644 ui-lib/src/main/res/ui/security_warning/values/strings.xml diff --git a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedTextField.kt b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedTextField.kt index 68f6495b2..333f17b39 100644 --- a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedTextField.kt +++ b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedTextField.kt @@ -45,6 +45,7 @@ import kotlinx.coroutines.launch fun ZashiSeedTextField( state: SeedTextFieldState, modifier: Modifier = Modifier, + wordModifier: (index: Int) -> Modifier = { Modifier }, handle: SeedTextFieldHandle = rememberSeedTextFieldHandle(), ) { val interactions = remember { state.values.map { MutableInteractionSource() } } @@ -105,6 +106,7 @@ fun ZashiSeedTextField( } } }, + innerModifier = wordModifier(index), prefix = (index + 1).toString(), state = wordState.copy( diff --git a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedWordTextField.kt b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedWordTextField.kt index ca6c9efd3..0aba7cf7b 100644 --- a/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedWordTextField.kt +++ b/ui-design-lib/src/main/java/co/electriccoin/zcash/ui/design/component/ZashiSeedWordTextField.kt @@ -29,13 +29,14 @@ fun ZashiSeedWordTextField( prefix: String, state: SeedWordTextFieldState, modifier: Modifier = Modifier, + innerModifier: Modifier = Modifier, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, ) { ZashiTextField( modifier = modifier, - innerModifier = Modifier, + innerModifier = innerModifier, shape = RoundedCornerShape(12.dp), keyboardOptions = keyboardOptions, keyboardActions = keyboardActions, diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightTags.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightTags.kt new file mode 100644 index 000000000..6701f9136 --- /dev/null +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightTags.kt @@ -0,0 +1,5 @@ +package co.electriccoin.zcash.ui.screen.restore.height + +object RestoreBDHeightTags { + const val RESTORE_BTN = "RESTORE_BTN" +} diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightView.kt index 389e194e8..d67dd9a4a 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/height/RestoreBDHeightView.kt @@ -132,7 +132,10 @@ private fun Content( ZashiButton( state.restore, - modifier = Modifier.fillMaxWidth(), + modifier = + Modifier + .fillMaxWidth() + .testTag(RestoreBDHeightTags.RESTORE_BTN), ) } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/seed/RestoreSeedView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/seed/RestoreSeedView.kt index 61ead70b1..305c6e0f9 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/seed/RestoreSeedView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/restore/seed/RestoreSeedView.kt @@ -108,7 +108,8 @@ private fun Content( Spacer(Modifier.height(20.dp)) ZashiSeedTextField( state = state.seed, - handle = handle + handle = handle, + wordModifier = { Modifier.testTag(RestoreSeedTag.SEED_WORD_TEXT_FIELD) } ) Spacer(Modifier.weight(1f)) Spacer(Modifier.height(24.dp)) diff --git a/ui-lib/src/main/res/ui/security_warning/values-es/strings.xml b/ui-lib/src/main/res/ui/security_warning/values-es/strings.xml deleted file mode 100644 index a92132bbe..000000000 --- a/ui-lib/src/main/res/ui/security_warning/values-es/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - Advertencia de seguridad: - - Zashi %1$s es una billetera exclusiva para Zcash, con protección de privacidad — creada por Zcashers para Zcashers. Zashi ha sido diseñada para tu privacidad y seguridad. Al instalar y usar Zashi, aceptas compartir informes de fallos con Electric Coin Co. (el desarrollador de la billetera), lo que nos ayudará a mejorar la experiencia del usuario de Zashi.*\n\nPor favor, confirma y acepta a continuación para continuar. - *Nota: - \u0020Los informes de fallos podrían revelar la fecha y hora del fallo y los eventos que ocurrieron, pero no revelarían las claves de gasto o de visualización. - - Confirmar - Acepto - diff --git a/ui-lib/src/main/res/ui/security_warning/values/strings.xml b/ui-lib/src/main/res/ui/security_warning/values/strings.xml deleted file mode 100644 index d7b1bfbd3..000000000 --- a/ui-lib/src/main/res/ui/security_warning/values/strings.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - Security warning: - - Zashi %1$s - is a Zcash-only, shielded wallet — built by Zcashers for Zcashers. Zashi has been engineered for your - privacy and safety. By installing and using Zashi, you consent to share crash reports with Electric Coin Co. - (the wallet developer), which will help us improve the Zashi user experience.*\n\nPlease acknowledge and - confirm below to proceed. - *Note: - \u0020Crash reports might reveal the timing of the crash and - what events occurred, but it would not reveal spending or viewing keys. - - Confirm - I acknowledge - \ No newline at end of file diff --git a/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ScreenshotTest.kt b/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ScreenshotTest.kt index 3d702bd33..387fa907e 100644 --- a/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ScreenshotTest.kt +++ b/ui-screenshot-test/src/main/java/co/electroniccoin/zcash/ui/screenshot/ScreenshotTest.kt @@ -5,14 +5,15 @@ package co.electroniccoin.zcash.ui.screenshot import android.content.Context import android.os.Build import android.os.LocaleList -import androidx.activity.viewModels import androidx.compose.ui.test.ExperimentalTestApi import androidx.compose.ui.test.SemanticsNodeInteraction +import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onAllNodesWithTag import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick @@ -29,7 +30,6 @@ import androidx.test.filters.LargeTest import androidx.test.filters.SdkSuppress import cash.z.ecc.android.sdk.fixture.WalletAddressFixture import cash.z.ecc.android.sdk.model.MonetarySeparators -import cash.z.ecc.android.sdk.model.SeedPhrase import cash.z.ecc.sdk.fixture.MemoFixture import cash.z.ecc.sdk.fixture.SeedPhraseFixture import cash.z.ecc.sdk.type.ZcashCurrency @@ -45,8 +45,8 @@ import co.electriccoin.zcash.ui.design.component.UiMode import co.electriccoin.zcash.ui.screen.authentication.view.AnimationConstants.WELCOME_ANIM_TEST_TAG import co.electriccoin.zcash.ui.screen.balances.BalanceTag import co.electriccoin.zcash.ui.screen.home.HomeTags +import co.electriccoin.zcash.ui.screen.restore.height.RestoreBDHeightTags import co.electriccoin.zcash.ui.screen.restore.seed.RestoreSeedTag -import co.electriccoin.zcash.ui.screen.restore.seed.RestoreSeedViewModel import co.electriccoin.zcash.ui.screen.send.SendTag import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking @@ -196,19 +196,22 @@ class ScreenshotTest : UiTestPrerequisites() { // To ensure that the new screen is available, or wait until it is composeTestRule.waitUntilAtLeastOneExists( - hasText(resContext.getString(R.string.restore_title)), + hasText(resContext.getString(R.string.restore_title), ignoreCase = true), DEFAULT_TIMEOUT_MILLISECONDS ) - composeTestRule.onNodeWithText(resContext.getString(R.string.restore_title)).also { - it.assertExists() - } + composeTestRule + .onNodeWithText( + resContext.getString(R.string.restore_title), + ignoreCase = true + ) + .assertExists() takeScreenshot(tag, "Import 1") val seedPhraseSplitLength = SeedPhraseFixture.new().split.size SeedPhraseFixture.new().split.forEachIndexed { index, string -> - composeTestRule.onNodeWithTag(RestoreSeedTag.SEED_WORD_TEXT_FIELD).also { + composeTestRule.onAllNodesWithTag(RestoreSeedTag.SEED_WORD_TEXT_FIELD)[index].also { it.performTextInput(string) // Take a screenshot half-way through filling in the seed phrase @@ -218,39 +221,39 @@ class ScreenshotTest : UiTestPrerequisites() { } } - composeTestRule.waitUntil { - composeTestRule.activity.viewModels().value.suggestionsState.value - ?.suggestions - ?.size == - SeedPhrase.SEED_PHRASE_SIZE + composeTestRule.onNodeWithText( + text = resContext.getString(R.string.restore_button), + ignoreCase = true + ).also { + // Even with waiting for the word list in the view model, + // there's some latency before the button is enabled + composeTestRule.waitUntil(5.seconds.inWholeMilliseconds) { + runCatching { it.assertIsEnabled() }.isSuccess + } + it.performScrollTo() + it.performClick() } - // composeTestRule.onNodeWithText( - // text = resContext.getString(R.string.restore_seed_button_next), - // ignoreCase = true - // ).also { - // // Even with waiting for the word list in the view model, - // // there's some latency before the button is enabled - // composeTestRule.waitUntil(5.seconds.inWholeMilliseconds) { - // runCatching { it.assertIsEnabled() }.isSuccess - // } - // it.performScrollTo() - // it.performClick() - // } - - // composeTestRule.onNodeWithText(resContext.getString(R.string.restore_birthday_header)).also { - // it.assertExists() - // } + composeTestRule + .onNodeWithText( + resContext.getString(R.string.restore_bd_subtitle), + ignoreCase = true + ) + .also { + it.assertExists() + } takeScreenshot(tag, "Import 3") - // composeTestRule.onNodeWithText( - // text = resContext.getString(R.string.restore_birthday_button_restore), - // ignoreCase = true - // ).also { - // it.performScrollTo() - // it.performClick() - // } + composeTestRule.waitUntilAtLeastOneExists( + hasTestTag(RestoreBDHeightTags.RESTORE_BTN), + timeoutMillis = DEFAULT_TIMEOUT_MILLISECONDS + ) + + composeTestRule.onNodeWithTag(RestoreBDHeightTags.RESTORE_BTN).also { + it.performScrollTo() + it.performClick() + } composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.onNodeWithText( @@ -404,41 +407,6 @@ private fun onboardingScreenshots( ).also { it.performClick() } - - // Security Warning screen - composeTestRule.onNodeWithText( - text = resContext.getString(R.string.security_warning_acknowledge), - ignoreCase = true, - useUnmergedTree = true - ).also { - it.assertExists() - it.performClick() - ScreenshotTest.takeScreenshot(tag, "Security Warning") - } - composeTestRule.onNodeWithText( - text = resContext.getString(R.string.security_warning_confirm), - ignoreCase = true, - useUnmergedTree = true - ).performClick() - - composeTestRule.waitForIdle() - - composeTestRule.waitUntil { - composeTestRule.onNodeWithText( - text = resContext.getString(R.string.seed_recovery_next_button), - ignoreCase = true, - useUnmergedTree = true - ).exists() - } - - composeTestRule.onNodeWithText( - text = resContext.getString(R.string.seed_recovery_next_button), - ignoreCase = true, - useUnmergedTree = true - ).also { - it.performScrollTo() - it.performClick() - } } private fun accountScreenshots(