Completely remove screenshot tests
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
34
.github/workflows/pull_request.yml
vendored
|
@ -7,40 +7,6 @@ on:
|
|||
- trying
|
||||
|
||||
jobs:
|
||||
# run-screenshot-tests:
|
||||
# runs-on: macOS-latest
|
||||
# steps:
|
||||
#
|
||||
# - uses: actions/setup-java@d202f5dbf7256730fb690ec59f6381650114feb2
|
||||
# with:
|
||||
# java-version: '11'
|
||||
#
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||
#
|
||||
# - name: Copy CI gradle.properties
|
||||
# run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
|
||||
#
|
||||
# - name: Boot emulator manually
|
||||
# run: |
|
||||
# ./scripts/setup_environment.sh
|
||||
# ./scripts/boot_emulator.sh &
|
||||
# until [ "$(adb shell getprop sys.boot_completed)" == "1" ]
|
||||
# do sleep 5
|
||||
# done
|
||||
#
|
||||
# - uses: burrunan/gradle-cache-action@03c71a8ba93d670980695505f48f49daf43704a6
|
||||
# name: Run screenshot tests
|
||||
# with:
|
||||
# arguments: executeScreenshotTests --stacktrace
|
||||
#
|
||||
# - name: (Fail-only) upload test report
|
||||
# if: failure()
|
||||
# uses: actions/upload-artifact@27bce4eee761b5bc643f46a8dfb41b430c8d05f6
|
||||
# with:
|
||||
# name: Test report
|
||||
# path: app/build/reports
|
||||
|
||||
run-unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
@ -4,8 +4,6 @@ This app is built as a very lightweight frontend for [lobste.rs](https://lobste.
|
|||
|
||||
The codebase is fairly simple, and the package structure follows [Buffer's](https://buffer.com/resources/android-rethinking-package-structure/).
|
||||
|
||||
We use screenshot testing for our Android UI, and a script is included in the `scripts` directory to create an emulator that will exactly match the one in our CI so you can deterministically replicate the setup for locally running tests.
|
||||
|
||||
## Subproject breakdown
|
||||
|
||||
- `:api`: Retrofit-backed interface to the [lobste.rs] API
|
||||
|
|
|
@ -4,18 +4,12 @@ plugins {
|
|||
kotlin("kapt")
|
||||
id("dagger.hilt.android.plugin")
|
||||
id("org.jetbrains.compose")
|
||||
id("shot")
|
||||
`versioning-plugin`
|
||||
`lobsters-plugin`
|
||||
`core-library-desugaring`
|
||||
}
|
||||
|
||||
android {
|
||||
defaultConfig {
|
||||
applicationId = "dev.msfjarvis.lobsters"
|
||||
testInstrumentationRunner = "com.karumi.shot.ShotTestRunner"
|
||||
}
|
||||
}
|
||||
android { defaultConfig { applicationId = "dev.msfjarvis.lobsters" } }
|
||||
|
||||
dependencies {
|
||||
kapt(libs.androidx.hilt.daggerCompiler)
|
||||
|
|
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 254 KiB |
Before Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 55 KiB |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="${applicationId}.test"
|
||||
android:sharedUserId="${applicationId}.uid">
|
||||
|
||||
</manifest>
|
|
@ -1,22 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui
|
||||
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import dev.msfjarvis.lobsters.ui.theme.darkColors
|
||||
import dev.msfjarvis.lobsters.ui.theme.lightColors
|
||||
|
||||
@Composable
|
||||
fun LightTestTheme(children: @Composable () -> Unit) {
|
||||
MaterialTheme(
|
||||
colors = lightColors,
|
||||
content = children,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DarkTestTheme(children: @Composable () -> Unit) {
|
||||
MaterialTheme(
|
||||
colors = darkColors,
|
||||
content = children,
|
||||
)
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.main
|
||||
|
||||
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||
import androidx.compose.ui.test.captureToImage
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import com.karumi.shot.ScreenshotTest
|
||||
import dev.msfjarvis.lobsters.ui.DarkTestTheme
|
||||
import dev.msfjarvis.lobsters.ui.LightTestTheme
|
||||
import dev.msfjarvis.lobsters.ui.navigation.Destination
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@Ignore("Shot is broken yet again")
|
||||
class LobstersTopBarTest : ScreenshotTest {
|
||||
|
||||
@get:Rule val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun showsRefreshIconWhenOnHottestPostsScreen_DarkTheme() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
LobstersTopAppBar(
|
||||
currentDestination = Destination.Hottest,
|
||||
toggleSortingOrder = {},
|
||||
launchSettings = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showsRefreshIconWhenOnHottestPostsScreen_LightTheme() {
|
||||
composeTestRule.setContent {
|
||||
LightTestTheme {
|
||||
LobstersTopAppBar(
|
||||
currentDestination = Destination.Hottest,
|
||||
toggleSortingOrder = {},
|
||||
launchSettings = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun doesNotShowRefreshIconWhenOnSavedPostsScreen_DarkTheme() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
LobstersTopAppBar(
|
||||
currentDestination = Destination.Saved,
|
||||
toggleSortingOrder = {},
|
||||
launchSettings = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun doesNotShowRefreshIconWhenOnSavedPostsScreen_LightTheme() {
|
||||
composeTestRule.setContent {
|
||||
LightTestTheme {
|
||||
LobstersTopAppBar(
|
||||
currentDestination = Destination.Saved,
|
||||
toggleSortingOrder = {},
|
||||
launchSettings = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.navigation
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||
import androidx.compose.ui.test.assertHasClickAction
|
||||
import androidx.compose.ui.test.captureToImage
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import androidx.compose.ui.test.performClick
|
||||
import com.karumi.shot.ScreenshotTest
|
||||
import dev.msfjarvis.lobsters.ui.DarkTestTheme
|
||||
import dev.msfjarvis.lobsters.ui.main.LobstersBottomNav
|
||||
import kotlin.test.Test
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
|
||||
@Ignore("Shot is broken yet again")
|
||||
class LobstersBottomNavTest : ScreenshotTest {
|
||||
|
||||
@get:Rule val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun bottomNavIsRenderedCorrectlyOnScreen() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
LobstersBottomNav(
|
||||
currentDestination = Destination.startDestination,
|
||||
navigateToDestination = {},
|
||||
jumpToIndex = { _, _ -> },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bottomNavUpdatesCorrectly() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
var destination by remember { mutableStateOf(Destination.startDestination) }
|
||||
|
||||
LobstersBottomNav(
|
||||
currentDestination = destination,
|
||||
navigateToDestination = { newDestination -> destination = newDestination },
|
||||
jumpToIndex = { _, _ -> },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
selectNode(Destination.Saved.name)
|
||||
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
private fun selectNode(testTag: String) =
|
||||
composeTestRule.onNodeWithTag(testTag).assertHasClickAction().performClick()
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.posts
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||
import androidx.compose.ui.test.captureToImage
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import com.karumi.shot.ScreenshotTest
|
||||
import dev.msfjarvis.lobsters.ui.DarkTestTheme
|
||||
import java.time.Month
|
||||
import kotlin.test.Test
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
|
||||
@Ignore("Shot is broken yet again")
|
||||
class HeaderTest : ScreenshotTest {
|
||||
@get:Rule val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun headerDoesNotHaveATransparentBackground() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.background(color = Color(0xffffff)).fillMaxWidth().wrapContentHeight(),
|
||||
) { MonthHeader(month = Month.AUGUST) }
|
||||
}
|
||||
}
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package dev.msfjarvis.lobsters.ui.posts
|
||||
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||
import androidx.compose.ui.test.captureToImage
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import com.karumi.shot.ScreenshotTest
|
||||
import dev.msfjarvis.lobsters.ui.DarkTestTheme
|
||||
import dev.msfjarvis.lobsters.ui.LightTestTheme
|
||||
import kotlin.test.Test
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
|
||||
@Ignore("Shot is broken yet again")
|
||||
class LobstersItemTest : ScreenshotTest {
|
||||
|
||||
@get:Rule val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun singlePost() {
|
||||
composeTestRule.setContent {
|
||||
DarkTestTheme {
|
||||
LobstersItem(
|
||||
post = TEST_POST,
|
||||
viewPost = {},
|
||||
viewComments = {},
|
||||
toggleSave = {},
|
||||
isSaved = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiplePosts() {
|
||||
composeTestRule.setContent {
|
||||
LightTestTheme {
|
||||
LazyColumn {
|
||||
items(10) {
|
||||
LobstersItem(
|
||||
post = TEST_POST,
|
||||
viewPost = {},
|
||||
viewComments = {},
|
||||
toggleSave = {},
|
||||
isSaved = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiplePostsWithLesserTags() {
|
||||
composeTestRule.setContent {
|
||||
LightTestTheme {
|
||||
LazyColumn {
|
||||
items(10) {
|
||||
LobstersItem(
|
||||
post = TEST_POST.copy(tags = listOf("openbsd", "linux")),
|
||||
viewPost = {},
|
||||
viewComments = {},
|
||||
toggleSave = {},
|
||||
isSaved = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
compareScreenshot(composeTestRule.onRoot().captureToImage().asAndroidBitmap())
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
status = [
|
||||
# "run-screenshot-tests",
|
||||
"run-unit-tests",
|
||||
"stylecheck"
|
||||
]
|
||||
|
|
|
@ -29,7 +29,6 @@ dependencies {
|
|||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
|
||||
implementation("com.google.devtools.ksp:symbol-processing-gradle-plugin:1.4.32-1.0.0-alpha08")
|
||||
implementation("com.github.zafarkhaja:java-semver:0.9.0")
|
||||
implementation("com.karumi:shot:5.10.3")
|
||||
implementation("com.diffplug.spotless:spotless-plugin-gradle:5.12.4")
|
||||
implementation("com.squareup.sqldelight:gradle-plugin:1.5.0")
|
||||
implementation("org.jetbrains.compose:compose-gradle-plugin:0.4.0-build188")
|
||||
|
|
|
@ -21,7 +21,6 @@ hiltGradlePlugin = { module = "com.google.dagger:hilt-android-gradle-plugin", ve
|
|||
jsemverGradlePlugin = "com.github.zafarkhaja:java-semver:0.9.0"
|
||||
kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||
kspGradlePlugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
|
||||
shotGradlePlugin = "com.karumi:shot:5.10.3"
|
||||
spotlessGradlePlugin = "com.diffplug.spotless:spotless-plugin-gradle:5.12.4"
|
||||
sqldelightGradlePlugin = { module = "com.squareup.sqldelight:gradle-plugin", version.ref = "sqldelight" }
|
||||
|
||||
|
|