Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,44 @@ jobs:
**/build/reports/tests/
**/build/test-results/

screenshot-tests:
name: Screenshot Tests (Paparazzi)
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Cache Gradle dependencies
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: Verify Paparazzi snapshots
run: ./gradlew verifyPaparazziDebug

- name: Upload Paparazzi report
if: always()
uses: actions/upload-artifact@v4
with:
name: paparazzi-report
path: app/build/paparazzi/

ui-tests:
name: UI Tests
needs: [build, unit-tests]
needs: [build, unit-tests, screenshot-tests]
runs-on: ubuntu-latest
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 5
Expand Down Expand Up @@ -168,7 +203,7 @@ jobs:

sign_and_release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, lint, unit-tests, ui-tests]
needs: [build, lint, unit-tests, screenshot-tests, ui-tests]
runs-on: ubuntu-latest

steps:
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.ktlint)
alias(libs.plugins.paparazzi)
}

android {
Expand Down Expand Up @@ -111,4 +112,5 @@ dependencies {
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
testImplementation(kotlin("test"))
testImplementation(libs.paparazzi)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.plugbrain.android.challenges.addition

class AdditionFourDigitsChallenge : AdditionChallenge {
override val operand1: Int = (1000..10000).random()
override val operand2: Int = (1000..10000).random()
override val operand1: Int = (1000..9999).random()
override val operand2: Int = (1000..9999).random()
override val difficultyLevel: Int = 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package app.plugbrain.android.screenshots

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import app.cash.paparazzi.DeviceConfig
import app.cash.paparazzi.Paparazzi
import app.plugbrain.android.ui.designsystem.components.button.PlugButtonPrimary
import app.plugbrain.android.ui.designsystem.components.button.PlugButtonSecondary
import app.plugbrain.android.ui.designsystem.components.button.PlugButtonTertiary
import app.plugbrain.android.ui.theme.MathlockAppTheme
import org.junit.Rule
import org.junit.Test

class PlugButtonScreenshotTest {
@get:Rule
val paparazzi =
Paparazzi(
deviceConfig = DeviceConfig.PIXEL_5,
)

@Test
fun plugButtonTests() {
paparazzi.snapshot {
plugButtonsTest(darkTheme = false)
}
}

@Test
fun plugButtonDarkModeTests() {
paparazzi.snapshot {
plugButtonsTest(darkTheme = true)
}
}

@Composable
private fun plugButtonsTest(darkTheme: Boolean) {
MathlockAppTheme(dynamicColor = false, darkTheme = darkTheme) {
Column(
modifier =
Modifier
.background(MaterialTheme.colorScheme.background)
.padding(32.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
PlugButtonPrimary(
text = "Primary Button with icon",
onClick = {},
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonPrimary(
text = "Primary Button disabled",
onClick = {},
enabled = false,
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonSecondary(
text = "Secondary Button",
onClick = {},
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonSecondary(
text = "Secondary Button",
onClick = {},
enabled = false,
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonTertiary(
text = "Tertiary Button",
onClick = {},
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
PlugButtonTertiary(
text = "Tertiary Button",
onClick = {},
enabled = false,
icon = Icons.Default.Settings,
modifier = Modifier.fillMaxWidth(),
)
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ timber = "5.0.1"
mockitoVersion = "5.17.0"
mockitoKotlinVersion = "5.4.0"
mockkVersion = "1.14.0"
paparazzi = "1.3.1"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand Down Expand Up @@ -54,9 +55,12 @@ mockito = {module ="org.mockito:mockito-core", version.ref ="mockitoVersion"}
mockito-kotlin = {module ="org.mockito.kotlin:mockito-kotlin", version.ref = "mockitoKotlinVersion" }
mockk = {module ="io.mockk:mockk", version.ref = "mockkVersion" }

#Screenshot testing - Paparazzi
paparazzi = { module = "app.cash.paparazzi:paparazzi", version.ref = "paparazzi" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }

paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
Loading