Skip to content

Commit

Permalink
Merge pull request #86 from RajashekarRaju/shreyas/screenshot-tests-s…
Browse files Browse the repository at this point in the history
…earch

Added screenshot test for SearchScreenUI
  • Loading branch information
yesshreyes authored Feb 3, 2025
2 parents b0e4e50 + 8ec4779 commit 6159129
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 43 deletions.
9 changes: 2 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
## Description

### Task related to roadmap v0.3.0
### Task related to roadmap v0.4.0

- [ ] Please add your task here

### Task status

- In Progress
- Completed
- [ ] Please add your task here
21 changes: 11 additions & 10 deletions .github/workflows/androidTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: gradle-cache-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}
restore-keys: gradle-cache-${{ runner.os }}-

- name: Run local tests
run: ./gradlew testDebug --stacktrace

- name: Cache AVD
uses: actions/cache@v3
id: avd-cache
Expand All @@ -43,20 +46,18 @@ jobs:
key: avd-cache-${{ runner.os }}-${{ hashFiles('**/*.avd') }}
restore-keys: avd-cache-${{ runner.os }}-

- name: Create AVD and generate snapshot for caching and Run androidTest
- name: Create Android Virtual Device and run all tests
uses: reactivecircus/android-emulator-runner@v2
continue-on-error: true
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 500
id: testing
with:
api-level: 29
emulator-build: 7425822
target: google_apis
arch: x86_64
force-avd-creation: true
emulator-options: -wipe-data -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: |
echo "Generated AVD snapshot for caching."
./gradlew connectedCheck
./gradlew testDebugUnitTest validateDebugScreenshotTest connectedDebugAndroidTest --stacktrace
- name: Upload Failing Test Report Log
if: steps.testing.outcome != 'success'
Expand Down
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
alias(libs.plugins.com.google.firebase)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.serialization)
alias(libs.plugins.screenshot)
}

android {
Expand Down Expand Up @@ -45,7 +46,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

experimentalProperties["android.experimental.enableScreenshotTest"] = true
kotlinOptions {
jvmTarget = "1.8"
// To mark experimental features api
Expand Down Expand Up @@ -139,6 +140,8 @@ dependencies {
androidTestImplementation(libs.androidx.compose.ui.ui.test.junit4)

debugImplementation(libs.androidx.compose.ui.ui.test.manifest)

screenshotTestImplementation(libs.androidx.compose.ui.tooling)
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).configureEach {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private fun SearchScreenUIDarkPreview() {

@Preview(showBackground = true)
@Composable
private fun SearchScreenUILightPreview() {
fun SearchScreenUILightPreview() {
ComposeActorsTheme(darkTheme = false) {
SearchScreenUI(
navigateUp = {},
Expand Down
11 changes: 11 additions & 0 deletions app/src/screenshotTest/kotlin/SearchScreenScreenshotTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.developersbreach.composeactors.screenshotTests

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import com.developersbreach.composeactors.ui.screens.search.SearchScreenUILightPreview

@Preview
@Composable
private fun SearchScreenUIPreviewTest() {
SearchScreenUILightPreview()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class DesignSystemTest {
Konsist.scopeFromProject()
.files
.filter { file ->
excludePaths.all { !file.path.contains(it) }
val normalizedFilePath = file.path.replace("\\", "/").lowercase()
excludePaths.none { normalizedFilePath.contains(it.replace("\\", "/").lowercase()) }
}
.flatMap { file ->
file.imports.filter { it.name == materialComponent }.map { file }
Expand Down
20 changes: 0 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
alias(libs.plugins.com.google.ksp) apply false
alias(libs.plugins.com.google.gms) apply false
alias(libs.plugins.com.google.firebase) apply false
alias(libs.plugins.com.diffplug.spotless)
alias(libs.plugins.com.github.ben.manes.versions)
alias(libs.plugins.nl.littlerobots.version.catalog.update)
alias(libs.plugins.compose.compiler) apply false
Expand All @@ -17,25 +16,6 @@ buildscript {
}
}

spotless {
// optional: limit format enforcement to just the files changed by this feature branch
//ratchetFrom 'origin/master'

kotlin {
// spotless:off and spotless:on
// toggleOffOn()

target("**/*.kt")
targetExclude("$buildDir/**/*.kt")
targetExclude("bin/**/*.kt")
ktlint("0.48.1")
ktfmt()
}

// Disabling warnings and error messages
// enforceCheck false
}

tasks.withType(com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class) {
fun isStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ android.nonTransitiveRClass=true
kotlin.code.style=official
# This gives detailed warning on deprecated usages in gradle
org.gradle.warning.mode=all
org.gradle.configuration-cache=true
org.gradle.configuration-cache=true
android.experimental.enableScreenshotTest=true
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kotlin = "2.0.21"
kotlinx-coroutines-core = "1.9.0"
ktor-bom = "3.0.1"
jetbrains-kotlin-jvm = "2.0.21"
screenshot = "0.0.1-alpha07"

[libraries]
androidx-activity-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
Expand Down Expand Up @@ -61,10 +62,10 @@ ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negoti
ktor-client-logging = { module = "io.ktor:ktor-client-logging" }
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling"}

[plugins]
com-android-application = "com.android.application:8.7.3"
com-diffplug-spotless = "com.diffplug.spotless:6.18.0"
com-github-ben-manes-versions = "com.github.ben-manes.versions:0.46.0"
nl-littlerobots-version-catalog-update = "nl.littlerobots.version-catalog-update:0.8.0"
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand All @@ -74,3 +75,4 @@ com-google-ksp = "com.google.devtools.ksp:2.0.21-1.0.27"
com-google-gms = { id = "com.google.gms.google-services", version.ref = "com-google-gms" }
com-google-firebase = { id = "com.google.firebase.crashlytics", version.ref = "com-google-firebase" }
jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "jetbrains-kotlin-jvm" }
screenshot = { id = "com.android.compose.screenshot", version.ref = "screenshot"}

0 comments on commit 6159129

Please sign in to comment.