Skip to content

Commit

Permalink
📝 The robots were separated according to their roles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corvus400 committed Sep 8, 2024
1 parent f6b08f4 commit ae95036
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 185 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package io.github.droidkaigi.confsched.testing.robot.action

import androidx.compose.ui.test.filter
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollToNode
import androidx.compose.ui.test.performTextInput
import io.github.droidkaigi.confsched.droidkaigiui.Inject
import io.github.droidkaigi.confsched.sessions.component.DropdownFilterChipTestTagPrefix
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterCategoryChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterDayChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterLanguageChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersLazyRowTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchTextFieldAppBarTextFieldTestTag
import io.github.droidkaigi.confsched.testing.robot.DefaultScreenRobot
import io.github.droidkaigi.confsched.testing.robot.ScreenRobot
import io.github.droidkaigi.confsched.testing.robot.core.SearchScreenCoreRobot.Category
import io.github.droidkaigi.confsched.testing.robot.core.SearchScreenCoreRobot.ConferenceDay
import io.github.droidkaigi.confsched.testing.robot.TimetableItemCardRobot.Language
import io.github.droidkaigi.confsched.testing.robot.core.DemoSearchWord
import io.github.droidkaigi.confsched.testing.utils.hasTestTag

class SearchScreenActionRobot @Inject constructor(
private val screenRobot: DefaultScreenRobot,
) : ScreenRobot by screenRobot {
fun inputDemoSearchWord() {
inputSearchWord(DemoSearchWord)
}

private fun inputSearchWord(text: String) {
composeTestRule
.onNodeWithTag(SearchTextFieldAppBarTextFieldTestTag)
.performTextInput(text)
waitUntilIdle()
}

fun scrollToFilterLanguageChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersLazyRowTestTag))
.performScrollToNode(hasTestTag(SearchFiltersFilterLanguageChipTestTag))
waitUntilIdle()
}

fun clickFilterDayChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterDayChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickFilterCategoryChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterCategoryChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickFilterLanguageChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterLanguageChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickConferenceDay(
clickDay: ConferenceDay,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(clickDay.dateText))
.onFirst()
.performClick()
waitUntilIdle()
}

fun clickCategory(
category: Category,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(category.categoryName))
.onFirst()
.performClick()
waitUntilIdle()
}

fun clickLanguage(
language: Language,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(language.tagName))
.onFirst()
.performClick()
waitUntilIdle()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.github.droidkaigi.confsched.testing.robot.core

import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.droidkaigiui.Inject
import io.github.droidkaigi.confsched.sessions.SearchScreen
import io.github.droidkaigi.confsched.testing.robot.DefaultDeviceSetupRobot
import io.github.droidkaigi.confsched.testing.robot.DefaultScreenRobot
import io.github.droidkaigi.confsched.testing.robot.DefaultTimetableItemCardRobot
import io.github.droidkaigi.confsched.testing.robot.DefaultTimetableServerRobot
import io.github.droidkaigi.confsched.testing.robot.DeviceSetupRobot
import io.github.droidkaigi.confsched.testing.robot.ScreenRobot
import io.github.droidkaigi.confsched.testing.robot.action.SearchScreenActionRobot
import io.github.droidkaigi.confsched.testing.robot.verify.SearchScreenVerifyRobot
import io.github.droidkaigi.confsched.testing.robot.TimetableItemCardRobot
import io.github.droidkaigi.confsched.testing.robot.TimetableServerRobot

const val DemoSearchWord = "Demo"

class SearchScreenCoreRobot @Inject constructor(
private val screenRobot: DefaultScreenRobot,
private val timetableServerRobot: DefaultTimetableServerRobot,
private val deviceSetupRobot: DefaultDeviceSetupRobot,
timetableItemRobot: DefaultTimetableItemCardRobot,
) : ScreenRobot by screenRobot,
TimetableServerRobot by timetableServerRobot,
DeviceSetupRobot by deviceSetupRobot,
TimetableItemCardRobot by timetableItemRobot {
@Inject lateinit var actionRobot: SearchScreenActionRobot
@Inject lateinit var verifyRobot: SearchScreenVerifyRobot

enum class ConferenceDay(
val day: Int,
val dateText: String,
) {
Day1(1, "9/12"),
Day2(2, "9/13"),
}

enum class Category(
val categoryName: String,
) {
AppArchitecture("App Architecture en"),
JetpackCompose("Jetpack Compose en"),
Other("Other en"),
}

fun setupSearchScreenContent() {
robotTestRule.setContent {
KaigiTheme {
SearchScreen(
onTimetableItemClick = {},
onBackClick = {},
)
}
}
waitUntilIdle()
}
}
Original file line number Diff line number Diff line change
@@ -1,162 +1,34 @@
package io.github.droidkaigi.confsched.testing.robot
package io.github.droidkaigi.confsched.testing.robot.verify

