diff --git a/.github/workflows/compose_screenshot_test.yml b/.github/workflows/compose_screenshot_test.yml new file mode 100644 index 0000000000..3f0ca43378 --- /dev/null +++ b/.github/workflows/compose_screenshot_test.yml @@ -0,0 +1,39 @@ +name: Screenshots tests + +on: + push: + branches: + - main + pull_request: + +jobs: + sceenshot_test: + runs-on: ubuntu-latest + steps: + - name: Checkout GIT + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '18' + + - name: Enable Gradle Wrapper caching (optimization) + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Run Compose preview screenshot tests + run: ./gradlew :shared:ui:testing:validateDebugScreenshotTest + + - name: Upload build reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: my-artifact + path: shared/ui/testing/build/reports \ No newline at end of file diff --git a/.github/workflows/paparazzi_screenshot_test.yml b/.github/workflows/paparazzi_screenshot_test.yml deleted file mode 100644 index 3ec49a1abb..0000000000 --- a/.github/workflows/paparazzi_screenshot_test.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Paparazzi screenshots tests - -on: - push: - branches: - - main - pull_request: - -jobs: - sceenshot_test: - runs-on: ubuntu-latest - steps: - - name: Checkout GIT - uses: actions/checkout@v4 - - - name: Setup Java SDK - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: '18' - - - name: Gradle cache - uses: gradle/actions/setup-gradle@v4 - - - name: Run Paparazzi screenshot tests - run: ./gradlew verifyPaparazziDebug diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c9644c3baa..3afb36276e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -25,8 +25,8 @@ dependencies { implementation(libs.ksp.plugin) implementation(libs.cashapp.molecule.plugin) implementation(libs.room.plugin) - implementation(libs.paparazzi.plugin) implementation(libs.module.graph.plugin) + implementation(libs.compose.screenshot.plugin) // Make version catalog available in precompiled scripts // https://github.com/gradle/gradle/issues/15383#issuecomment-1567461389 diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt new file mode 100644 index 0000000000..ccf548b56a --- /dev/null +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -0,0 +1,3 @@ +object BuildConfigConstants { + const val IMAGE_DIFFERENCE_THRESHOLD = 0.013f +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ivy.compose.preview.testing.gradle.kts b/buildSrc/src/main/kotlin/ivy.compose.preview.testing.gradle.kts new file mode 100644 index 0000000000..2090753581 --- /dev/null +++ b/buildSrc/src/main/kotlin/ivy.compose.preview.testing.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("ivy.compose") + /* + Will refactor code for import plugin for compose preview screenshot testing + when compose.screenshot has a stable version - + remove android.experimental.enableScreenshotTest + */ +// id("com.android.compose.screenshot") +} + +android { + experimentalProperties["android.experimental.enableScreenshotTest"] = true +} diff --git a/buildSrc/src/main/kotlin/ivy.feature.gradle.kts b/buildSrc/src/main/kotlin/ivy.feature.gradle.kts index c7105e9219..c03c7620fe 100644 --- a/buildSrc/src/main/kotlin/ivy.feature.gradle.kts +++ b/buildSrc/src/main/kotlin/ivy.feature.gradle.kts @@ -2,5 +2,5 @@ plugins { org.jetbrains.kotlin.plugin.compose id("ivy.module") id("ivy.compose") - id("ivy.paparazzi") + id("ivy.compose.preview.testing") } diff --git a/buildSrc/src/main/kotlin/ivy.paparazzi.gradle.kts b/buildSrc/src/main/kotlin/ivy.paparazzi.gradle.kts deleted file mode 100644 index 5609c8ac13..0000000000 --- a/buildSrc/src/main/kotlin/ivy.paparazzi.gradle.kts +++ /dev/null @@ -1,21 +0,0 @@ -plugins { - id("ivy.compose") - id("app.cash.paparazzi") -} - -// TODO Remove when https://github.com/google/guava/issues/6567 is fixed. -// See also: https://github.com/google/guava/issues/6801. -dependencies.constraints { - testImplementation("com.google.guava:guava") { - attributes { - attribute( - TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, - objects.named(TargetJvmEnvironment::class.java, TargetJvmEnvironment.STANDARD_JVM) - ) - } - because( - "Paparazzi's layoutlib and sdk-common depend on Guava's -jre published variant." + - "See https://github.com/cashapp/paparazzi/issues/906." - ) - } -} \ No newline at end of file diff --git a/docs/CI-Troubleshooting.md b/docs/CI-Troubleshooting.md index 021d424b2b..88ecb89bf4 100644 --- a/docs/CI-Troubleshooting.md +++ b/docs/CI-Troubleshooting.md @@ -2,12 +2,6 @@ If you see any of the PR checks failing (❌) go to [Actions](https://github.com/Ivy-Apps/ivy-wallet/actions) and find it there. Or simply click "Details" next to the failed check and explore the logs to see why it has failed. -## PR description check - -It means that you didn't follow our [official PR template](../.github/PULL_REQUEST_TEMPLATE.md). -Update your PR description with all necessary information. You can also check the exact error by -clicking "Details" on the failing (❌) check. - ## Detekt [Detekt](https://detekt.dev/) is a static code analyzer for Kotlin that we use to enforce code readability and good practices. @@ -77,15 +71,19 @@ This GitHub Action checks whether your `@Composable` functions are stable (i.e. Do that only if the failure is in legacy code. If the script is failing, open it and execute the commands inside it manually. -## Paparazzi Tests -Paparazzi is used for automated visual testing. It captures screenshots of various `@Composable` and then compares them against baseline images to detect any visual differences or regressions. +## Compose preview screenshot testing + +Screenshot testing is an effective way to verify how your UI looks to users. The Compose Preview Screenshot Testing tool combines the simplicity and features of composable previews with the productivity gains of running host-side screenshot tests. Compose Preview Screenshot Testing is designed to be as easy to use as composable previews. + +A screenshot test is an automated test that takes a screenshot of a piece of UI and then compares it against a previously approved reference image. If the images don't match, the test fails and produces an HTML report to help you compare and find the differences. -**Fixing Paparazzi issues:** +We also create an annotation called @IvyPreviews to serve the purpose of exporting and checking images for large-sized devices and small-sized devices. -1. Run `./gradlew verifyPaparazziDebug` locally to execute the Paparazzi tests and identify the specific screens where failures occur. -2. Upon failure, the system generates detailed reports pinpointing the changes introduced since the last successful test run. Review these reports to understand the nature of the failures. -3. If the identified changes are intentional, proceed by running `./gradlew {module_name}:recordPaparazziDebug` to update the baseline screenshots specifically for the failed UI components. -4. After updating the baseline screenshots, rerun `./gradlew {module_name}:verifyPaparazziDebug` to ensure that the tests now pass with the updated baselines. -5. Repeat this process iteratively for all modules that have failed Paparazzi tests, ensuring thorough validation and updating of baseline images as needed. +1. Run `./gradlew validateDebugScreenshotTest` locally to execute the screenshot testing and identify the specific screens where failures occur. +2. Upon failure, the system generates detailed reports pinpointing the changes introduced since the last successful test run. Review these reports to understand the nature of the failures. You can find the report at the following path: {module}/build/reports/screenshotTest/preview/{variant}/index.html + For example: screen/balance/build/reports/screenshotTest/preview/debug/index.html +3. If the identified changes are intentional, proceed by running `./gradlew :module:update{Variant}ScreenshotTest` to update the baseline screenshots specifically for the failed UI components. For example : `./gradlew :screen:balance:updateDebugScreenshotTest` +4. After updating the baseline screenshots, rerun `./gradlew :module:validate{Variant}ScreenshotTest` to ensure that the tests now pass with the updated baselines. For example : `./gradlew :screen:balance:validateDebugScreenshotTest` +5. Repeat this process iteratively for all modules that have failed compose preview screenshot testing, ensuring thorough validation and updating of baseline images as needed. > **Note**: Ensure the use of static data only. Dynamic data, such as current time or date, will cause test failures due to its variability. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4ab6bbc3ef..b8ebda8d21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,4 +22,4 @@ kotlin.code.style=official # Speed-up Gradle Builds! (OPTIMIZATION) org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 org.gradle.configuration-cache=true - +android.experimental.enableScreenshotTest=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 588d65a153..943311342d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,7 +12,7 @@ hilt = "2.52" room = "2.6.1" androidx-work = "2.9.1" kotlinx-collections = "0.3.7" -paparazzi = "1.3.3" +screenshot = "0.0.1-alpha06" # Android min-sdk = "28" @@ -60,8 +60,6 @@ kotest-assertions-arrow = { module = "io.kotest.extensions:kotest-assertions-arr kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" } cashapp-molecule-plugin = { module = "app.cash.molecule:molecule-gradle-plugin", version = "1.4.3" } cashapp-turbine = { module = "app.cash.turbine:turbine", version = "1.1.0" } -paparazzi-plugin = { module = "app.cash.paparazzi:paparazzi-gradle-plugin", version.ref = "paparazzi" } -paparazzi = { module = "app.cash.paparazzi:paparazzi", version.ref = "paparazzi" } google-testparameterinjector = { module = "com.google.testparameterinjector:test-parameter-injector", version = "1.16" } # Integartion (Android) testing @@ -145,6 +143,8 @@ ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle. # Modules Graph module-graph-plugin = { module = "com.jraska.module.graph.assertion:plugin", version = "2.6.0" } +# Compose Preview Testing +compose-screenshot-plugin = { module = "com.android.compose.screenshot:com.android.compose.screenshot.gradle.plugin", version.ref = "screenshot" } [bundles] kotlin = [ diff --git a/screen/accounts/build.gradle.kts b/screen/accounts/build.gradle.kts index 46da4b8e86..0fc5d59617 100644 --- a/screen/accounts/build.gradle.kts +++ b/screen/accounts/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.accounts" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -14,6 +20,4 @@ dependencies { implementation(projects.shared.ui.navigation) implementation(projects.temp.legacyCode) implementation(projects.temp.oldDesign) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_da39a3ee_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..5f7491e504 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..e07d29546c Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_da39a3ee_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..524c2f8c04 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..583e6d4d2b Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabCompactModeLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_da39a3ee_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..65272fcae4 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..ba67b999f6 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_da39a3ee_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..a65ae902a7 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..d8442ae4c7 Binary files /dev/null and b/screen/accounts/src/debug/screenshotTest/reference/AccountTabPreviewTestKt/PreviewAccountsTabLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt index db6aad9f8c..b50e4b1f4d 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt @@ -49,6 +49,7 @@ import com.ivy.navigation.TransactionsScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.ui.theme.Green import com.ivy.wallet.ui.theme.GreenLight @@ -334,7 +335,7 @@ private fun AccountHeader( } } -@Preview +@IvyPreviews @Composable private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme = theme) { @@ -421,7 +422,7 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) { } } -@Preview +@IvyPreviews @Composable private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme = theme) { @@ -510,7 +511,7 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) { /** For screen shot testing **/ @Composable -fun AccountsTabNonCompactUITest(dark: Boolean) { +fun AccountsTabUITest(dark: Boolean) { val theme = when (dark) { true -> Theme.DARK false -> Theme.LIGHT @@ -518,9 +519,8 @@ fun AccountsTabNonCompactUITest(dark: Boolean) { PreviewAccountsTabCompactModeDisabled(theme) } -/** For screen shot testing **/ @Composable -fun AccountsTabCompactUITest(dark: Boolean) { +fun AccountsTabUICompactModeTest(dark: Boolean) { val theme = when (dark) { true -> Theme.DARK false -> Theme.LIGHT diff --git a/screen/accounts/src/screenshotTestDebug/kotlin/AccountTabPreviewTest.kt b/screen/accounts/src/screenshotTestDebug/kotlin/AccountTabPreviewTest.kt new file mode 100644 index 0000000000..6de46cce47 --- /dev/null +++ b/screen/accounts/src/screenshotTestDebug/kotlin/AccountTabPreviewTest.kt @@ -0,0 +1,30 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.accounts.AccountsTabUICompactModeTest +import com.ivy.accounts.AccountsTabUITest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewAccountsTabLight() { + AccountsTabUITest(dark = false) +} + +@IvyPreviews +@Composable +private fun PreviewAccountsTabDark() { + AccountsTabUITest(dark = true) +} + +@IvyPreviews +@Composable +private fun PreviewAccountsTabCompactModeDark() { + AccountsTabUICompactModeTest(dark = true) +} + +@IvyPreviews +@Composable +private fun PreviewAccountsTabCompactModeLight() { + AccountsTabUICompactModeTest(dark = false) +} diff --git a/screen/accounts/src/test/java/com/ivy/accounts/AccountsTabPaparazziTest.kt b/screen/accounts/src/test/java/com/ivy/accounts/AccountsTabPaparazziTest.kt deleted file mode 100644 index f0ac525cc8..0000000000 --- a/screen/accounts/src/test/java/com/ivy/accounts/AccountsTabPaparazziTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.ivy.accounts - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class AccountsTabPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot accountTab nonCompact composable`() { - snapshot(theme) { - AccountsTabNonCompactUITest(theme == PaparazziTheme.Dark) - } - } - - @Test - fun `snapshot accountTab compact composable`() { - snapshot(theme) { - AccountsTabCompactUITest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png deleted file mode 100644 index f5dc94fc90..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Dark].png and /dev/null differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png deleted file mode 100644 index 15855b09f6..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab compact composable[Light].png and /dev/null differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Dark].png deleted file mode 100644 index 2887266a69..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Dark].png and /dev/null differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Light].png deleted file mode 100644 index 383ed6d98c..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab composable[Light].png and /dev/null differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png deleted file mode 100644 index 8c5c63d5cf..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Dark].png and /dev/null differ diff --git a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png b/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png deleted file mode 100644 index 07fffa6e55..0000000000 Binary files a/screen/accounts/src/test/snapshots/images/com.ivy.accounts_AccountsTabPaparazziTest_snapshot accountTab nonCompact composable[Light].png and /dev/null differ diff --git a/screen/attributions/build.gradle.kts b/screen/attributions/build.gradle.kts index 4386051857..057841c1bb 100644 --- a/screen/attributions/build.gradle.kts +++ b/screen/attributions/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.attributions" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -11,6 +17,4 @@ dependencies { implementation(projects.shared.domain) implementation(projects.shared.ui.core) implementation(projects.shared.ui.navigation) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_da39a3ee_da39a3ee_0.png b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..9095358e11 Binary files /dev/null and b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..f531bbc180 Binary files /dev/null and b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUIDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_da39a3ee_da39a3ee_0.png b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..72e1456cb0 Binary files /dev/null and b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..b722047483 Binary files /dev/null and b/screen/attributions/src/debug/screenshotTest/reference/AttributionScreenPreviewTestKt/AttributionsUILight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/attributions/src/main/java/com/ivy/attributions/AttributionsScreen.kt b/screen/attributions/src/main/java/com/ivy/attributions/AttributionsScreen.kt index ee5c28c467..efdbdfa7e8 100644 --- a/screen/attributions/src/main/java/com/ivy/attributions/AttributionsScreen.kt +++ b/screen/attributions/src/main/java/com/ivy/attributions/AttributionsScreen.kt @@ -32,6 +32,7 @@ import com.ivy.navigation.Navigation import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -156,7 +157,7 @@ private fun AttributionsSectionDivider( ) } -@Preview +@IvyPreviews @Composable private fun AttributionsUIPreview(isDark: Boolean = false) { val attributionItems = persistentListOf( diff --git a/screen/attributions/src/screenshotTestDebug/kotlin/AttributionScreenPreviewTest.kt b/screen/attributions/src/screenshotTestDebug/kotlin/AttributionScreenPreviewTest.kt new file mode 100644 index 0000000000..3ca74360bf --- /dev/null +++ b/screen/attributions/src/screenshotTestDebug/kotlin/AttributionScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.attributions.AttributionScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun AttributionsUILight() { + AttributionScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun AttributionsUIDark() { + AttributionScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/attributions/src/test/java/com/ivy/attributions/AttributionsScreenPaparazziTest.kt b/screen/attributions/src/test/java/com/ivy/attributions/AttributionsScreenPaparazziTest.kt deleted file mode 100644 index 130b886b90..0000000000 --- a/screen/attributions/src/test/java/com/ivy/attributions/AttributionsScreenPaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.attributions - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class AttributionsScreenPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Attribution Screen`() { - snapshot(theme) { - AttributionScreenUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Dark].png b/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Dark].png deleted file mode 100644 index 687006837d..0000000000 Binary files a/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Dark].png and /dev/null differ diff --git a/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Light].png b/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Light].png deleted file mode 100644 index c06bbde8be..0000000000 Binary files a/screen/attributions/src/test/snapshots/images/com.ivy.attributions_AttributionsScreenPaparazziTest_snapshot Attribution Screen[Light].png and /dev/null differ diff --git a/screen/balance/build.gradle.kts b/screen/balance/build.gradle.kts index 56f10e7870..b27735e73b 100644 --- a/screen/balance/build.gradle.kts +++ b/screen/balance/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.balance" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -13,6 +19,4 @@ dependencies { implementation(projects.shared.ui.navigation) implementation(projects.temp.legacyCode) implementation(projects.temp.oldDesign) - - testImplementation(projects.shared.ui.testing) } \ No newline at end of file diff --git a/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_da39a3ee_da39a3ee_0.png b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..bddc115259 Binary files /dev/null and b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..a5a83378e9 Binary files /dev/null and b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_da39a3ee_da39a3ee_0.png b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..6839e575b5 Binary files /dev/null and b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..6e95554d89 Binary files /dev/null and b/screen/balance/src/debug/screenshotTest/reference/BalanceScreenPreviewTestKt/PreviewBalanceScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/balance/src/main/java/com/ivy/balance/BalanceScreen.kt b/screen/balance/src/main/java/com/ivy/balance/BalanceScreen.kt index f49f5081a1..c60462512e 100644 --- a/screen/balance/src/main/java/com/ivy/balance/BalanceScreen.kt +++ b/screen/balance/src/main/java/com/ivy/balance/BalanceScreen.kt @@ -39,6 +39,7 @@ import com.ivy.legacy.utils.format import com.ivy.navigation.BalanceScreen import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.Gradient import com.ivy.wallet.ui.theme.Gray import com.ivy.wallet.ui.theme.Orange @@ -238,7 +239,7 @@ private fun ColumnScope.CloseButton() { } } -@Preview +@IvyPreviews @Composable private fun Preview(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { diff --git a/screen/balance/src/screenshotTestDebug/kotlin/BalanceScreenPreviewTest.kt b/screen/balance/src/screenshotTestDebug/kotlin/BalanceScreenPreviewTest.kt new file mode 100644 index 0000000000..16a34a64e6 --- /dev/null +++ b/screen/balance/src/screenshotTestDebug/kotlin/BalanceScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.balance.BalanceScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewBalanceScreenLight() { + BalanceScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewBalanceScreenDark() { + BalanceScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Dark].png b/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Dark].png deleted file mode 100644 index 94252b4745..0000000000 Binary files a/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Dark].png and /dev/null differ diff --git a/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Light].png b/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Light].png deleted file mode 100644 index f87097e505..0000000000 Binary files a/screen/balance/src/test/snapshots/images/com.ivy.balance_BalanceScreenPaparazziTest_snapshot Balance Screen[Light].png and /dev/null differ diff --git a/screen/budgets/build.gradle.kts b/screen/budgets/build.gradle.kts index 910b37ccbd..2d6a90c34a 100644 --- a/screen/budgets/build.gradle.kts +++ b/screen/budgets/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.budgets" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -14,6 +20,4 @@ dependencies { implementation(projects.shared.ui.navigation) implementation(projects.temp.legacyCode) implementation(projects.temp.oldDesign) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_da39a3ee_da39a3ee_0.png b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..69768d21aa Binary files /dev/null and b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..bd3342887a Binary files /dev/null and b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_da39a3ee_da39a3ee_0.png b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..851f4e40d7 Binary files /dev/null and b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..347f947775 Binary files /dev/null and b/screen/budgets/src/debug/screenshotTest/reference/BudgetScreenPreviewTestKt/PreviewBudgetScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/budgets/src/main/java/com/ivy/budgets/BudgetScreen.kt b/screen/budgets/src/main/java/com/ivy/budgets/BudgetScreen.kt index 74063ad9f9..fb3fb39a5c 100644 --- a/screen/budgets/src/main/java/com/ivy/budgets/BudgetScreen.kt +++ b/screen/budgets/src/main/java/com/ivy/budgets/BudgetScreen.kt @@ -22,10 +22,15 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.budgets.model.DisplayBudget import com.ivy.design.api.LocalTimeFormatter import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style +import com.ivy.legacy.IvyWalletPreview +import com.ivy.legacy.data.model.Month +import com.ivy.legacy.data.model.TimePeriod +import com.ivy.legacy.datamodel.Budget import com.ivy.legacy.legacy.ui.theme.components.BudgetBattery import com.ivy.legacy.utils.clickableNoIndication import com.ivy.legacy.utils.format @@ -34,11 +39,13 @@ import com.ivy.navigation.BudgetScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.Gray import com.ivy.wallet.ui.theme.components.IvyIcon import com.ivy.wallet.ui.theme.components.ReorderButton import com.ivy.wallet.ui.theme.components.ReorderModalSingleType import com.ivy.wallet.ui.theme.wallet.AmountCurrencyB1 +import kotlinx.collections.immutable.persistentListOf @Composable fun BoxWithConstraintsScope.BudgetScreen(screen: BudgetScreen) { @@ -54,7 +61,7 @@ fun BoxWithConstraintsScope.BudgetScreen(screen: BudgetScreen) { @Composable private fun BoxWithConstraintsScope.UI( state: BudgetScreenState, - onEvent: (BudgetScreenEvent) -> Unit = {} + onEvent: (BudgetScreenEvent) -> Unit = {}, ) { Column( modifier = Modifier @@ -170,7 +177,7 @@ private fun Toolbar( baseCurrency: String, appBudgetMax: Double, categoryBudgetsTotal: Double, - setReorderModalVisible: (Boolean) -> Unit + setReorderModalVisible: (Boolean) -> Unit, ) { Row( modifier = Modifier.fillMaxWidth(), @@ -268,7 +275,7 @@ private fun Toolbar( private fun BudgetItem( displayBudget: DisplayBudget, baseCurrency: String, - onClick: () -> Unit + onClick: () -> Unit, ) { Row( modifier = Modifier @@ -327,7 +334,7 @@ private fun BudgetItem( private fun NoBudgetsEmptyState( emptyStateTitle: String, emptyStateText: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Column( modifier = modifier.fillMaxWidth(), @@ -364,4 +371,91 @@ private fun NoBudgetsEmptyState( Spacer(Modifier.height(96.dp)) } +} + +@Suppress("UnusedPrivateMember") +@IvyPreviews +@Composable +private fun Preview_Empty() { + IvyWalletPreview { + UI( + state = BudgetScreenState( + timeRange = TimePeriod.currentMonth( + startDayOfMonth = 1 + ).fromToRange, // preview + baseCurrency = "BGN", + categories = persistentListOf(), + accounts = persistentListOf(), + budgets = persistentListOf(), + appBudgetMax = 5000.0, + categoryBudgetsTotal = 2400.0, + budgetModalData = null, + reorderModalVisible = false, + totalRemainingBudgetText = "TEST" + ) + ) + } +} + +@IvyPreviews +@Composable +private fun Preview_Budgets(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { + UI( + state = BudgetScreenState( + timeRange = TimePeriod(month = Month.monthsList().first()).fromToRange, // preview + baseCurrency = "BGN", + categories = persistentListOf(), + accounts = persistentListOf(), + appBudgetMax = 5000.0, + categoryBudgetsTotal = 0.0, + budgetModalData = null, + reorderModalVisible = false, + budgets = persistentListOf( + DisplayBudget( + budget = Budget( + name = "Ivy Marketing", + amount = 1000.0, + accountIdsSerialized = null, + categoryIdsSerialized = null, + orderId = 0.0 + ), + spentAmount = 260.0 + ), + DisplayBudget( + budget = Budget( + name = "Ivy Marketing 2", + amount = 1000.0, + accountIdsSerialized = null, + categoryIdsSerialized = null, + orderId = 0.0 + ), + spentAmount = 351.0 + ), + DisplayBudget( + budget = Budget( + name = "Baldr Products, Fidgets", + amount = 750.0, + accountIdsSerialized = null, + categoryIdsSerialized = "cat1,cat2,cat3", + orderId = 0.1 + ), + spentAmount = 50.0 + ) + ), + totalRemainingBudgetText = "TEST" + ) + ) + } +} + + +/** For screenshot testing */ +@Composable +fun BudgetScreenUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + Preview_Budgets(theme) } \ No newline at end of file diff --git a/screen/budgets/src/screenshotTestDebug/kotlin/BudgetScreenPreviewTest.kt b/screen/budgets/src/screenshotTestDebug/kotlin/BudgetScreenPreviewTest.kt new file mode 100644 index 0000000000..d9d40698e7 --- /dev/null +++ b/screen/budgets/src/screenshotTestDebug/kotlin/BudgetScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.budgets.BudgetScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewBudgetScreenLight() { + BudgetScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewBudgetScreenDark() { + BudgetScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/categories/build.gradle.kts b/screen/categories/build.gradle.kts index 4fdde27877..970208b405 100644 --- a/screen/categories/build.gradle.kts +++ b/screen/categories/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.categories" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_da39a3ee_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..eaac326cd4 Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..f147528ba4 Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_da39a3ee_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..3bc21605ce Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..f7ee2b23fc Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenCompactLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_da39a3ee_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..bde4965e35 Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..ca000fa135 Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_da39a3ee_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..e67898ca0d Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..e1c23f4747 Binary files /dev/null and b/screen/categories/src/debug/screenshotTest/reference/CategoriesScreenPreviewTestKt/PreviewCategoriesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/categories/src/main/java/com/ivy/categories/CategoriesScreen.kt b/screen/categories/src/main/java/com/ivy/categories/CategoriesScreen.kt index bbc8a3955a..1843199c30 100644 --- a/screen/categories/src/main/java/com/ivy/categories/CategoriesScreen.kt +++ b/screen/categories/src/main/java/com/ivy/categories/CategoriesScreen.kt @@ -62,6 +62,7 @@ import com.ivy.navigation.TransactionsScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.domain.data.SortOrder import com.ivy.wallet.ui.theme.Gradient @@ -681,13 +682,13 @@ private fun SelectTypeButton( } } -@Preview +@IvyPreviews @Composable private fun PreviewCategoriesCompactModeEnabled(theme: Theme = Theme.LIGHT) { Preview(theme = theme, compactModeEnabled = true) } -@Preview +@IvyPreviews @Composable private fun PreviewCategoriesCompactModeEnabledAndSearchBarEnabled(theme: Theme = Theme.LIGHT) { Preview(theme = theme, compactModeEnabled = true, displaySearchBarEnabled = true) diff --git a/screen/categories/src/screenshotTestDebug/kotlin/CategoriesScreenPreviewTest.kt b/screen/categories/src/screenshotTestDebug/kotlin/CategoriesScreenPreviewTest.kt new file mode 100644 index 0000000000..fccf2f3961 --- /dev/null +++ b/screen/categories/src/screenshotTestDebug/kotlin/CategoriesScreenPreviewTest.kt @@ -0,0 +1,30 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.categories.CategoriesScreenCompactUiTest +import com.ivy.categories.CategoriesScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewCategoriesScreenLight() { + CategoriesScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewCategoriesScreenDark() { + CategoriesScreenUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewCategoriesScreenCompactLight() { + CategoriesScreenCompactUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewCategoriesScreenCompactDark() { + CategoriesScreenCompactUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/categories/src/test/java/com/ivy/categories/CategoriesScreenPaparazziTest.kt b/screen/categories/src/test/java/com/ivy/categories/CategoriesScreenPaparazziTest.kt deleted file mode 100644 index 59676c227d..0000000000 --- a/screen/categories/src/test/java/com/ivy/categories/CategoriesScreenPaparazziTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.ivy.categories - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class CategoriesScreenPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Categories nonCompact Screen`() { - snapshot(theme) { - CategoriesScreenUiTest(theme == PaparazziTheme.Dark) - } - } - - @Test - fun `snapshot Categories nonCompact Screen with search bar`() { - snapshot(theme) { - CategoriesScreenWithSearchBarUiTest(theme == PaparazziTheme.Dark) - } - } - - @Test - fun `snapshot Categories compact Screen`() { - snapshot(theme) { - CategoriesScreenCompactUiTest(theme == PaparazziTheme.Dark) - } - } - - @Test - fun `snapshot Categories compact Screen with search bar`() { - snapshot(theme) { - CategoriesScreenWithSearchBarCompactUiTest(theme == PaparazziTheme.Dark) - } - } -} diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Dark].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Dark].png deleted file mode 100644 index 38e87daa35..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Dark].png and /dev/null differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Light].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Light].png deleted file mode 100644 index d2c9b42df3..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories Screen[Light].png and /dev/null differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Dark].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Dark].png deleted file mode 100644 index 0b98e4ba5f..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Dark].png and /dev/null differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Light].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Light].png deleted file mode 100644 index e083429b8c..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories compact Screen[Light].png and /dev/null differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png deleted file mode 100644 index bfef171f80..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Dark].png and /dev/null differ diff --git a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png b/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png deleted file mode 100644 index 507f56e4a9..0000000000 Binary files a/screen/categories/src/test/snapshots/images/com.ivy.categories_CategoriesScreenPaparazziTest_snapshot Categories nonCompact Screen[Light].png and /dev/null differ diff --git a/screen/contributors/build.gradle.kts b/screen/contributors/build.gradle.kts index 3183b04c63..60202d71a5 100644 --- a/screen/contributors/build.gradle.kts +++ b/screen/contributors/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.contributors" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -13,6 +19,4 @@ dependencies { implementation(projects.shared.ui.navigation) implementation(libs.bundles.ktor) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_da39a3ee_da39a3ee_0.png b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..e36d7f1f7a Binary files /dev/null and b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..3ce67590a7 Binary files /dev/null and b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_da39a3ee_da39a3ee_0.png b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..8f96c1a079 Binary files /dev/null and b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..2596a19050 Binary files /dev/null and b/screen/contributors/src/debug/screenshotTest/reference/ContributorsScreenPreviewTestKt/PreviewContributorScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/contributors/src/screenshotTestDebug/kotlin/ContributorsScreenPreviewTest.kt b/screen/contributors/src/screenshotTestDebug/kotlin/ContributorsScreenPreviewTest.kt new file mode 100644 index 0000000000..2e10b9d63c --- /dev/null +++ b/screen/contributors/src/screenshotTestDebug/kotlin/ContributorsScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.contributors.ContributorScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewContributorScreenLight() { + ContributorScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewContributorScreenLDark() { + ContributorScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/contributors/src/test/java/com/ivy/contributors/ContributorsScreenPaparazziTest.kt b/screen/contributors/src/test/java/com/ivy/contributors/ContributorsScreenPaparazziTest.kt deleted file mode 100644 index 502a2996a1..0000000000 --- a/screen/contributors/src/test/java/com/ivy/contributors/ContributorsScreenPaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.contributors - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class ContributorsScreenPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Contributor Screen`() { - snapshot(theme) { - ContributorScreenUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/contributors/src/test/java/com/ivy/contributors/ContributorsViewModelTest.kt b/screen/contributors/src/test/java/com/ivy/contributors/ContributorsViewModelTest.kt deleted file mode 100644 index 085a9a0414..0000000000 --- a/screen/contributors/src/test/java/com/ivy/contributors/ContributorsViewModelTest.kt +++ /dev/null @@ -1,92 +0,0 @@ -package com.ivy.contributors - -import arrow.core.Either -import com.ivy.contributors.IvyWalletRepositoryDataSource.ContributorDto -import com.ivy.contributors.IvyWalletRepositoryDataSource.IvyWalletRepositoryInfo -import com.ivy.ui.testing.ComposeViewModelTest -import com.ivy.ui.testing.runTest -import io.kotest.matchers.shouldBe -import io.kotest.matchers.types.shouldBeInstanceOf -import io.mockk.coEvery -import io.mockk.mockk -import kotlinx.collections.immutable.persistentListOf -import org.junit.Before -import org.junit.Test - -class ContributorsViewModelTest : ComposeViewModelTest() { - - private val repoDataSource = mockk() - - private lateinit var viewModel: ContributorsViewModel - - @Before - fun setup() { - viewModel = ContributorsViewModel(repoDataSource) - } - - @Test - fun `happy path, both success`() { - // given - coEvery { repoDataSource.fetchContributors() } returns Either.Right( - listOf( - ContributorDto( - login = "a", - avatarUrl = "a_avatar", - contributions = 7, - link = "a_link" - ), - ContributorDto( - login = "b", - avatarUrl = "b_avatar", - contributions = 42, - link = "b_link" - ), - ) - ) - coEvery { repoDataSource.fetchRepositoryInfo() } returns IvyWalletRepositoryInfo( - forks = 300, - stars = 2_000, - url = "abc" - ) - - // then - viewModel.runTest { - contributorsResponse shouldBe ContributorsResponse.Success( - persistentListOf( - Contributor( - name = "a", - photoUrl = "a_avatar", - contributionsCount = "7", - githubProfileUrl = "a_link" - ), - Contributor( - name = "b", - photoUrl = "b_avatar", - contributionsCount = "42", - githubProfileUrl = "b_link" - ), - ) - ) - - projectResponse shouldBe ProjectResponse.Success( - ProjectRepositoryInfo( - forks = "300", - stars = "2000", - url = "abc" - ) - ) - } - } - - @Test - fun `unhappy path, both error`() { - // given - coEvery { repoDataSource.fetchContributors() } returns Either.Left("Error") - coEvery { repoDataSource.fetchRepositoryInfo() } returns null - - viewModel.runTest { - contributorsResponse.shouldBeInstanceOf() - projectResponse.shouldBeInstanceOf() - } - } -} diff --git a/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Dark].png b/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Dark].png deleted file mode 100644 index 0310b69c9e..0000000000 Binary files a/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Dark].png and /dev/null differ diff --git a/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Light].png b/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Light].png deleted file mode 100644 index 9d6679aa7f..0000000000 Binary files a/screen/contributors/src/test/snapshots/images/com.ivy.contributors_ContributorsScreenPaparazziTest_snapshot Contributor Screen[Light].png and /dev/null differ diff --git a/screen/disclaimer/build.gradle.kts b/screen/disclaimer/build.gradle.kts index 15e7f05889..6a1f9e5eeb 100644 --- a/screen/disclaimer/build.gradle.kts +++ b/screen/disclaimer/build.gradle.kts @@ -1,15 +1,19 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.disclaimer" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { implementation(projects.shared.data.core) implementation(projects.shared.ui.core) implementation(projects.shared.ui.navigation) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_da39a3ee_da39a3ee_0.png b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..d5f2d49df4 Binary files /dev/null and b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..c06337f480 Binary files /dev/null and b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_da39a3ee_da39a3ee_0.png b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..608893f702 Binary files /dev/null and b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..bd7f07d14b Binary files /dev/null and b/screen/disclaimer/src/debug/screenshotTest/reference/DisclaimerScreenPreviewTestKt/PreviewDisclaimerScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/disclaimer/src/main/java/com/ivy/disclaimer/DisclaimerScreen.kt b/screen/disclaimer/src/main/java/com/ivy/disclaimer/DisclaimerScreen.kt index 4e2cf9babb..6380f58a44 100644 --- a/screen/disclaimer/src/main/java/com/ivy/disclaimer/DisclaimerScreen.kt +++ b/screen/disclaimer/src/main/java/com/ivy/disclaimer/DisclaimerScreen.kt @@ -13,7 +13,9 @@ import com.ivy.disclaimer.composables.AcceptTermsText import com.ivy.disclaimer.composables.AgreeButton import com.ivy.disclaimer.composables.AgreementCheckBox import com.ivy.disclaimer.composables.DisclaimerTopAppBar +import com.ivy.navigation.IvyPreview import com.ivy.navigation.screenScopedViewModel +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.component.OpenSourceCard @Composable @@ -80,4 +82,24 @@ private fun Content( Spacer(modifier = Modifier.height(48.dp)) } } +} + +@IvyPreviews +@Composable +private fun PreviewDisclaimerScreen(isDark: Boolean = false) { + IvyPreview(isDark) { + DisclaimerScreenUi( + viewState = DisclaimerViewState( + agreeButtonEnabled = true, + checkboxes = DisclaimerViewModel.LegalCheckboxes + ), + onEvent = {} + ) + } +} + +/** For screenshot testing */ +@Composable +fun DisclaimerScreenUiTest(isDark: Boolean) { + PreviewDisclaimerScreen(isDark) } \ No newline at end of file diff --git a/screen/disclaimer/src/screenshotTestDebug/kotlin/DisclaimerScreenPreviewTest.kt b/screen/disclaimer/src/screenshotTestDebug/kotlin/DisclaimerScreenPreviewTest.kt new file mode 100644 index 0000000000..3d0f56a158 --- /dev/null +++ b/screen/disclaimer/src/screenshotTestDebug/kotlin/DisclaimerScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.disclaimer.DisclaimerScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewDisclaimerScreenLight() { + DisclaimerScreenUiTest(false) +} + +@IvyPreviews +@Composable +private fun PreviewDisclaimerScreenDark() { + DisclaimerScreenUiTest(true) +} \ No newline at end of file diff --git a/screen/disclaimer/src/test/java/com/ivy/disclaimer/DisclaimerScreenPaparazziTest.kt b/screen/disclaimer/src/test/java/com/ivy/disclaimer/DisclaimerScreenPaparazziTest.kt deleted file mode 100644 index 18f8186d9b..0000000000 --- a/screen/disclaimer/src/test/java/com/ivy/disclaimer/DisclaimerScreenPaparazziTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.ivy.disclaimer - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import kotlinx.collections.immutable.toImmutableList -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class DisclaimerScreenPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - - @Test - fun `none checked`() { - snapshot(theme) { - DisclaimerScreenUi( - viewState = DisclaimerViewState( - checkboxes = DisclaimerViewModel.LegalCheckboxes, - agreeButtonEnabled = false, - ), - onEvent = {} - ) - } - } - - @Test - fun `all checked`() { - snapshot(theme) { - DisclaimerScreenUi( - viewState = DisclaimerViewState( - checkboxes = DisclaimerViewModel.LegalCheckboxes.map { - it.copy(checked = true) - }.toImmutableList(), - agreeButtonEnabled = true, - ), - onEvent = {} - ) - } - } -} \ No newline at end of file diff --git a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Dark].png b/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Dark].png deleted file mode 100644 index 836ae79e61..0000000000 Binary files a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Dark].png and /dev/null differ diff --git a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Light].png b/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Light].png deleted file mode 100644 index 2d5956626a..0000000000 Binary files a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_all checked[Light].png and /dev/null differ diff --git a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Dark].png b/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Dark].png deleted file mode 100644 index e2b6183a67..0000000000 Binary files a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Dark].png and /dev/null differ diff --git a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Light].png b/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Light].png deleted file mode 100644 index df0189f5ab..0000000000 Binary files a/screen/disclaimer/src/test/snapshots/images/com.ivy.disclaimer_DisclaimerScreenPaparazziTest_none checked[Light].png and /dev/null differ diff --git a/screen/edit-transaction/build.gradle.kts b/screen/edit-transaction/build.gradle.kts index a7991e141f..49815bef07 100644 --- a/screen/edit-transaction/build.gradle.kts +++ b/screen/edit-transaction/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.transaction" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -15,6 +21,4 @@ dependencies { implementation(projects.temp.legacyCode) implementation(projects.temp.oldDesign) implementation(projects.widget.balance) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_da39a3ee_da39a3ee_0.png b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..0ed09dcfae Binary files /dev/null and b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..1cefec64b8 Binary files /dev/null and b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_da39a3ee_da39a3ee_0.png b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..01735e7bd7 Binary files /dev/null and b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..d666e5f4b1 Binary files /dev/null and b/screen/edit-transaction/src/debug/screenshotTest/reference/EditTransactionPreviewTestKt/PreviewEditTransactionScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt index dac4dabc1c..511faff1d4 100644 --- a/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt +++ b/screen/edit-transaction/src/main/java/com/ivy/transaction/EditTransactionScreen.kt @@ -51,10 +51,10 @@ import com.ivy.legacy.ui.component.tags.ShowTagModal import com.ivy.legacy.utils.onScreenStart import com.ivy.navigation.EditPlannedScreen import com.ivy.navigation.EditTransactionScreen -import com.ivy.navigation.IvyPreview import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.domain.data.CustomExchangeRateState import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData @@ -658,10 +658,10 @@ private val testDateTime = LocalDateTime.of(2023, 4, 27, 0, 35) .toInstant(ZoneOffset.UTC) @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun BoxWithConstraintsScope.Preview(isDark: Boolean = false) { - IvyPreview(isDark) { +private fun EditTransactionScreenPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { UI( screen = EditTransactionScreen(null, TransactionType.EXPENSE), initialTitle = "", @@ -713,7 +713,5 @@ fun EditTransactionScreenUiTest(isDark: Boolean) { true -> Theme.DARK false -> Theme.LIGHT } - IvyWalletPreview(theme) { - Preview(isDark) - } + EditTransactionScreenPreview(theme = theme) } diff --git a/screen/edit-transaction/src/screenshotTestDebug/kotlin/EditTransactionPreviewTest.kt b/screen/edit-transaction/src/screenshotTestDebug/kotlin/EditTransactionPreviewTest.kt new file mode 100644 index 0000000000..d17760def8 --- /dev/null +++ b/screen/edit-transaction/src/screenshotTestDebug/kotlin/EditTransactionPreviewTest.kt @@ -0,0 +1,19 @@ +@file:OptIn(ExperimentalFoundationApi::class) +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.runtime.Composable +import com.ivy.transaction.EditTransactionScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewEditTransactionScreenLight() { + EditTransactionScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewEditTransactionScreenDark() { + EditTransactionScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/exchange-rates/build.gradle.kts b/screen/exchange-rates/build.gradle.kts index fc1cb51e65..6122f6b818 100644 --- a/screen/exchange-rates/build.gradle.kts +++ b/screen/exchange-rates/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.exchangerates" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_da39a3ee_da39a3ee_0.png b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..ab0a9544dc Binary files /dev/null and b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..1d9564dbb0 Binary files /dev/null and b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_da39a3ee_da39a3ee_0.png b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..ce045e7466 Binary files /dev/null and b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..dbeaddc994 Binary files /dev/null and b/screen/exchange-rates/src/debug/screenshotTest/reference/ExchangeRatesScreenPreviewTestKt/PreviewExchangeRatesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/exchange-rates/src/main/java/com/ivy/exchangerates/ExchangeRatesScreen.kt b/screen/exchange-rates/src/main/java/com/ivy/exchangerates/ExchangeRatesScreen.kt index 09f87a9920..4f37719012 100644 --- a/screen/exchange-rates/src/main/java/com/ivy/exchangerates/ExchangeRatesScreen.kt +++ b/screen/exchange-rates/src/main/java/com/ivy/exchangerates/ExchangeRatesScreen.kt @@ -32,6 +32,7 @@ import com.ivy.exchangerates.modal.AddRateModal import com.ivy.legacy.IvyWalletPreview import com.ivy.legacy.ui.SearchInput import com.ivy.legacy.utils.selectEndTextFieldValue +import com.ivy.ui.annotation.IvyPreviews import com.ivy.navigation.navigation import com.ivy.wallet.ui.theme.modal.edit.AmountModal import kotlinx.collections.immutable.persistentListOf @@ -186,7 +187,7 @@ private fun SearchField( ) } -@Preview +@IvyPreviews @Composable private fun Preview(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { diff --git a/screen/exchange-rates/src/screenshotTestDebug/kotlin/ExchangeRatesScreenPreviewTest.kt b/screen/exchange-rates/src/screenshotTestDebug/kotlin/ExchangeRatesScreenPreviewTest.kt new file mode 100644 index 0000000000..e6f1c82330 --- /dev/null +++ b/screen/exchange-rates/src/screenshotTestDebug/kotlin/ExchangeRatesScreenPreviewTest.kt @@ -0,0 +1,17 @@ +import androidx.compose.runtime.Composable +import com.ivy.exchangerates.ExchangeRatesScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@Suppress("UnusedPrivateMember") +@IvyPreviews +@Composable +private fun PreviewExchangeRatesScreenLight() { + ExchangeRatesScreenUiTest(isDark = false) +} + +@Suppress("UnusedPrivateMember") +@IvyPreviews +@Composable +private fun PreviewExchangeRatesScreenDark() { + ExchangeRatesScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/exchange-rates/src/test/java/com/ivy/exchangerates/ExchangeRatesScreenPaparazziTest.kt b/screen/exchange-rates/src/test/java/com/ivy/exchangerates/ExchangeRatesScreenPaparazziTest.kt deleted file mode 100644 index 85ab25b058..0000000000 --- a/screen/exchange-rates/src/test/java/com/ivy/exchangerates/ExchangeRatesScreenPaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.exchangerates - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class ExchangeRatesScreenPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Exchange Rates Screen`() { - snapshot(theme) { - ExchangeRatesScreenUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Dark].png b/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Dark].png deleted file mode 100644 index 23114fad8c..0000000000 Binary files a/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Dark].png and /dev/null differ diff --git a/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Light].png b/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Light].png deleted file mode 100644 index 6ab4e38b2f..0000000000 Binary files a/screen/exchange-rates/src/test/snapshots/images/com.ivy.exchangerates_ExchangeRatesScreenPaparazziTest_snapshot Exchange Rates Screen[Light].png and /dev/null differ diff --git a/screen/features/build.gradle.kts b/screen/features/build.gradle.kts index a81ae19644..d2477e6ec2 100644 --- a/screen/features/build.gradle.kts +++ b/screen/features/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.features" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_da39a3ee_da39a3ee_0.png b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..a62ba5284e Binary files /dev/null and b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..6f5abf5d00 Binary files /dev/null and b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_da39a3ee_da39a3ee_0.png b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..de90f8c25d Binary files /dev/null and b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..1cd058a1b0 Binary files /dev/null and b/screen/features/src/debug/screenshotTest/reference/FeaturesScreenPreviewTestKt/PreviewFeaturesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/features/src/main/java/com/ivy/features/FeaturesScreen.kt b/screen/features/src/main/java/com/ivy/features/FeaturesScreen.kt index 7747750066..1c99b13652 100644 --- a/screen/features/src/main/java/com/ivy/features/FeaturesScreen.kt +++ b/screen/features/src/main/java/com/ivy/features/FeaturesScreen.kt @@ -28,14 +28,16 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import androidx.lifecycle.viewmodel.compose.viewModel +import com.ivy.navigation.IvyPreview import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel +import com.ivy.ui.annotation.IvyPreviews import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf @Composable fun FeaturesScreenImpl( - viewModel: FeaturesViewModel = screenScopedViewModel() + viewModel: FeaturesViewModel = screenScopedViewModel(), ) { FeaturesUi( uiState = viewModel.uiState(), @@ -159,3 +161,45 @@ private fun FeatureRow( } } } + + +@IvyPreviews +@Composable +private fun FeatureScreenPreview(isDark: Boolean = false) { + IvyPreview(isDark) { + FeaturesUi( + uiState = FeaturesUiState( + features = persistentListOf( + FeatureUi( + name = "Feature A", + enabled = true, + description = "Connected to process 13436 on device 'Pixel_7a_API_34 [emulator-5554]'" + ), + FeatureUi( + name = "This is a very very long text feature name", + enabled = false, + description = "Connected to process 13436 on device 'Pixel_7a_API_34 [emulator-5554]'" + ), + FeatureUi( + name = "Feature C", + enabled = false, + description = "Connected to process 13436 on device 'Pixel_7a_API_34 [emulator-5554]'" + ), + FeatureUi( + name = "Feature D", + enabled = true, + description = "Connected to process 13436 on device 'Pixel_7a_API_34 [emulator-5554]'" + ), + ) + ), + onEvent = {}, + ) + } +} + +/** For screenshot testing */ +@Composable +fun FeatureScreenUiTest(isDark: Boolean) { + FeatureScreenPreview(isDark) +} + diff --git a/screen/features/src/screenshotTestDebug/kotlin/FeaturesScreenPreviewTest.kt b/screen/features/src/screenshotTestDebug/kotlin/FeaturesScreenPreviewTest.kt new file mode 100644 index 0000000000..19902a93fe --- /dev/null +++ b/screen/features/src/screenshotTestDebug/kotlin/FeaturesScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.features.FeatureScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewFeaturesScreenLight() { + FeatureScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewFeaturesScreenDark() { + FeatureScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/home/build.gradle.kts b/screen/home/build.gradle.kts index 5f445d7136..6a1fd1bcb7 100644 --- a/screen/home/build.gradle.kts +++ b/screen/home/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.home" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_da39a3ee_da39a3ee_0.png b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..65787fba07 Binary files /dev/null and b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..5d5663c144 Binary files /dev/null and b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_da39a3ee_da39a3ee_0.png b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..e7248d9aff Binary files /dev/null and b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..c2570e3a47 Binary files /dev/null and b/screen/home/src/debug/screenshotTest/reference/HomeTabPreviewTestKt/PreviewHomeTabLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/home/src/main/java/com/ivy/home/HomeTab.kt b/screen/home/src/main/java/com/ivy/home/HomeTab.kt index 7635272e7d..1d9065d9c2 100644 --- a/screen/home/src/main/java/com/ivy/home/HomeTab.kt +++ b/screen/home/src/main/java/com/ivy/home/HomeTab.kt @@ -22,7 +22,6 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.ivy.base.legacy.Theme import com.ivy.base.legacy.Transaction @@ -49,9 +48,9 @@ import com.ivy.legacy.ui.component.transaction.transactions import com.ivy.legacy.utils.horizontalSwipeListener import com.ivy.legacy.utils.rememberSwipeListenerState import com.ivy.legacy.utils.verticalSwipeListener -import com.ivy.navigation.IvyPreview import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.domain.pure.data.IncomeExpensePair @@ -310,7 +309,7 @@ fun HomeLazyColumn( onHiddenIncomeClick: () -> Unit, onSkipTransaction: (Transaction) -> Unit, onSkipAllTransactions: (List) -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { val ivyContext = ivyWalletCtx() @@ -319,7 +318,7 @@ fun HomeLazyColumn( override fun onPostScroll( consumed: Offset, available: Offset, - source: NestedScrollSource + source: NestedScrollSource, ): Offset { onSetExpand(listState.firstVisibleItemScrollOffset == 0) return super.onPostScroll(consumed, available, source) @@ -394,10 +393,10 @@ fun HomeLazyColumn( @ExperimentalAnimationApi @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun BoxWithConstraintsScope.PreviewHomeTab(isDark: Boolean = false) { - IvyPreview(isDark) { +private fun PreviewHomeTab(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { HomeUi( uiState = HomeState( theme = Theme.AUTO, @@ -443,7 +442,5 @@ fun HomeUiTest(isDark: Boolean) { true -> Theme.DARK false -> Theme.LIGHT } - IvyWalletPreview(theme) { - PreviewHomeTab(isDark) - } + PreviewHomeTab(theme) } diff --git a/screen/home/src/screenshotTestDebug/kotlin/HomeTabPreviewTest.kt b/screen/home/src/screenshotTestDebug/kotlin/HomeTabPreviewTest.kt new file mode 100644 index 0000000000..6eb3aa56c6 --- /dev/null +++ b/screen/home/src/screenshotTestDebug/kotlin/HomeTabPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.home.HomeUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewHomeTabLight() { + HomeUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewHomeTabDark() { + HomeUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/home/src/test/java/com/ivy/home/HomePaparazziTest.kt b/screen/home/src/test/java/com/ivy/home/HomePaparazziTest.kt deleted file mode 100644 index 21003fcdc5..0000000000 --- a/screen/home/src/test/java/com/ivy/home/HomePaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.home - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class HomePaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Home Screen`() { - snapshot(theme) { - HomeUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Dark].png b/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Dark].png deleted file mode 100644 index 8e5d356723..0000000000 Binary files a/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Dark].png and /dev/null differ diff --git a/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Light].png b/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Light].png deleted file mode 100644 index 6a7cbd7b67..0000000000 Binary files a/screen/home/src/test/snapshots/images/com.ivy.home_HomePaparazziTest_snapshot Home Screen[Light].png and /dev/null differ diff --git a/screen/import-data/build.gradle.kts b/screen/import-data/build.gradle.kts index 378377fec8..718ac9ce7b 100644 --- a/screen/import-data/build.gradle.kts +++ b/screen/import-data/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.importdata" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_da39a3ee_da39a3ee_0.png b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..2789c22355 Binary files /dev/null and b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..13aeca5bbe Binary files /dev/null and b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_da39a3ee_da39a3ee_0.png b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..0c5709d559 Binary files /dev/null and b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..6fd7649e37 Binary files /dev/null and b/screen/import-data/src/debug/screenshotTest/reference/ImportDataScreenPreviewTestKt/PreviewImportScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/import-data/src/main/java/com/ivy/importdata/csvimport/ImportScreen.kt b/screen/import-data/src/main/java/com/ivy/importdata/csvimport/ImportScreen.kt index 65fbd7a22d..08ad5c378a 100644 --- a/screen/import-data/src/main/java/com/ivy/importdata/csvimport/ImportScreen.kt +++ b/screen/import-data/src/main/java/com/ivy/importdata/csvimport/ImportScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.viewmodel.compose.viewModel +import com.ivy.base.legacy.Theme import com.ivy.importdata.csvimport.flow.ImportFrom import com.ivy.importdata.csvimport.flow.ImportProcessing import com.ivy.importdata.csvimport.flow.ImportResultUI @@ -16,6 +17,8 @@ import com.ivy.legacy.domain.deprecated.logic.csv.model.ImportType import com.ivy.navigation.ImportScreen import com.ivy.onboarding.viewmodel.OnboardingViewModel import com.ivy.data.backup.ImportResult +import com.ivy.legacy.IvyWalletPreview +import com.ivy.ui.annotation.IvyPreviews @OptIn(ExperimentalStdlibApi::class) @ExperimentalFoundationApi @@ -111,10 +114,10 @@ private fun BoxWithConstraintsScope.UI( } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview() { - com.ivy.legacy.IvyWalletPreview { +private fun ImportScreenPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { UI( screen = ImportScreen(launchedFromOnboarding = true), importStep = ImportStep.IMPORT_FROM, @@ -124,3 +127,14 @@ private fun Preview() { ) } } + +/** For screenshot testing */ +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun ImportScreenUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + ImportScreenPreview(theme) +} diff --git a/screen/import-data/src/screenshotTestDebug/kotlin/ImportDataScreenPreviewTest.kt b/screen/import-data/src/screenshotTestDebug/kotlin/ImportDataScreenPreviewTest.kt new file mode 100644 index 0000000000..f70dea3dbe --- /dev/null +++ b/screen/import-data/src/screenshotTestDebug/kotlin/ImportDataScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.importdata.csvimport.ImportScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewImportScreenLight() { + ImportScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewImportScreenDark() { + ImportScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/loans/build.gradle.kts b/screen/loans/build.gradle.kts index 9c08720992..36a64df423 100644 --- a/screen/loans/build.gradle.kts +++ b/screen/loans/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.loans" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { @@ -14,6 +20,4 @@ dependencies { implementation(projects.shared.ui.navigation) implementation(projects.temp.legacyCode) implementation(projects.temp.oldDesign) - - testImplementation(projects.shared.ui.testing) } diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_da39a3ee_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..0bd5dac003 Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..e8cc5cfe3e Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_da39a3ee_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..3d4b1a67c0 Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..254b6a6cfa Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoanDetailsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_da39a3ee_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..7cba1beb94 Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..bafa0c2695 Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_da39a3ee_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..ddb3df036a Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..44cdad8df6 Binary files /dev/null and b/screen/loans/src/debug/screenshotTest/reference/LoansScreenPreviewTestKt/PreviewLoansScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt b/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt index 1ff99e96a0..f1a60153cf 100644 --- a/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt +++ b/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt @@ -46,6 +46,7 @@ import com.ivy.navigation.LoanDetailsScreen import com.ivy.navigation.LoansScreen import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.Blue import com.ivy.wallet.ui.theme.Gray import com.ivy.wallet.ui.theme.Orange @@ -407,7 +408,7 @@ private fun NoLoansEmptyState( /** For Preview purpose **/ private val testDateTime = LocalDateTime.of(2023, 4, 20, 0, 35) -@Preview +@IvyPreviews @Composable private fun Preview(theme: Theme = Theme.LIGHT) { val state = LoanScreenState( diff --git a/screen/loans/src/main/java/com/ivy/loans/loandetails/LoanDetailsScreen.kt b/screen/loans/src/main/java/com/ivy/loans/loandetails/LoanDetailsScreen.kt index 9cbb4bc7f2..052aacd2a7 100644 --- a/screen/loans/src/main/java/com/ivy/loans/loandetails/LoanDetailsScreen.kt +++ b/screen/loans/src/main/java/com/ivy/loans/loandetails/LoanDetailsScreen.kt @@ -64,6 +64,7 @@ import com.ivy.navigation.LoanDetailsScreen import com.ivy.navigation.TransactionsScreen import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.time.TimeFormatter import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.ui.theme.Gradient @@ -889,7 +890,7 @@ private fun NoLoanRecordsEmptyState() { } } -@Preview +@IvyPreviews @Composable private fun Preview_Empty() { IvyWalletPreview { @@ -923,7 +924,7 @@ private fun Preview_Empty() { /** For Preview purpose **/ private val testDateTime = LocalDateTime.of(2023, 4, 27, 0, 35) -@Preview +@IvyPreviews @Composable private fun Preview_Records(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { diff --git a/screen/loans/src/screenshotTestDebug/kotlin/LoansScreenPreviewTest.kt b/screen/loans/src/screenshotTestDebug/kotlin/LoansScreenPreviewTest.kt new file mode 100644 index 0000000000..01243d2af0 --- /dev/null +++ b/screen/loans/src/screenshotTestDebug/kotlin/LoansScreenPreviewTest.kt @@ -0,0 +1,30 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.loans.loan.LoanScreenUiTest +import com.ivy.loans.loandetails.LoanDetailScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewLoansScreenLight() { + LoanScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewLoansScreenDark() { + LoanScreenUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewLoanDetailsScreenLight() { + LoanDetailScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewLoanDetailsScreenDark() { + LoanDetailScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/onboarding/build.gradle.kts b/screen/onboarding/build.gradle.kts index 649da187cd..f49a6d7021 100644 --- a/screen/onboarding/build.gradle.kts +++ b/screen/onboarding/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.onboarding" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..3043640c54 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..d15ab740f3 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..5ef23efab6 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..aec00f04ae Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..fb4e8f0526 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..839c04e859 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..4e6c68f402 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..205406d8ce Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingAccountsLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..6e6b9a033c Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..eac2978fae Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDarkEmptyState_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..1c151f373f Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..80f0aecb9c Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..061ab86ae6 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..1ffc45e805 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLightEmptyState_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..3de7b3f3cb Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..3f9c74923e Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingCategoriesLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..42e1b7701d Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..836a64bcfc Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..cf8654c8c6 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..626a07a10f Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingImportCSVFileLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..be01fccecb Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..818ecd87d1 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..0e2ea23631 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..e49933d07e Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSetCurrencyLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..6515e78c6c Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..09e36e61eb Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_da39a3ee_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..cb8e7f52f8 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..ee4f113db3 Binary files /dev/null and b/screen/onboarding/src/debug/screenshotTest/reference/OnboardingScreenPreviewTestKt/PreviewOnboardingSplashLoginLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt index ad6b497492..e3c3427af2 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingAccounts.kt @@ -1,5 +1,6 @@ package com.ivy.onboarding.steps +import android.annotation.SuppressLint import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -31,8 +32,8 @@ import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.IvyWalletPreview @@ -44,6 +45,7 @@ import com.ivy.onboarding.components.OnboardingProgressSlider import com.ivy.onboarding.components.OnboardingToolbar import com.ivy.onboarding.components.Suggestions import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.domain.deprecated.logic.model.CreateAccountData import com.ivy.wallet.ui.theme.GradientIvy import com.ivy.wallet.ui.theme.Green @@ -73,7 +75,7 @@ fun BoxWithConstraintsScope.OnboardingAccounts( onEditAccount: (Account, Double) -> Unit = { _, _ -> }, onSkip: () -> Unit = {}, - onDoneClick: () -> Unit = {} + onDoneClick: () -> Unit = {}, ) { var accountModalData: AccountModalData? by remember { mutableStateOf(null) } @@ -213,11 +215,12 @@ fun BoxWithConstraintsScope.OnboardingAccounts( ) } +@SuppressLint("ComposeMultipleContentEmitters") @Composable private fun Accounts( baseCurrency: String, accounts: List, - onClick: (AccountBalance) -> Unit + onClick: (AccountBalance) -> Unit, ) { for (account in accounts) { AccountCard( @@ -235,7 +238,7 @@ private fun Accounts( private fun AccountCard( baseCurrency: String, accountBalance: AccountBalance, - onClick: () -> Unit + onClick: () -> Unit, ) { val account = accountBalance.account val accountColor = account.color.toComposeColor() @@ -287,10 +290,10 @@ private fun AccountCard( } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview_Empty() { - IvyWalletPreview { +private fun OnboardingAccountEmpty(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { val baseCurrency = "BGN" OnboardingAccounts( baseCurrency = baseCurrency, @@ -323,55 +326,10 @@ private fun Preview_Empty() { } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview_Accounts() { - IvyWalletPreview { - val baseCurrency = "BGN" - OnboardingAccounts( - baseCurrency = baseCurrency, - suggestions = listOf( - CreateAccountData( - name = "Cash", - currency = baseCurrency, - color = Green, - icon = "cash", - balance = 0.0 - ), - CreateAccountData( - name = "Bank", - currency = baseCurrency, - color = Ivy, - icon = "bank", - balance = 0.0 - ), - CreateAccountData( - name = "Revolut", - currency = baseCurrency, - color = Color(0xFF4DCAFF), - icon = "revolut", - balance = 0.0 - ), - ), - accounts = listOf( - AccountBalance( - account = Account( - name = "Cash", - color = Green.toArgb(), - icon = "cash" - ), - balance = 0.0 - ) - ) - ) - } -} - -@ExperimentalFoundationApi -@Preview -@Composable -private fun Preview_Premium() { - IvyWalletPreview { +private fun OnboardingAccountNotEmpty(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { val baseCurrency = "BGN" OnboardingAccounts( baseCurrency = baseCurrency, @@ -427,3 +385,18 @@ private fun Preview_Premium() { ) } } + +/** For screenshot testing */ +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun OnboardingAccountUiTest(isDark: Boolean, isEmptyState: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + if (isEmptyState) { + OnboardingAccountEmpty(theme) + } else { + OnboardingAccountNotEmpty(theme) + } +} diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingCategories.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingCategories.kt index 9bf5b7274a..d723d081e5 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingCategories.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingCategories.kt @@ -1,5 +1,6 @@ package com.ivy.onboarding.steps +import android.annotation.SuppressLint import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -33,6 +34,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.data.model.Category import com.ivy.data.model.CategoryId import com.ivy.data.model.primitive.ColorInt @@ -47,6 +49,7 @@ import com.ivy.onboarding.components.OnboardingProgressSlider import com.ivy.onboarding.components.OnboardingToolbar import com.ivy.onboarding.components.Suggestions import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.domain.deprecated.logic.model.CreateCategoryData import com.ivy.wallet.ui.theme.GradientIvy import com.ivy.wallet.ui.theme.Green @@ -54,6 +57,7 @@ import com.ivy.wallet.ui.theme.Ivy import com.ivy.wallet.ui.theme.IvyDark import com.ivy.wallet.ui.theme.Orange import com.ivy.wallet.ui.theme.OrangeLight +import com.ivy.wallet.ui.theme.Purple1Dark import com.ivy.wallet.ui.theme.Red import com.ivy.wallet.ui.theme.RedLight import com.ivy.wallet.ui.theme.White @@ -210,6 +214,7 @@ fun BoxWithConstraintsScope.OnboardingCategories( ) } +@SuppressLint("ComposeMultipleContentEmitters") @Composable private fun Categories( categories: List, @@ -271,10 +276,10 @@ private fun CategoryCard( } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview_Empty() { - IvyWalletPreview { +private fun OnboardingCategoriesEmpty(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { OnboardingCategories( suggestions = listOf( CreateCategoryData( @@ -337,10 +342,10 @@ private fun Preview_Empty() { } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview_Categories() { - IvyWalletPreview { +private fun OnboardingCategoriesNotEmpty(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { OnboardingCategories( suggestions = listOf( CreateCategoryData( @@ -399,87 +404,35 @@ private fun Preview_Categories() { ), categories = listOf( Category( - name = NotBlankTrimmedString.unsafe("Food & Drinks"), - color = ColorInt(Orange.toArgb()), - icon = IconAsset.unsafe("fooddrinks"), + name = NotBlankTrimmedString.unsafe("Science"), + color = ColorInt(Purple1Dark.toArgb()), + icon = IconAsset.unsafe("atom"), id = CategoryId(UUID.randomUUID()), orderNum = 0.0, - ) + ), + Category( + id = CategoryId(UUID.randomUUID()), + name = NotBlankTrimmedString.unsafe("Ivy"), + color = ColorInt(IvyDark.toArgb()), + icon = IconAsset.unsafe("star"), + orderNum = 0.0, + ), ) ) } } -@ExperimentalFoundationApi -@Preview +/** For screenshot testing */ +@OptIn(ExperimentalFoundationApi::class) @Composable -private fun Preview_Premium() { - IvyWalletPreview { - OnboardingCategories( - suggestions = listOf( - CreateCategoryData( - name = "Food & Drinks", - color = Green, - icon = "fooddrink" - ), - - CreateCategoryData( - name = "Bills & Fees", - color = Red, - icon = "bills" - ), - - CreateCategoryData( - name = "Transport", - color = OrangeLight, - icon = "transport" - ), - - CreateCategoryData( - name = "Groceries", - color = Color(0xFF75ff4d), - icon = "groceries" - ), - - CreateCategoryData( - name = "Entertainment", - color = Orange, - icon = "game" - ), - - CreateCategoryData( - name = "Shopping", - color = Ivy, - icon = "shopping" - ), - - CreateCategoryData( - name = "Gifts", - color = RedLight, - icon = "gift" - ), - - CreateCategoryData( - name = "Health", - color = Color(0xFF4dfff3), - icon = "health" - ), - - CreateCategoryData( - name = "Investments", - color = Color(0xFF1e5166), - icon = "leaf" - ), - ), - categories = List(12) { - Category( - name = NotBlankTrimmedString.unsafe("Food & Drinks"), - color = ColorInt(Orange.toArgb()), - icon = IconAsset.unsafe("fooddrinks"), - id = CategoryId(UUID.randomUUID()), - orderNum = 0.0, - ) - } - ) +fun OnboardingCategoriesUiTest(isDark: Boolean, isEmptyState: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + if (isEmptyState) { + OnboardingCategoriesEmpty(theme) + } else { + OnboardingCategoriesNotEmpty(theme) } } diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSetCurrency.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSetCurrency.kt index 9d64a5b273..ec6479018c 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSetCurrency.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSetCurrency.kt @@ -21,12 +21,14 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.IvyWalletPreview import com.ivy.legacy.utils.setStatusBarDarkTextCompat import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.ui.theme.GradientIvy import com.ivy.wallet.ui.theme.White @@ -114,13 +116,23 @@ fun BoxWithConstraintsScope.OnboardingSetCurrency( } } -@Preview +@IvyPreviews @Composable -private fun Preview() { - IvyWalletPreview { +private fun OnboardingSetCurrencyPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { OnboardingSetCurrency( preselectedCurrency = IvyCurrency.getDefault() ) { } } } + +/** For screenshot testing */ +@Composable +fun OnboardingSetCurrencyUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + OnboardingSetCurrencyPreview(theme) +} diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSplashLogin.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSplashLogin.kt index 6a00de6380..882cc6ceb5 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSplashLogin.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingSplashLogin.kt @@ -1,5 +1,6 @@ package com.ivy.onboarding.steps +import android.annotation.SuppressLint import androidx.annotation.DrawableRes import androidx.compose.animation.core.animateDp import androidx.compose.animation.core.animateFloat @@ -41,10 +42,11 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style +import com.ivy.design.utils.thenIf import com.ivy.legacy.Constants import com.ivy.legacy.IvyWalletCtx import com.ivy.legacy.IvyWalletPreview @@ -53,13 +55,13 @@ import com.ivy.legacy.utils.clickableNoIndication import com.ivy.legacy.utils.drawColoredShadow import com.ivy.legacy.utils.lerp import com.ivy.legacy.utils.openUrl -import com.ivy.legacy.utils.springBounceSlow -import com.ivy.design.utils.thenIf import com.ivy.legacy.utils.rememberInteractionSource +import com.ivy.legacy.utils.springBounceSlow import com.ivy.legacy.utils.toDensityDp import com.ivy.legacy.utils.toDensityPx import com.ivy.onboarding.OnboardingState import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.Gradient import com.ivy.wallet.ui.theme.Gray import com.ivy.wallet.ui.theme.Green @@ -238,7 +240,7 @@ fun BoxWithConstraintsScope.OnboardingSplashLogin( private fun Modifier.animateXCenterToLeft( ivyContext: IvyWalletCtx, - percentTransition: Float + percentTransition: Float, ): Modifier { return this.layout { measurable, constraints -> val placeable = measurable.measure(constraints) @@ -258,7 +260,7 @@ private fun Modifier.animateXCenterToLeft( @Composable private fun LoginSection( percentTransition: Float, - onSkip: () -> Unit + onSkip: () -> Unit, ) { if (percentTransition > 0.01f) { Column( @@ -292,6 +294,7 @@ private fun LoginSection( } } +@SuppressLint("ComposeMultipleContentEmitters", "ComposeContentEmitterReturningValues") @Composable private fun LocalAccountExplanation() { Text( @@ -391,7 +394,7 @@ private fun LoginButton( textColor: Color, backgroundGradient: Gradient, hasShadow: Boolean, - onClick: () -> Unit + onClick: () -> Unit, ) { Row( modifier = Modifier @@ -429,13 +432,22 @@ private fun LoginButton( } } -@Preview +@IvyPreviews @Composable -private fun Preview() { - IvyWalletPreview { +private fun OnboardingSplashLoginPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { OnboardingSplashLogin( onboardingState = OnboardingState.SPLASH, onSkip = {} ) } } + +@Composable +fun OnboardingSplashLoginUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + OnboardingSplashLoginPreview(theme) +} diff --git a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingType.kt b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingType.kt index 542d69d105..6788147386 100644 --- a/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingType.kt +++ b/screen/onboarding/src/main/java/com/ivy/onboarding/steps/OnboardingType.kt @@ -18,14 +18,15 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.legacy.IvyWalletPreview import com.ivy.navigation.navigation import com.ivy.onboarding.components.OnboardingProgressSlider import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.GradientIvy import com.ivy.wallet.ui.theme.Gray import com.ivy.wallet.ui.theme.Green @@ -134,13 +135,22 @@ fun OnboardingType( } } -@Preview +@IvyPreviews @Composable -private fun Preview() { - IvyWalletPreview { +private fun OnboardingImportCSVFile(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { OnboardingType( onStartImport = {} ) { } } } + +@Composable +fun OnboardingImportCSVFileUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + OnboardingImportCSVFile(theme) +} \ No newline at end of file diff --git a/screen/onboarding/src/screenshotTestDebug/kotlin/OnboardingScreenPreviewTest.kt b/screen/onboarding/src/screenshotTestDebug/kotlin/OnboardingScreenPreviewTest.kt new file mode 100644 index 0000000000..bfac4f26ef --- /dev/null +++ b/screen/onboarding/src/screenshotTestDebug/kotlin/OnboardingScreenPreviewTest.kt @@ -0,0 +1,93 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.onboarding.steps.OnboardingAccountUiTest +import com.ivy.onboarding.steps.OnboardingCategoriesUiTest +import com.ivy.onboarding.steps.OnboardingImportCSVFileUiTest +import com.ivy.onboarding.steps.OnboardingSetCurrencyUiTest +import com.ivy.onboarding.steps.OnboardingSplashLoginUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewOnboardingAccountsLight() { + OnboardingAccountUiTest(isDark = false, false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingAccountsDark() { + OnboardingAccountUiTest(isDark = true, false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingAccountsLightEmptyState() { + OnboardingAccountUiTest(isDark = false, true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingAccountsDarkEmptyState() { + OnboardingAccountUiTest(isDark = true, true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingCategoriesLight() { + OnboardingCategoriesUiTest(isDark = false, false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingCategoriesDark() { + OnboardingCategoriesUiTest(isDark = true, false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingCategoriesLightEmptyState() { + OnboardingCategoriesUiTest(isDark = false, true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingCategoriesDarkEmptyState() { + OnboardingCategoriesUiTest(isDark = true, true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingSetCurrencyLight() { + OnboardingSetCurrencyUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingSetCurrencyDark() { + OnboardingSetCurrencyUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingSplashLoginLight() { + OnboardingSplashLoginUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingSplashLoginDark() { + OnboardingSplashLoginUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingImportCSVFileLight() { + OnboardingImportCSVFileUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewOnboardingImportCSVFileDark() { + OnboardingImportCSVFileUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/piechart/build.gradle.kts b/screen/piechart/build.gradle.kts index 895d4c81ba..8e4abf6900 100644 --- a/screen/piechart/build.gradle.kts +++ b/screen/piechart/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.piechart" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_da39a3ee_da39a3ee_0.png b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..a6bd18ecfb Binary files /dev/null and b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..534b0e7b55 Binary files /dev/null and b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_da39a3ee_da39a3ee_0.png b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..dd79b9bdbd Binary files /dev/null and b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..8778f7268f Binary files /dev/null and b/screen/piechart/src/debug/screenshotTest/reference/PieChartStatisticsScreenPreviewTestKt/PreviewPieChartStatisticsScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/piechart/src/main/java/com/ivy/piechart/PieChartStatisticScreen.kt b/screen/piechart/src/main/java/com/ivy/piechart/PieChartStatisticScreen.kt index 02fe62665e..8c0cae4705 100644 --- a/screen/piechart/src/main/java/com/ivy/piechart/PieChartStatisticScreen.kt +++ b/screen/piechart/src/main/java/com/ivy/piechart/PieChartStatisticScreen.kt @@ -37,6 +37,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import com.ivy.base.legacy.Theme import com.ivy.base.model.TransactionType import com.ivy.data.model.Category import com.ivy.data.model.CategoryId @@ -49,6 +50,8 @@ import com.ivy.design.api.LocalTimeProvider import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.design.utils.thenIf +import com.ivy.legacy.IvyWalletPreview +import com.ivy.legacy.data.model.TimePeriod import com.ivy.legacy.ivyWalletCtx import com.ivy.legacy.utils.drawColoredShadow import com.ivy.legacy.utils.format @@ -60,6 +63,7 @@ import com.ivy.navigation.TransactionsScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.ui.theme.GradientGreen import com.ivy.wallet.ui.theme.Gray @@ -89,7 +93,7 @@ import java.util.UUID @ExperimentalFoundationApi @Composable fun BoxWithConstraintsScope.PieChartStatisticScreen( - screen: PieChartStatisticScreen + screen: PieChartStatisticScreen, ) { val viewModel: PieChartStatisticViewModel = screenScopedViewModel() val uiState = viewModel.uiState() @@ -108,7 +112,7 @@ fun BoxWithConstraintsScope.PieChartStatisticScreen( @Composable private fun BoxWithConstraintsScope.UI( state: PieChartStatisticState, - onEvent: (PieChartStatisticEvent) -> Unit = {} + onEvent: (PieChartStatisticEvent) -> Unit = {}, ) { val nav = navigation() val lazyState = rememberScrollPositionListState( @@ -258,7 +262,7 @@ private fun Header( onClose: () -> Unit, onAdd: (TransactionType) -> Unit, - showCloseButtonOnly: Boolean = false + showCloseButtonOnly: Boolean = false, ) { Row( modifier = Modifier @@ -353,7 +357,7 @@ private fun CategoryAmountCard( selectedCategory: SelectedCategory?, - onClick: () -> Unit + onClick: () -> Unit, ) { val category = categoryAmount.category val amount = categoryAmount.amount @@ -459,7 +463,7 @@ private fun PercentText( amount: Double, totalAmount: Double, selectedState: Boolean, - contrastColor: Color + contrastColor: Color, ) { Text( text = if (totalAmount != 0.0) { @@ -566,13 +570,13 @@ private fun Preview_Expense() { } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview_Income() { - com.ivy.legacy.IvyWalletPreview { +private fun PieChartExpensePreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { val state = PieChartStatisticState( - transactionType = TransactionType.INCOME, - period = com.ivy.legacy.data.model.TimePeriod.currentMonth( + transactionType = TransactionType.EXPENSE, + period = TimePeriod.currentMonth( startDayOfMonth = 1 ), // preview baseCurrency = "BGN", @@ -655,3 +659,14 @@ private fun Preview_Income() { UI(state = state) } } + +/** For screenshot testing */ +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun PieChartStatisticScreenUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + PieChartExpensePreview(theme) +} diff --git a/screen/piechart/src/screenshotTestDebug/kotlin/PieChartStatisticsScreenPreviewTest.kt b/screen/piechart/src/screenshotTestDebug/kotlin/PieChartStatisticsScreenPreviewTest.kt new file mode 100644 index 0000000000..2ac499fb26 --- /dev/null +++ b/screen/piechart/src/screenshotTestDebug/kotlin/PieChartStatisticsScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.piechart.PieChartStatisticScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewPieChartStatisticsScreenLight() { + PieChartStatisticScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewPieChartStatisticsScreenDark() { + PieChartStatisticScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/planned-payments/build.gradle.kts b/screen/planned-payments/build.gradle.kts index 4f5eeed3c5..9f2c2bd995 100644 --- a/screen/planned-payments/build.gradle.kts +++ b/screen/planned-payments/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.planned" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_da39a3ee_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..8412526b50 Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..61041f222b Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_da39a3ee_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..87c05ce9b5 Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..bf351ed3fe Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewEditPlannedScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_da39a3ee_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..7f434c818a Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..4ae1ea770d Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_da39a3ee_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..2ad9e5f108 Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..750c577955 Binary files /dev/null and b/screen/planned-payments/src/debug/screenshotTest/reference/PlannedPaymentsPreviewTestKt/PreviewPlannedPaymentScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt b/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt index 8ffe95c7b0..560a58f824 100644 --- a/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt +++ b/screen/planned-payments/src/main/java/com/ivy/planned/edit/EditPlannedScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.base.model.TransactionType import com.ivy.data.model.Category import com.ivy.data.model.IntervalType @@ -35,6 +36,7 @@ import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R import com.ivy.wallet.ui.edit.core.Category import com.ivy.legacy.ui.component.edit.core.Description +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.edit.core.EditBottomSheet import com.ivy.wallet.ui.edit.core.Title import com.ivy.wallet.ui.edit.core.Toolbar @@ -422,10 +424,10 @@ private fun shouldFocusRecurring( private fun shouldFocusAmount(amount: Double) = amount == 0.0 @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview() { - IvyWalletPreview { +private fun EditPlannedScreenPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { UI( screen = EditPlannedScreen(null, TransactionType.EXPENSE), EditPlannedScreenState( @@ -454,3 +456,14 @@ private fun Preview() { ) {} } } + +/** For screenshot testing */ +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun EditPlannedScreenUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + EditPlannedScreenPreview(theme) +} diff --git a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt index f5c24234a3..9646f667da 100644 --- a/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt +++ b/screen/planned-payments/src/main/java/com/ivy/planned/list/PlannedPaymentsScreen.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.ivy.base.legacy.Theme import com.ivy.base.model.TransactionType import com.ivy.data.model.Category import com.ivy.data.model.CategoryId @@ -30,10 +31,12 @@ import com.ivy.navigation.PlannedPaymentsScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.ui.theme.Green import com.ivy.wallet.ui.theme.Orange import kotlinx.collections.immutable.persistentListOf +import java.time.Instant import java.time.ZoneOffset import java.util.UUID @@ -104,10 +107,10 @@ private fun BoxWithConstraintsScope.UI( ) } -@Preview +@IvyPreviews @Composable -private fun Preview() { - IvyWalletPreview { +private fun PlannedPaymentsScreenPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { val account = Account(name = "Cash", Green.toArgb()) val food = Category( name = NotBlankTrimmedString.unsafe("Food"), @@ -135,7 +138,7 @@ private fun Preview() { title = "Lidl pazar", categoryId = food.id.value, amount = 250.75, - startDate = timeNowUTC().plusDays(5).toInstant(ZoneOffset.UTC), + startDate = Instant.now(), oneTime = true, intervalType = null, intervalN = null, @@ -150,7 +153,7 @@ private fun Preview() { title = "Tabu", categoryId = shisha.id.value, amount = 1025.5, - startDate = timeNowUTC().plusDays(5).toInstant(ZoneOffset.UTC), + startDate = Instant.now(), oneTime = false, intervalType = IntervalType.MONTH, intervalN = 1, @@ -165,3 +168,13 @@ private fun Preview() { ) } } + +/** For screenshot testing */ +@Composable +fun PlannedPaymentScreenUiTest(isDark: Boolean) { + val theme = when (isDark) { + true -> Theme.DARK + false -> Theme.LIGHT + } + PlannedPaymentsScreenPreview(theme) +} diff --git a/screen/planned-payments/src/screenshotTestDebug/kotlin/PlannedPaymentsPreviewTest.kt b/screen/planned-payments/src/screenshotTestDebug/kotlin/PlannedPaymentsPreviewTest.kt new file mode 100644 index 0000000000..3d26ddb268 --- /dev/null +++ b/screen/planned-payments/src/screenshotTestDebug/kotlin/PlannedPaymentsPreviewTest.kt @@ -0,0 +1,30 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.planned.edit.EditPlannedScreenUiTest +import com.ivy.planned.list.PlannedPaymentScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewEditPlannedScreenLight() { + EditPlannedScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewEditPlannedScreenDark() { + EditPlannedScreenUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewPlannedPaymentScreenLight() { + PlannedPaymentScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewPlannedPaymentScreenDark() { + PlannedPaymentScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/releases/build.gradle.kts b/screen/releases/build.gradle.kts index 9c69718f29..c8472c2bcd 100644 --- a/screen/releases/build.gradle.kts +++ b/screen/releases/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.releases" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_da39a3ee_da39a3ee_0.png b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..b8770dfcf9 Binary files /dev/null and b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..03b9e26a2a Binary files /dev/null and b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_da39a3ee_da39a3ee_0.png b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..664766f02b Binary files /dev/null and b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..d8670dc1d6 Binary files /dev/null and b/screen/releases/src/debug/screenshotTest/reference/ReleasesScreenPreviewTestKt/PreviewReleasesScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/releases/src/main/java/com/ivy/releases/ReleasesScreen.kt b/screen/releases/src/main/java/com/ivy/releases/ReleasesScreen.kt index e6af5971be..4918310f2e 100644 --- a/screen/releases/src/main/java/com/ivy/releases/ReleasesScreen.kt +++ b/screen/releases/src/main/java/com/ivy/releases/ReleasesScreen.kt @@ -32,8 +32,11 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.ivy.navigation.IvyPreview import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews +import kotlinx.collections.immutable.persistentListOf @Composable fun ReleasesScreenImpl() { @@ -52,7 +55,7 @@ fun ReleasesScreenImpl() { @Composable private fun ReleasesUi( uiState: ReleasesState, - onEvent: (ReleasesEvent) -> Unit + onEvent: (ReleasesEvent) -> Unit, ) { val browser = LocalUriHandler.current Scaffold( @@ -110,7 +113,7 @@ private fun BackButton() { private fun LazyListScope.content( releasesState: ReleasesState, - onEvent: (ReleasesEvent) -> Unit + onEvent: (ReleasesEvent) -> Unit, ) { when (releasesState) { is ReleasesState.Error -> { @@ -142,7 +145,7 @@ private fun LazyListScope.content( @Composable private fun ReleaseInfoCard( releaseInfo: ReleaseInfo, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { val browser = LocalUriHandler.current @@ -169,7 +172,7 @@ private fun ReleaseInfoCard( @Composable private fun ReleaseInfoRow( releaseInfo: ReleaseInfo, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Row( modifier = modifier, @@ -184,7 +187,7 @@ private fun ReleaseInfoRow( @Composable private fun ReleaseName( info: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Text( modifier = modifier, @@ -198,7 +201,7 @@ private fun ReleaseName( @Composable private fun ReleaseDate( info: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Text( modifier = modifier, @@ -212,7 +215,7 @@ private fun ReleaseDate( private fun ReleasesErrorState( message: String, modifier: Modifier = Modifier, - onClick: () -> Unit + onClick: () -> Unit, ) { Column( modifier = modifier.fillMaxSize(), @@ -235,7 +238,7 @@ private fun ReleasesErrorState( @Composable private fun GitHubButton( modifier: Modifier = Modifier, - onClick: () -> Unit + onClick: () -> Unit, ) { FloatingActionButton( modifier = modifier, @@ -249,3 +252,64 @@ private fun GitHubButton( ) } } + +@IvyPreviews +@Composable +private fun ReleaseScreenPreview(isDark: Boolean = false) { + val state = ReleasesState.Success( + releasesInfo = persistentListOf( + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ), + ReleaseInfo( + releaseName = "Release Name", + releaseCommits = persistentListOf("Commit A", "Commit B", "Commit C"), + releaseUrl = "", + releaseDate = "12/07/2024" + ) + ) + ) + IvyPreview(isDark) { + ReleasesUi( + uiState = state + ) {} + } +} + +@Composable +fun ReleaseScreenUiTest(isDark: Boolean) { + ReleaseScreenPreview(isDark) +} diff --git a/screen/releases/src/screenshotTestDebug/kotlin/ReleasesScreenPreviewTest.kt b/screen/releases/src/screenshotTestDebug/kotlin/ReleasesScreenPreviewTest.kt new file mode 100644 index 0000000000..01c4445763 --- /dev/null +++ b/screen/releases/src/screenshotTestDebug/kotlin/ReleasesScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.releases.ReleaseScreenUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewReleasesScreenLight() { + ReleaseScreenUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewReleasesScreenDark() { + ReleaseScreenUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/releases/src/test/java/com/ivy/releases/ReleasesContentParserTest.kt b/screen/releases/src/test/java/com/ivy/releases/ReleasesContentParserTest.kt deleted file mode 100644 index a8f39e12dc..0000000000 --- a/screen/releases/src/test/java/com/ivy/releases/ReleasesContentParserTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -package com.ivy.releases - -import io.kotest.matchers.shouldBe -import kotlinx.collections.immutable.persistentListOf -import org.junit.Before -import org.junit.Test - -class ReleasesContentParserTest { - - private lateinit var releasesContentParser: ReleasesContentParser - - @Before - fun setup() { - releasesContentParser = ReleasesContentParser() - } - - @Test - fun `toCommitsList - with null commits input`() { - releasesContentParser.toCommitsList(null) shouldBe persistentListOf() - } - - @Test - fun `toCommitsList - with blank commits input`() { - releasesContentParser.toCommitsList("") shouldBe persistentListOf() - } - - @Test - fun `toCommitsList - with 4 commits input`() { - // given - val commits = "- c9a985eb Add `GitHubWorkerMigration` and bump version to \"4.4.2\" " + - "(142)\n - e6e001e8 Update dev-request.yml\n - 2d397ca1 Update bug_report.yml\n " + - "- 2c386031 Update and rename dev-contributor-request.yml to dev-request.yml" - - // when - val res = releasesContentParser.toCommitsList(commits) - - // then - res shouldBe persistentListOf( - "c9a985eb Add `GitHubWorkerMigration` and bump version to \"4.4.2\" (142)", - "e6e001e8 Update dev-request.yml", - "2d397ca1 Update bug_report.yml", - "2c386031 Update and rename dev-contributor-request.yml to dev-request.yml" - ) - } - - @Test - fun `toReleaseDate - formats the date`() { - // given - val date = "2023-09-16T17:42:08Z" - - // when - val dateFormatted = releasesContentParser.toReleaseDate(date) - - // then - dateFormatted shouldBe "2023-09-16" - } -} diff --git a/screen/reports/build.gradle.kts b/screen/reports/build.gradle.kts index 968802e7c4..805030aa9c 100644 --- a/screen/reports/build.gradle.kts +++ b/screen/reports/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.reports" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_da39a3ee_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..b4739145da Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..38c1cf019b Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_da39a3ee_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..9fcd34614f Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..2e48a80348 Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportNoFilterUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_da39a3ee_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..09fc1a49f7 Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..20c11eefa6 Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_da39a3ee_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..4084511631 Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..d65c59c384 Binary files /dev/null and b/screen/reports/src/debug/screenshotTest/reference/ReportScreenPreviewTestKt/PreviewReportUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt b/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt index 43aa4ae264..de6ca9f249 100644 --- a/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt +++ b/screen/reports/src/main/java/com/ivy/reports/ReportScreen.kt @@ -22,7 +22,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import androidx.lifecycle.viewmodel.compose.viewModel @@ -49,6 +48,7 @@ import com.ivy.navigation.PieChartStatisticScreen import com.ivy.navigation.ReportScreen import com.ivy.navigation.navigation import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.domain.pure.data.IncomeExpensePair import com.ivy.wallet.ui.theme.Gray @@ -75,7 +75,7 @@ import java.util.UUID @ExperimentalFoundationApi @Composable fun BoxWithConstraintsScope.ReportScreen( - screen: ReportScreen + screen: ReportScreen, ) { val viewModel: ReportViewModel = viewModel() val state = viewModel.uiState() @@ -90,7 +90,7 @@ fun BoxWithConstraintsScope.ReportScreen( @Composable private fun BoxWithConstraintsScope.UI( state: ReportScreenState = ReportScreenState(), - onEventHandler: (ReportScreenEvent) -> Unit = {} + onEventHandler: (ReportScreenEvent) -> Unit = {}, ) { val legacyTransactions = state.transactions val nav = navigation() @@ -312,7 +312,7 @@ private fun BoxWithConstraintsScope.UI( @Composable private fun NoFilterEmptyState( - setFilterOverlayVisible: (Boolean) -> Unit + setFilterOverlayVisible: (Boolean) -> Unit, ) { Column( modifier = Modifier.fillMaxWidth(), @@ -363,7 +363,7 @@ private fun NoFilterEmptyState( @Composable private fun Toolbar( onExport: () -> Unit, - onFilter: () -> Unit + onFilter: () -> Unit, ) { val nav = navigation() IvyToolbar( @@ -400,7 +400,7 @@ private fun Toolbar( } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable private fun Preview(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { @@ -461,7 +461,7 @@ private fun Preview(theme: Theme = Theme.LIGHT) { } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable private fun Preview_NO_FILTER(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { diff --git a/screen/reports/src/screenshotTestDebug/kotlin/ReportScreenPreviewTest.kt b/screen/reports/src/screenshotTestDebug/kotlin/ReportScreenPreviewTest.kt new file mode 100644 index 0000000000..e38c2cde00 --- /dev/null +++ b/screen/reports/src/screenshotTestDebug/kotlin/ReportScreenPreviewTest.kt @@ -0,0 +1,30 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.reports.ReportNoFilterUiTest +import com.ivy.reports.ReportUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewReportUiScreenLight() { + ReportUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewReportUiScreenDark() { + ReportUiTest(isDark = true) +} + +@IvyPreviews +@Composable +private fun PreviewReportNoFilterUiScreenLight() { + ReportNoFilterUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewReportNoFilterUiScreenDark() { + ReportNoFilterUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/reports/src/test/java/com/ivy/report/ReportPaparazziTest.kt b/screen/reports/src/test/java/com/ivy/report/ReportPaparazziTest.kt deleted file mode 100644 index e1d0428dfe..0000000000 --- a/screen/reports/src/test/java/com/ivy/report/ReportPaparazziTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.ivy.report - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.reports.ReportNoFilterUiTest -import com.ivy.reports.ReportUiTest -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class ReportPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Report Screen`() { - snapshot(theme) { - ReportUiTest(theme == PaparazziTheme.Dark) - } - } - - @Test - fun `snapshot Report Screen no filter`() { - snapshot(theme) { - ReportNoFilterUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Dark].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Dark].png deleted file mode 100644 index 1e8097f0fa..0000000000 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Dark].png and /dev/null differ diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Light].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Light].png deleted file mode 100644 index f613991216..0000000000 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen no filter[Light].png and /dev/null differ diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png deleted file mode 100644 index 284c34c880..0000000000 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Dark].png and /dev/null differ diff --git a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png b/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png deleted file mode 100644 index 1988435d01..0000000000 Binary files a/screen/reports/src/test/snapshots/images/com.ivy.report_ReportPaparazziTest_snapshot Report Screen[Light].png and /dev/null differ diff --git a/screen/search/build.gradle.kts b/screen/search/build.gradle.kts index 1cb1a517a7..383aa3c2ef 100644 --- a/screen/search/build.gradle.kts +++ b/screen/search/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.search" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_da39a3ee_da39a3ee_0.png b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..187b900c5c Binary files /dev/null and b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..75722b5637 Binary files /dev/null and b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_da39a3ee_da39a3ee_0.png b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..8ad2940773 Binary files /dev/null and b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..465df003e6 Binary files /dev/null and b/screen/search/src/debug/screenshotTest/reference/SearchScreenPreviewTestKt/PreviewSearchUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/search/src/main/java/com/ivy/search/SearchScreen.kt b/screen/search/src/main/java/com/ivy/search/SearchScreen.kt index b488b54a7b..ce264ac3f2 100644 --- a/screen/search/src/main/java/com/ivy/search/SearchScreen.kt +++ b/screen/search/src/main/java/com/ivy/search/SearchScreen.kt @@ -2,7 +2,6 @@ package com.ivy.search import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.tween -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -18,10 +17,9 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.ivy.base.legacy.Theme -import com.ivy.design.utils.IvyComponentPreview +import com.ivy.legacy.IvyWalletPreview import com.ivy.legacy.data.AppBaseData import com.ivy.legacy.ui.SearchInput import com.ivy.legacy.ui.component.transaction.transactions @@ -29,10 +27,10 @@ import com.ivy.legacy.utils.densityScope import com.ivy.legacy.utils.keyboardOnlyWindowInsets import com.ivy.legacy.utils.keyboardVisibleState import com.ivy.legacy.utils.selectEndTextFieldValue -import com.ivy.navigation.IvyPreview import com.ivy.navigation.SearchScreen import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.ui.theme.modal.DURATION_MODAL_ANIM import kotlinx.collections.immutable.persistentListOf @@ -50,7 +48,7 @@ fun SearchScreen(screen: SearchScreen) { @Composable private fun SearchUi( uiState: SearchState, - onEvent: (SearchEvent) -> Unit + onEvent: (SearchEvent) -> Unit, ) { Column( modifier = Modifier @@ -123,10 +121,10 @@ private fun SearchUi( } } -@Preview +@IvyPreviews @Composable -private fun Preview(isDark: Boolean = false) { - IvyPreview(isDark) { +private fun SearchScreenPreview(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { SearchUi( uiState = SearchState( searchQuery = "Transaction", @@ -141,11 +139,8 @@ private fun Preview(isDark: Boolean = false) { } /** For screenshot testing */ -@OptIn(ExperimentalFoundationApi::class) @Composable fun SearchUiTest(isDark: Boolean) { val theme = if (isDark) Theme.DARK else Theme.LIGHT - IvyComponentPreview(theme = theme) { - Preview(isDark) - } + SearchScreenPreview(theme) } \ No newline at end of file diff --git a/screen/search/src/screenshotTestDebug/kotlin/SearchScreenPreviewTest.kt b/screen/search/src/screenshotTestDebug/kotlin/SearchScreenPreviewTest.kt new file mode 100644 index 0000000000..245792ed31 --- /dev/null +++ b/screen/search/src/screenshotTestDebug/kotlin/SearchScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.search.SearchUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewSearchUiScreenLight() { + SearchUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewSearchUiScreenDark() { + SearchUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/search/src/test/java/com/ivy/search/SearchPaparazziTest.kt b/screen/search/src/test/java/com/ivy/search/SearchPaparazziTest.kt deleted file mode 100644 index 58d5880b77..0000000000 --- a/screen/search/src/test/java/com/ivy/search/SearchPaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.search - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class SearchPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Search Screen`() { - snapshot(theme) { - SearchUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Dark].png b/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Dark].png deleted file mode 100644 index b5ab3e3646..0000000000 Binary files a/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Dark].png and /dev/null differ diff --git a/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Light].png b/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Light].png deleted file mode 100644 index b5ab3e3646..0000000000 Binary files a/screen/search/src/test/snapshots/images/com.ivy.search_SearchPaparazziTest_snapshot Search Screen[Light].png and /dev/null differ diff --git a/screen/settings/build.gradle.kts b/screen/settings/build.gradle.kts index 16e18b35b1..e715030ab5 100644 --- a/screen/settings/build.gradle.kts +++ b/screen/settings/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.settings" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_da39a3ee_da39a3ee_0.png b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..bd01926438 Binary files /dev/null and b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..6817c76e4f Binary files /dev/null and b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_da39a3ee_da39a3ee_0.png b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..656bfda1fc Binary files /dev/null and b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..de86347171 Binary files /dev/null and b/screen/settings/src/debug/screenshotTest/reference/SettingsScreenPreviewTestKt/PreviewSettingsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/settings/src/main/java/com/ivy/settings/SettingsScreen.kt b/screen/settings/src/main/java/com/ivy/settings/SettingsScreen.kt index 745152a4fb..f4c509ce63 100644 --- a/screen/settings/src/main/java/com/ivy/settings/SettingsScreen.kt +++ b/screen/settings/src/main/java/com/ivy/settings/SettingsScreen.kt @@ -57,6 +57,7 @@ import com.ivy.navigation.ReleasesScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.wallet.domain.data.IvyCurrency import com.ivy.wallet.ui.theme.Blue import com.ivy.wallet.ui.theme.Gradient @@ -1168,16 +1169,22 @@ private fun SettingsDefaultButton( } @ExperimentalFoundationApi -@Preview +@IvyPreviews @Composable -private fun Preview(theme: Theme = Theme.LIGHT) { +private fun SettingsScreenPreview(theme: Theme = Theme.LIGHT) { IvyWalletPreview(theme) { UI( - nameLocalAccount = null, - theme = Theme.AUTO, + currencyCode = "USD", + theme = theme, onSwitchTheme = {}, lockApp = false, - currencyCode = "BGN", + nameLocalAccount = "Ivy", + startDateOfMonth = 1, + showNotifications = true, + hideCurrentBalance = false, + hideIncome = false, + progressState = false, + treatTransfersAsIncomeExpense = false, onSetCurrency = {}, languageOptionVisible = true ) @@ -1192,5 +1199,5 @@ fun SettingsUiTest(isDark: Boolean) { true -> Theme.DARK false -> Theme.LIGHT } - Preview(theme) + SettingsScreenPreview(theme) } \ No newline at end of file diff --git a/screen/settings/src/screenshotTestDebug/kotlin/SettingsScreenPreviewTest.kt b/screen/settings/src/screenshotTestDebug/kotlin/SettingsScreenPreviewTest.kt new file mode 100644 index 0000000000..2f4509a34d --- /dev/null +++ b/screen/settings/src/screenshotTestDebug/kotlin/SettingsScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.settings.SettingsUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewSettingsUiScreenLight() { + SettingsUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewSettingsUiScreenDark() { + SettingsUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/transactions/build.gradle.kts b/screen/transactions/build.gradle.kts index f2e2e5793e..6a1a84c786 100644 --- a/screen/transactions/build.gradle.kts +++ b/screen/transactions/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.transactions" + testOptions { + screenshotTests { + imageDifferenceThreshold = BuildConfigConstants.IMAGE_DIFFERENCE_THRESHOLD + } + } } dependencies { diff --git a/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_da39a3ee_da39a3ee_0.png b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..80d890ba92 Binary files /dev/null and b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_da39a3ee_da39a3ee_0.png differ diff --git a/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..0b93c1010b Binary files /dev/null and b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenDark_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_da39a3ee_da39a3ee_0.png b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..ea76b2085c Binary files /dev/null and b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_da39a3ee_da39a3ee_0.png differ diff --git a/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..7bebf20e2a Binary files /dev/null and b/screen/transactions/src/debug/screenshotTest/reference/TransactionsScreenPreviewTestKt/PreviewTransactionsUiScreenLight_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt b/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt index 22c50a20e4..26ac1e9922 100644 --- a/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt +++ b/screen/transactions/src/main/java/com/ivy/transactions/TransactionsScreen.kt @@ -32,7 +32,6 @@ import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.ivy.base.legacy.Theme import com.ivy.base.legacy.Transaction @@ -43,6 +42,9 @@ import com.ivy.data.model.Category import com.ivy.design.api.LocalTimeConverter import com.ivy.design.api.LocalTimeFormatter import com.ivy.design.api.LocalTimeProvider +import com.ivy.design.l0_system.Blue2Light +import com.ivy.design.l0_system.Blue3Light +import com.ivy.design.l0_system.BlueLight import com.ivy.design.l0_system.UI import com.ivy.design.l0_system.style import com.ivy.design.utils.thenIf @@ -64,16 +66,15 @@ import com.ivy.legacy.utils.rememberInteractionSource import com.ivy.legacy.utils.rememberSwipeListenerState import com.ivy.legacy.utils.setStatusBarDarkTextCompat import com.ivy.navigation.EditTransactionScreen -import com.ivy.navigation.IvyPreview import com.ivy.navigation.PieChartStatisticScreen import com.ivy.navigation.TransactionsScreen import com.ivy.navigation.navigation import com.ivy.navigation.screenScopedViewModel import com.ivy.ui.R +import com.ivy.ui.annotation.IvyPreviews import com.ivy.ui.rememberScrollPositionListState import com.ivy.wallet.domain.pure.data.IncomeExpensePair import com.ivy.wallet.ui.theme.Gray -import com.ivy.wallet.ui.theme.GreenDark import com.ivy.wallet.ui.theme.components.BalanceRow import com.ivy.wallet.ui.theme.components.BalanceRowMedium import com.ivy.wallet.ui.theme.components.ItemIconMDefaultIcon @@ -819,10 +820,11 @@ private fun Item( } } -@Preview +@Suppress("UnusedPrivateMember") +@IvyPreviews @Composable -private fun BoxWithConstraintsScope.Preview_empty() { - IvyPreview { +private fun Preview_empty() { + IvyWalletPreview { UI( period = TimePeriod.currentMonth( startDayOfMonth = 1 @@ -840,7 +842,7 @@ private fun BoxWithConstraintsScope.Preview_empty() { history = persistentListOf(), category = null, - account = Account("DSK", color = GreenDark.toArgb(), icon = "pet"), + account = Account("Ivy", color = BlueLight.toArgb(), icon = "pet"), onSetPeriod = { }, onPreviousMonth = {}, onNextMonth = {}, @@ -860,10 +862,11 @@ private fun BoxWithConstraintsScope.Preview_empty() { } } -@Preview +@Suppress("UnusedPrivateMember") +@IvyPreviews @Composable -private fun BoxWithConstraintsScope.Preview_crypto() { - IvyPreview { +private fun Preview_crypto() { + IvyWalletPreview { UI( period = TimePeriod.currentMonth( startDayOfMonth = 1 @@ -882,8 +885,8 @@ private fun BoxWithConstraintsScope.Preview_crypto() { history = persistentListOf(), category = null, account = Account( - name = "DSK", - color = GreenDark.toArgb(), + name = "Ivy", + color = Blue3Light.toArgb(), icon = "pet", includeInBalance = false ), @@ -906,10 +909,10 @@ private fun BoxWithConstraintsScope.Preview_crypto() { } } -@Preview +@IvyPreviews @Composable -private fun BoxWithConstraintsScope.Preview_empty_upcoming() { - IvyPreview { +private fun TransactionScreenUpcoming(theme: Theme = Theme.LIGHT) { + IvyWalletPreview(theme) { UI( period = TimePeriod(month = Month.monthsList().first(), year = 2023), baseCurrency = "BGN", @@ -925,7 +928,7 @@ private fun BoxWithConstraintsScope.Preview_empty_upcoming() { history = persistentListOf(), category = null, - account = Account("DSK", color = GreenDark.toArgb(), icon = "pet"), + account = Account("Ivy", color = Blue2Light.toArgb(), icon = "pet"), onSetPeriod = { }, onPreviousMonth = {}, onNextMonth = {}, @@ -953,14 +956,11 @@ private fun BoxWithConstraintsScope.Preview_empty_upcoming() { } /** For screenshot testing */ -@OptIn(ExperimentalFoundationApi::class) @Composable fun TransactionsUiTest(isDark: Boolean) { val theme = when (isDark) { true -> Theme.DARK false -> Theme.LIGHT } - IvyWalletPreview(theme) { - Preview_empty_upcoming() - } + TransactionScreenUpcoming(theme) } \ No newline at end of file diff --git a/screen/transactions/src/screenshotTestDebug/kotlin/TransactionsScreenPreviewTest.kt b/screen/transactions/src/screenshotTestDebug/kotlin/TransactionsScreenPreviewTest.kt new file mode 100644 index 0000000000..62ede73332 --- /dev/null +++ b/screen/transactions/src/screenshotTestDebug/kotlin/TransactionsScreenPreviewTest.kt @@ -0,0 +1,17 @@ +@file:Suppress("UnusedPrivateMember") + +import androidx.compose.runtime.Composable +import com.ivy.transactions.TransactionsUiTest +import com.ivy.ui.annotation.IvyPreviews + +@IvyPreviews +@Composable +private fun PreviewTransactionsUiScreenLight() { + TransactionsUiTest(isDark = false) +} + +@IvyPreviews +@Composable +private fun PreviewTransactionsUiScreenDark() { + TransactionsUiTest(isDark = true) +} \ No newline at end of file diff --git a/screen/transactions/src/test/java/com/ivy/transactions/TransactionsPaparazziTest.kt b/screen/transactions/src/test/java/com/ivy/transactions/TransactionsPaparazziTest.kt deleted file mode 100644 index cd4cdec0db..0000000000 --- a/screen/transactions/src/test/java/com/ivy/transactions/TransactionsPaparazziTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ivy.transactions - -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import com.ivy.ui.testing.PaparazziScreenshotTest -import com.ivy.ui.testing.PaparazziTheme -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class TransactionsPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot Transactions Screen`() { - snapshot(theme) { - TransactionsUiTest(theme == PaparazziTheme.Dark) - } - } -} \ No newline at end of file diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png deleted file mode 100644 index ae3ef6f7ad..0000000000 Binary files a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Dark].png and /dev/null differ diff --git a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png b/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png deleted file mode 100644 index 8583486f76..0000000000 Binary files a/screen/transactions/src/test/snapshots/images/com.ivy.transactions_TransactionsPaparazziTest_snapshot Transactions Screen[Light].png and /dev/null differ diff --git a/scripts/paparazziScreenshotTests.sh b/scripts/paparazziScreenshotTests.sh index 1d8c312ed2..cebb85e280 100755 --- a/scripts/paparazziScreenshotTests.sh +++ b/scripts/paparazziScreenshotTests.sh @@ -11,4 +11,4 @@ if [ ! -f "settings.gradle.kts" ]; then exit 1 fi -./gradlew verifyPaparazziDebug || exit 1 \ No newline at end of file +./gradlew validateDebugScreenshotTest || exit 1 \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 45f2be52eb..41edffe811 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,12 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +pluginManagement { + repositories { + google() + gradlePluginPortal() + } +} + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { diff --git a/shared/ui/core/src/main/java/com/ivy/ui/annotation/IvyPreviews.kt b/shared/ui/core/src/main/java/com/ivy/ui/annotation/IvyPreviews.kt new file mode 100644 index 0000000000..692ba283a2 --- /dev/null +++ b/shared/ui/core/src/main/java/com/ivy/ui/annotation/IvyPreviews.kt @@ -0,0 +1,16 @@ +package com.ivy.ui.annotation + +import androidx.compose.ui.tooling.preview.Preview + +@Suppress("PreviewAnnotationNaming") +@Retention(AnnotationRetention.BINARY) +@Target( + AnnotationTarget.ANNOTATION_CLASS, + AnnotationTarget.FUNCTION +) +@Preview +@Preview( + name = "nexus_one", + device = "id:Nexus One", +) +annotation class IvyPreviews \ No newline at end of file diff --git a/shared/ui/core/src/main/res/drawable/home_more_menu_auto_mode.xml b/shared/ui/core/src/main/res/drawable/home_more_menu_auto_mode.xml index 885800ebb7..97e96f1809 100644 --- a/shared/ui/core/src/main/res/drawable/home_more_menu_auto_mode.xml +++ b/shared/ui/core/src/main/res/drawable/home_more_menu_auto_mode.xml @@ -2,9 +2,8 @@ android:width="24dp" android:height="24dp" android:viewportWidth="24" - android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + android:viewportHeight="24"> + android:pathData="M11,7l-3.2,9h1.9l0.7,-2h3.2l0.7,2h1.9L13,7h-2zM10.85,12.65L12,9l1.15,3.65h-2.3zM20,8.69L20,4h-4.69L12,0.69 8.69,4L4,4v4.69L0.69,12 4,15.31L4,20h4.69L12,23.31 15.31,20L20,20v-4.69L23.31,12 20,8.69zM18,14.48L18,18h-3.52L12,20.48 9.52,18L6,18v-3.52L3.52,12 6,9.52L6,6h3.52L12,3.52 14.48,6L18,6v3.52L20.48,12 18,14.48z" /> diff --git a/shared/ui/core/src/main/res/drawable/ic_attachment.xml b/shared/ui/core/src/main/res/drawable/ic_attachment.xml index 1bd4efedf3..ba3cee5dca 100644 --- a/shared/ui/core/src/main/res/drawable/ic_attachment.xml +++ b/shared/ui/core/src/main/res/drawable/ic_attachment.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_budget_s.xml b/shared/ui/core/src/main/res/drawable/ic_budget_s.xml index 3d9db3dd13..24af13cc38 100644 --- a/shared/ui/core/src/main/res/drawable/ic_budget_s.xml +++ b/shared/ui/core/src/main/res/drawable/ic_budget_s.xml @@ -1,5 +1,5 @@ + > diff --git a/shared/ui/core/src/main/res/drawable/ic_done.xml b/shared/ui/core/src/main/res/drawable/ic_done.xml index 5f2d19b028..22612dd5da 100644 --- a/shared/ui/core/src/main/res/drawable/ic_done.xml +++ b/shared/ui/core/src/main/res/drawable/ic_done.xml @@ -1,5 +1,5 @@ + > diff --git a/shared/ui/core/src/main/res/drawable/ic_expand_more.xml b/shared/ui/core/src/main/res/drawable/ic_expand_more.xml index 0261aa810f..f9447cab3b 100644 --- a/shared/ui/core/src/main/res/drawable/ic_expand_more.xml +++ b/shared/ui/core/src/main/res/drawable/ic_expand_more.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_file.xml b/shared/ui/core/src/main/res/drawable/ic_file.xml index 336ae68a1d..8d4400b5ee 100644 --- a/shared/ui/core/src/main/res/drawable/ic_file.xml +++ b/shared/ui/core/src/main/res/drawable/ic_file.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_filter_l.xml b/shared/ui/core/src/main/res/drawable/ic_filter_l.xml index cf1836de6d..720ced8815 100644 --- a/shared/ui/core/src/main/res/drawable/ic_filter_l.xml +++ b/shared/ui/core/src/main/res/drawable/ic_filter_l.xml @@ -1,5 +1,5 @@ + > diff --git a/shared/ui/core/src/main/res/drawable/ic_hamburger.xml b/shared/ui/core/src/main/res/drawable/ic_hamburger.xml index d541bc9b12..9096f7a526 100644 --- a/shared/ui/core/src/main/res/drawable/ic_hamburger.xml +++ b/shared/ui/core/src/main/res/drawable/ic_hamburger.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_hidden.xml b/shared/ui/core/src/main/res/drawable/ic_hidden.xml index 49d626eae2..1d85d42321 100644 --- a/shared/ui/core/src/main/res/drawable/ic_hidden.xml +++ b/shared/ui/core/src/main/res/drawable/ic_hidden.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_outline_clear_24.xml b/shared/ui/core/src/main/res/drawable/ic_outline_clear_24.xml index 4ebf4a04e2..056daffc69 100644 --- a/shared/ui/core/src/main/res/drawable/ic_outline_clear_24.xml +++ b/shared/ui/core/src/main/res/drawable/ic_outline_clear_24.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_refresh.xml b/shared/ui/core/src/main/res/drawable/ic_refresh.xml index f2be45bab5..12bd658b2f 100644 --- a/shared/ui/core/src/main/res/drawable/ic_refresh.xml +++ b/shared/ui/core/src/main/res/drawable/ic_refresh.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + > diff --git a/shared/ui/core/src/main/res/drawable/ic_statistics_s.xml b/shared/ui/core/src/main/res/drawable/ic_statistics_s.xml index 3de4113dff..55ea63b6c1 100644 --- a/shared/ui/core/src/main/res/drawable/ic_statistics_s.xml +++ b/shared/ui/core/src/main/res/drawable/ic_statistics_s.xml @@ -1,5 +1,5 @@ + > diff --git a/shared/ui/core/src/main/res/drawable/ic_telegram_24dp.xml b/shared/ui/core/src/main/res/drawable/ic_telegram_24dp.xml index 74e56900f8..e3376dc50a 100644 --- a/shared/ui/core/src/main/res/drawable/ic_telegram_24dp.xml +++ b/shared/ui/core/src/main/res/drawable/ic_telegram_24dp.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal" + android:autoMirrored="true"> + > diff --git a/shared/ui/testing/build.gradle.kts b/shared/ui/testing/build.gradle.kts index ac3f6aae16..2b3506070d 100644 --- a/shared/ui/testing/build.gradle.kts +++ b/shared/ui/testing/build.gradle.kts @@ -1,9 +1,15 @@ plugins { id("ivy.feature") + id("com.android.compose.screenshot") } android { namespace = "com.ivy.ui.testing" + testOptions { + screenshotTests { + imageDifferenceThreshold = 0.0001f + } + } } dependencies { @@ -12,5 +18,4 @@ dependencies { // for this module we need test deps as "implementation" and not only "testImplementation" // because it'll be added as "testImplementation" implementation(libs.bundles.testing) - implementation(libs.paparazzi) } diff --git a/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_da39a3ee_da39a3ee_0.png b/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_da39a3ee_da39a3ee_0.png new file mode 100644 index 0000000000..c4b8fc8f44 Binary files /dev/null and b/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_da39a3ee_da39a3ee_0.png differ diff --git a/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_nexus_one_c37ad86f_da39a3ee_0.png b/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_nexus_one_c37ad86f_da39a3ee_0.png new file mode 100644 index 0000000000..0a7293cd72 Binary files /dev/null and b/shared/ui/testing/src/debug/screenshotTest/reference/DemoComposeScreenshotTestingKt/DemoComposeScreenTesting_nexus_one_c37ad86f_da39a3ee_0.png differ diff --git a/shared/ui/testing/src/main/java/com/ivy/ui/testing/ComposeViewModelTest.kt b/shared/ui/testing/src/main/java/com/ivy/ui/testing/ComposeViewModelTest.kt deleted file mode 100644 index cae74b603f..0000000000 --- a/shared/ui/testing/src/main/java/com/ivy/ui/testing/ComposeViewModelTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.ivy.ui.testing - -import app.cash.molecule.RecompositionMode -import app.cash.molecule.moleculeFlow -import app.cash.paparazzi.Paparazzi -import app.cash.turbine.test -import com.ivy.ui.ComposeViewModel -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.resetMain -import kotlinx.coroutines.test.setMain -import org.junit.Rule - -open class ComposeViewModelTest { - @get:Rule - val paparazzi = Paparazzi() -} - -/** - * Runs a [ComposeViewModel] test simulation. - * Compose runtime effects are executed [RecompositionMode.Immediate]. - * @param events pass the events that have occurred in your simulation - * @param verify assert what's the expected state after all the events - */ -@OptIn(ExperimentalCoroutinesApi::class) -fun ComposeViewModel.runTest( - events: List = emptyList(), - verify: UiState.() -> Unit -) { - try { - Dispatchers.setMain(Dispatchers.Unconfined) - val viewModel = this - kotlinx.coroutines.test.runTest { - moleculeFlow(mode = RecompositionMode.Immediate) { - viewModel.uiState() - }.test { - events.onEach(viewModel::onEvent) - verify(expectMostRecentItem()) - cancel() - } - } - } finally { - Dispatchers.resetMain() - } -} diff --git a/shared/ui/testing/src/main/java/com/ivy/ui/testing/PaparazziScreenshotTest.kt b/shared/ui/testing/src/main/java/com/ivy/ui/testing/PaparazziScreenshotTest.kt deleted file mode 100644 index d89d843239..0000000000 --- a/shared/ui/testing/src/main/java/com/ivy/ui/testing/PaparazziScreenshotTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.ivy.ui.testing - -import androidx.compose.runtime.Composable -import app.cash.paparazzi.DeviceConfig -import app.cash.paparazzi.Paparazzi -import com.ivy.design.system.IvyMaterial3Theme -import org.junit.Before -import org.junit.Rule -import java.util.Locale - -open class PaparazziScreenshotTest { - - @Before - fun setup() { - Locale.setDefault(Locale.US) - } - - @get:Rule - val paparazzi = Paparazzi( - deviceConfig = DeviceConfig.PIXEL_6_PRO, - showSystemUi = true, - maxPercentDifference = 0.005 - ) - - protected fun snapshot(theme: PaparazziTheme, content: @Composable () -> Unit) { - paparazzi.snapshot { - IvyMaterial3Theme( - dark = when (theme) { - PaparazziTheme.Light -> false - PaparazziTheme.Dark -> true - } - ) { - content() - } - } - } -} - -enum class PaparazziTheme { - Light, Dark -} \ No newline at end of file diff --git a/shared/ui/testing/src/screenshotTestDebug/kotlin/DemoComposeScreenshotTesting.kt b/shared/ui/testing/src/screenshotTestDebug/kotlin/DemoComposeScreenshotTesting.kt new file mode 100644 index 0000000000..a3a4108015 --- /dev/null +++ b/shared/ui/testing/src/screenshotTestDebug/kotlin/DemoComposeScreenshotTesting.kt @@ -0,0 +1,36 @@ +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import com.ivy.ui.annotation.IvyPreviews + +@Suppress("UnusedPrivateMember") +@IvyPreviews +@Composable +private fun DemoComposeScreenTesting() { + Column { + Spacer(Modifier.height(16.dp)) + Box( + modifier = Modifier + .height(100.dp) + .width(100.dp) + .background(Color.Cyan) + + ) { + Box( + modifier = Modifier + .height(50.dp) + .width(50.dp) + .background(Color.Red) + + ) + } + Spacer(Modifier.height(16.dp)) + } +} \ No newline at end of file diff --git a/shared/ui/testing/src/test/java/com/ivy/ui/testing/ComposeViewModelTestExtTest.kt b/shared/ui/testing/src/test/java/com/ivy/ui/testing/ComposeViewModelTestExtTest.kt deleted file mode 100644 index cebdaa68da..0000000000 --- a/shared/ui/testing/src/test/java/com/ivy/ui/testing/ComposeViewModelTestExtTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.ivy.ui.testing - -import io.kotest.matchers.shouldBe -import org.junit.Before -import org.junit.Test - -class ComposeViewModelTestExtTest : ComposeViewModelTest() { - - private lateinit var viewModel: FakeViewModel - - @Before - fun setup() { - viewModel = FakeViewModel() - } - - @Test - fun `initial state, no events`() { - viewModel.runTest { - counter shouldBe 42 - } - } - - @Test - fun `increment event`() { - viewModel.runTest( - events = listOf(FakeUiEvent.Increment) - ) { - counter shouldBe 43 - } - } - - @Test - fun `decrement event`() { - viewModel.runTest( - events = listOf(FakeUiEvent.Decrement) - ) { - counter shouldBe 41 - } - } - - @Test - fun `1 decrement 2 increment event`() { - viewModel.runTest( - events = listOf( - FakeUiEvent.Decrement, - FakeUiEvent.Increment, - FakeUiEvent.Increment, - ) - ) { - counter shouldBe 43 - } - } -} diff --git a/shared/ui/testing/src/test/java/com/ivy/ui/testing/DemoPaparazziTest.kt b/shared/ui/testing/src/test/java/com/ivy/ui/testing/DemoPaparazziTest.kt deleted file mode 100644 index ff57e9e836..0000000000 --- a/shared/ui/testing/src/test/java/com/ivy/ui/testing/DemoPaparazziTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.ivy.ui.testing - -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Surface -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class DemoPaparazziTest( - @TestParameter - private val theme: PaparazziTheme, -) : PaparazziScreenshotTest() { - @Test - fun `snapshot demo composable`() { - snapshot(theme) { - DemoComposable() - } - } -} - -@Composable -fun DemoComposable(modifier: Modifier = Modifier) { - Surface(modifier = modifier) { - Text( - modifier = Modifier.padding(all = 16.dp), - text = "Demo composable", - ) - } -} \ No newline at end of file diff --git a/shared/ui/testing/src/test/java/com/ivy/ui/testing/FakeViewModel.kt b/shared/ui/testing/src/test/java/com/ivy/ui/testing/FakeViewModel.kt deleted file mode 100644 index 8157da498e..0000000000 --- a/shared/ui/testing/src/test/java/com/ivy/ui/testing/FakeViewModel.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.ivy.ui.testing - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.setValue -import com.ivy.ui.ComposeViewModel - -data class FakeUiState( - val counter: Int, -) - -sealed interface FakeUiEvent { - data object Increment : FakeUiEvent - data object Decrement : FakeUiEvent -} - -class FakeViewModel : ComposeViewModel() { - private var counter by mutableIntStateOf(0) - - @Composable - override fun uiState(): FakeUiState { - LaunchedEffect(Unit) { - counter = 42 - } - - return FakeUiState( - counter = counter, - ) - } - - override fun onEvent(event: FakeUiEvent) { - when (event) { - FakeUiEvent.Decrement -> counter-- - FakeUiEvent.Increment -> counter++ - } - } -} diff --git a/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Dark].png b/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Dark].png deleted file mode 100644 index 21be3365ff..0000000000 Binary files a/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Dark].png and /dev/null differ diff --git a/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Light].png b/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Light].png deleted file mode 100644 index 42fe43bd62..0000000000 Binary files a/shared/ui/testing/src/test/snapshots/images/com.ivy.ui.testing_DemoPaparazziTest_snapshot demo composable[Light].png and /dev/null differ diff --git a/temp/old-design/src/main/res/drawable/ic_baseline_add_24.xml b/temp/old-design/src/main/res/drawable/ic_baseline_add_24.xml index 54da215b47..9541683fe1 100644 --- a/temp/old-design/src/main/res/drawable/ic_baseline_add_24.xml +++ b/temp/old-design/src/main/res/drawable/ic_baseline_add_24.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24" - android:tint="?attr/colorControlNormal"> + >