[#1448] Screenshot testing enabled

* [#1448] Screenshot testing enabled

Closes #1448

* Changelog update

---------

Co-authored-by: Honza <rychnovsky.honza@gmail.com>
This commit is contained in:
Milan 2024-08-12 11:17:17 +02:00 committed by GitHub
parent b2f750fb38
commit 66458a221a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 17 deletions

View File

@ -6,6 +6,9 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2
## [Unreleased] ## [Unreleased]
## Fixed
- The app screenshot testing has been re-enabled after we moved away from AppCompat components
## [1.1.5 (706)] - 2024-08-09 ## [1.1.5 (706)] - 2024-08-09
### Changed ### Changed

View File

@ -27,10 +27,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.painter.ColorPainter import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import co.electriccoin.zcash.ui.design.R import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.AnimationConstants.ANIMATION_DURATION import co.electriccoin.zcash.ui.design.component.AnimationConstants.ANIMATION_DURATION
import co.electriccoin.zcash.ui.design.component.AnimationConstants.INITIAL_DELAY import co.electriccoin.zcash.ui.design.component.AnimationConstants.INITIAL_DELAY
import co.electriccoin.zcash.ui.design.component.AnimationConstants.WELCOME_ANIM_TEST_TAG
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.screenHeight import co.electriccoin.zcash.ui.design.util.screenHeight
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@ -40,6 +42,7 @@ import kotlin.time.Duration.Companion.milliseconds
object AnimationConstants { object AnimationConstants {
const val ANIMATION_DURATION = 700 const val ANIMATION_DURATION = 700
const val INITIAL_DELAY = 1000 const val INITIAL_DELAY = 1000
const val WELCOME_ANIM_TEST_TAG = "WELCOME_ANIM_TEST_TAG"
fun together() = (ANIMATION_DURATION + INITIAL_DELAY).toLong() fun together() = (ANIMATION_DURATION + INITIAL_DELAY).toLong()
} }
@ -56,7 +59,7 @@ fun WelcomeAnimationAutostart(
WelcomeAnimation( WelcomeAnimation(
animationState = currentAnimationState, animationState = currentAnimationState,
modifier = modifier modifier = modifier.testTag(WELCOME_ANIM_TEST_TAG)
) )
// Let's start the animation automatically in case e.g. authentication is not involved // Let's start the animation automatically in case e.g. authentication is not involved

View File

@ -2,26 +2,14 @@
package co.electroniccoin.zcash.ui.screenshot package co.electroniccoin.zcash.ui.screenshot
import org.junit.Test
// NOTE: this is just a placeholder test to satisfy this module test settings and will be removed once the below
// issue is resolved
class ScreenshotTest {
@Test
fun placeholderTest() {
assert(true)
}
}
/*
TODO [#1448]: Re-enable or rework screenshot testing
TODO [#1448]: https://github.com/Electric-Coin-Company/zashi-android/issues/1448
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import android.os.LocaleList import android.os.LocaleList
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasContentDescription
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.ComposeContentTestRule
@ -54,6 +42,7 @@ import co.electriccoin.zcash.ui.MainActivity
import co.electriccoin.zcash.ui.NavigationTargets import co.electriccoin.zcash.ui.NavigationTargets
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.viewmodel.SecretState import co.electriccoin.zcash.ui.common.viewmodel.SecretState
import co.electriccoin.zcash.ui.design.component.AnimationConstants.WELCOME_ANIM_TEST_TAG
import co.electriccoin.zcash.ui.design.component.ConfigurationOverride import co.electriccoin.zcash.ui.design.component.ConfigurationOverride
import co.electriccoin.zcash.ui.design.component.UiMode import co.electriccoin.zcash.ui.design.component.UiMode
import co.electriccoin.zcash.ui.screen.account.AccountTag import co.electriccoin.zcash.ui.screen.account.AccountTag
@ -168,6 +157,7 @@ class ScreenshotTest : UiTestPrerequisites() {
} }
} }
@OptIn(ExperimentalTestApi::class)
@Suppress("LongMethod", "CyclomaticComplexMethod") @Suppress("LongMethod", "CyclomaticComplexMethod")
private fun takeScreenshotsForRestoreWallet( private fun takeScreenshotsForRestoreWallet(
resContext: Context, resContext: Context,
@ -183,6 +173,8 @@ class ScreenshotTest : UiTestPrerequisites() {
composeTestRule.activity.walletViewModel.secretState.value is SecretState.None composeTestRule.activity.walletViewModel.secretState.value is SecretState.None
} }
composeTestRule.waitUntilDoesNotExist(hasTestTag(WELCOME_ANIM_TEST_TAG), DEFAULT_TIMEOUT_MILLISECONDS)
composeTestRule.onNodeWithText( composeTestRule.onNodeWithText(
text = text =
resContext.getString( resContext.getString(
@ -324,6 +316,7 @@ class ScreenshotTest : UiTestPrerequisites() {
} }
} }
@OptIn(ExperimentalTestApi::class)
private fun onboardingScreenshots( private fun onboardingScreenshots(
resContext: Context, resContext: Context,
tag: String, tag: String,
@ -339,6 +332,8 @@ private fun onboardingScreenshots(
ScreenshotTest.takeScreenshot(tag, "Onboarding 1") ScreenshotTest.takeScreenshot(tag, "Onboarding 1")
} }
composeTestRule.waitUntilDoesNotExist(hasTestTag(WELCOME_ANIM_TEST_TAG), DEFAULT_TIMEOUT_MILLISECONDS)
composeTestRule.onNodeWithText( composeTestRule.onNodeWithText(
text = resContext.getString(R.string.onboarding_create_new_wallet), text = resContext.getString(R.string.onboarding_create_new_wallet),
ignoreCase = true ignoreCase = true
@ -347,7 +342,10 @@ private fun onboardingScreenshots(
} }
// Security Warning screen // Security Warning screen
composeTestRule.onNodeWithText(text = resContext.getString(R.string.security_warning_acknowledge)).also { composeTestRule.onNodeWithText(
text = resContext.getString(R.string.security_warning_acknowledge),
ignoreCase = true
).also {
it.assertExists() it.assertExists()
it.performClick() it.performClick()
ScreenshotTest.takeScreenshot(tag, "Security Warning") ScreenshotTest.takeScreenshot(tag, "Security Warning")
@ -551,4 +549,3 @@ private fun seedScreenshots(
ScreenshotTest.takeScreenshot(tag, "Seed 1") ScreenshotTest.takeScreenshot(tag, "Seed 1")
} }
*/