import androidx.compose.ui.test.assertAll
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.filter
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollToNode
import androidx.compose.ui.test.performTextInput
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched.droidkaigiui.Inject
import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemCardTestTag
import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemCardTitleTextTestTag
import io.github.droidkaigi.confsched.sessions.SearchScreen
import io.github.droidkaigi.confsched.sessions.component.DropdownFilterChipTestTagPrefix
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterCategoryChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterDayChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersFilterLanguageChipTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchFiltersLazyRowTestTag
import io.github.droidkaigi.confsched.sessions.component.SearchTextFieldAppBarTextFieldTestTag
import io.github.droidkaigi.confsched.sessions.section.TimetableListTestTag
import io.github.droidkaigi.confsched.testing.robot.DefaultScreenRobot
import io.github.droidkaigi.confsched.testing.robot.ScreenRobot
import io.github.droidkaigi.confsched.testing.robot.core.SearchScreenCoreRobot.Category
import io.github.droidkaigi.confsched.testing.robot.core.SearchScreenCoreRobot.ConferenceDay
import io.github.droidkaigi.confsched.testing.robot.TimetableItemCardRobot.Language
import io.github.droidkaigi.confsched.testing.robot.core.DemoSearchWord
import io.github.droidkaigi.confsched.testing.utils.assertCountAtLeast
import io.github.droidkaigi.confsched.testing.utils.assertTextDoesNotContain
import io.github.droidkaigi.confsched.testing.utils.hasTestTag

const val DemoSearchWord = "Demo"

class SearchScreenRobot @Inject constructor(
class SearchScreenVerifyRobot @Inject constructor(
private val screenRobot: DefaultScreenRobot,
private val timetableServerRobot: DefaultTimetableServerRobot,
private val deviceSetupRobot: DefaultDeviceSetupRobot,
timetableItemRobot: DefaultTimetableItemCardRobot,
) : ScreenRobot by screenRobot,
TimetableServerRobot by timetableServerRobot,
DeviceSetupRobot by deviceSetupRobot,
TimetableItemCardRobot by timetableItemRobot {
enum class ConferenceDay(
val day: Int,
val dateText: String,
) {
Day1(1, "9/12"),
Day2(2, "9/13"),
}

enum class Category(
val categoryName: String,
) {
AppArchitecture("App Architecture en"),
JetpackCompose("Jetpack Compose en"),
Other("Other en"),
}

fun setupSearchScreenContent() {
robotTestRule.setContent {
KaigiTheme {
SearchScreen(
onTimetableItemClick = {},
onBackClick = {},
)
}
}
waitUntilIdle()
}

fun inputDemoSearchWord() {
inputSearchWord(DemoSearchWord)
}

private fun inputSearchWord(text: String) {
composeTestRule
.onNodeWithTag(SearchTextFieldAppBarTextFieldTestTag)
.performTextInput(text)
waitUntilIdle()
}

fun scrollToFilterLanguageChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersLazyRowTestTag))
.performScrollToNode(hasTestTag(SearchFiltersFilterLanguageChipTestTag))
waitUntilIdle()
}

fun clickFilterDayChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterDayChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickFilterCategoryChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterCategoryChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickFilterLanguageChip() {
composeTestRule
.onNode(hasTestTag(SearchFiltersFilterLanguageChipTestTag))
.performClick()
waitUntilIdle()
}

fun clickConferenceDay(
clickDay: ConferenceDay,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(clickDay.dateText))
.onFirst()
.performClick()
waitUntilIdle()
}

fun clickCategory(
category: Category,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(category.categoryName))
.onFirst()
.performClick()
waitUntilIdle()
}

fun clickLanguage(
language: Language,
) {
composeTestRule
.onAllNodes(
hasTestTag(
testTag = DropdownFilterChipTestTagPrefix,
substring = true,
),
)
.filter(matcher = hasText(language.tagName))
.onFirst()
.performClick()
waitUntilIdle()
}

) : ScreenRobot by screenRobot {
fun checkDisplayedFilterDayChip() {
composeTestRule
.onAllNodes(
Expand Down
Loading

0 comments on commit ae95036

Please sign in to comment.