Skip to content

Commit

Permalink
Merge pull request DroidKaigi#1255 from Oxypetalum7/feature/add-check…
Browse files Browse the repository at this point in the history
…-launch-server-error-shot

Add checkLaunchServerErrorShot
  • Loading branch information
takahirom authored Sep 18, 2023
2 parents ae4742f + f963881 commit 2052094
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package io.github.droidkaigi.confsched2023.testing.robot
import androidx.compose.ui.test.isRoot
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import com.github.takahirom.roborazzi.captureRoboImage
import io.github.droidkaigi.confsched2023.data.staff.FakeStaffApiClient
import io.github.droidkaigi.confsched2023.data.staff.StaffApiClient
import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched2023.staff.StaffScreen
import io.github.droidkaigi.confsched2023.testing.RobotTestRule
Expand All @@ -16,6 +18,10 @@ class StaffScreenRobot @Inject constructor(
) {

@Inject lateinit var robotTestRule: RobotTestRule

@Inject lateinit var staffApiClient: StaffApiClient
val fakeStaffApiClient: FakeStaffApiClient
get() = staffApiClient as FakeStaffApiClient
private lateinit var composeTestRule: AndroidComposeTestRule<*, *>

operator fun invoke(
Expand All @@ -39,6 +45,20 @@ class StaffScreenRobot @Inject constructor(
waitUntilIdle()
}

enum class ServerStatus {
Operational,
Error,
}

fun setupServer(serverStatus: ServerStatus) {
fakeStaffApiClient.setup(
when (serverStatus) {
ServerStatus.Operational -> FakeStaffApiClient.Status.Operational
ServerStatus.Error -> FakeStaffApiClient.Status.Error
},
)
}

fun checkScreenCapture() {
composeTestRule
.onNode(isRoot())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.github.droidkaigi.confsched2023.testing.HiltTestActivity
import io.github.droidkaigi.confsched2023.testing.RobotTestRule
import io.github.droidkaigi.confsched2023.testing.category.ScreenshotTests
import io.github.droidkaigi.confsched2023.testing.robot.StaffScreenRobot
import io.github.droidkaigi.confsched2023.testing.robot.StaffScreenRobot.ServerStatus.Error
import org.junit.Rule
import org.junit.Test
import org.junit.experimental.categories.Category
Expand Down Expand Up @@ -38,4 +39,14 @@ class StaffScreenTest {
checkScreenCapture()
}
}

@Test
@Category(ScreenshotTests::class)
fun checkLaunchServerErrorShot() {
staffScreenRobot {
setupServer(Error)
setupScreenContent()
checkScreenCapture()
}
}
}

0 comments on commit 2052094

Please sign in to comment.