Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 [Proposal][SearchScreenTest] The robots were separated according to their roles. #1000

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
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.TimetableItemCardRobot.Language
import io.github.droidkaigi.confsched.testing.robot.core.DemoSearchWord
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.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,59 @@
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.TimetableItemCardRobot
import io.github.droidkaigi.confsched.testing.robot.TimetableServerRobot
import io.github.droidkaigi.confsched.testing.robot.action.SearchScreenActionRobot
import io.github.droidkaigi.confsched.testing.robot.verify.SearchScreenVerifyRobot

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.TimetableItemCardRobot.Language
import io.github.droidkaigi.confsched.testing.robot.core.DemoSearchWord
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.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
Loading