Skip to content

Commit

Permalink
♻️ Since the About screen test has not been implemented, it has been …
Browse files Browse the repository at this point in the history
…implemented except where the Issue manager is located.

DroidKaigi#670
  • Loading branch information
Corvus400 committed Aug 31, 2024
1 parent e262833 commit 2883d08
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ package io.github.droidkaigi.confsched.testing.robot

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performScrollToNode
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeUp
import io.github.droidkaigi.confsched.about.AboutScreen
import io.github.droidkaigi.confsched.about.AboutScreenLazyColumnTestTag
import io.github.droidkaigi.confsched.about.section.AboutCreditsContributorsItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutCreditsSponsorsItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutCreditsStaffItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutCreditsTitleTestTag
import io.github.droidkaigi.confsched.about.section.AboutDetailTestTag
import io.github.droidkaigi.confsched.about.section.AboutFooterLinksTestTag
import io.github.droidkaigi.confsched.about.section.AboutOthersCodeOfConductItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutOthersLicenseItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutOthersPrivacyPolicyItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutOthersSettingsItemTestTag
import io.github.droidkaigi.confsched.about.section.AboutOthersTitleTestTag
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme
import javax.inject.Inject
Expand All @@ -24,6 +36,24 @@ class AboutScreenRobot @Inject constructor(
waitUntilIdle()
}

fun scrollToCreditsSection() {
composeTestRule
.onNode(hasTestTag(AboutScreenLazyColumnTestTag))
.performScrollToNode(hasTestTag(AboutCreditsStaffItemTestTag))

composeTestRule.onRoot().performTouchInput {
swipeUp(startY = centerY, endY = centerY - 200)
}
waitUntilIdle()
}

fun scrollToOthersSection() {
composeTestRule
.onNode(hasTestTag(AboutScreenLazyColumnTestTag))
.performScrollToNode(hasTestTag(AboutOthersTitleTestTag))
waitUntilIdle()
}

fun checkDetailSectionDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutDetailTestTag))
Expand All @@ -36,12 +66,52 @@ class AboutScreenRobot @Inject constructor(
.assertIsDisplayed()
}

fun checkCreditsSectionContentsDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutCreditsContributorsItemTestTag))
.assertExists()
.assertIsDisplayed()

composeTestRule
.onNode(hasTestTag(AboutCreditsStaffItemTestTag))
.assertExists()
.assertIsDisplayed()

composeTestRule
.onNode(hasTestTag(AboutCreditsSponsorsItemTestTag))
.assertExists()
.assertIsDisplayed()
}

fun checkOthersSectionTitleDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutOthersTitleTestTag))
.assertIsDisplayed()
}

fun checkOthersSectionContentsDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutOthersCodeOfConductItemTestTag))
.assertExists()
.assertIsDisplayed()

composeTestRule
.onNode(hasTestTag(AboutOthersLicenseItemTestTag))
.assertExists()
.assertIsDisplayed()

composeTestRule
.onNode(hasTestTag(AboutOthersPrivacyPolicyItemTestTag))
.assertExists()
.assertIsDisplayed()

composeTestRule
.onNode(hasTestTag(AboutOthersSettingsItemTestTag))
.assertExists()
.assertIsDisplayed()
}

// TODO https://github.com/DroidKaigi/conference-app-2024/issues/670
fun checkFooterLinksSectionDisplayed() {
composeTestRule
.onNode(hasTestTag(AboutFooterLinksTestTag))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ class AboutScreenTest(
checkDetailSectionDisplayed()
}
}
describe("when scroll to credits section") {
doIt {
scrollToCreditsSection()
}
itShould("show credits contents") {
captureScreenWithChecks {
checkCreditsSectionTitleDisplayed()
checkCreditsSectionContentsDisplayed()
}
}
}
describe("when scroll to others section") {
doIt {
scrollToOthersSection()
}
itShould("show others contents") {
captureScreenWithChecks {
checkOthersSectionTitleDisplayed()
checkOthersSectionContentsDisplayed()
}
}
}
// TODO https://github.com/DroidKaigi/conference-app-2024/issues/670
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import org.jetbrains.compose.resources.stringResource

const val aboutScreenRoute = "about"

const val AboutScreenLazyColumnTestTag = "AboutScreenLazyColumnTestTag"

object AboutScreenTestTag {
const val Screen = "AboutScreen"
}
Expand Down Expand Up @@ -93,7 +95,9 @@ fun AboutScreen(
),
) { padding ->
LazyColumn(
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
Modifier
.nestedScroll(scrollBehavior.nestedScrollConnection)
.testTag(AboutScreenLazyColumnTestTag),
contentPadding = padding,
state = lazyListState,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const val AboutOthersTitleTestTag = "AboutOthersTitleTestTag"
const val AboutOthersCodeOfConductItemTestTag = "AboutOthersCodeOfConductItemTestTag"
const val AboutOthersLicenseItemTestTag = "AboutOthersLicenseItemTestTag"
const val AboutOthersPrivacyPolicyItemTestTag = "AboutOthersPrivacyPolicyItemTestTag"
const val AboutOthersSettingsItemTestTag = "AboutOthersSettingsItemTestTag"

fun LazyListScope.aboutOthers(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -92,7 +93,7 @@ fun LazyListScope.aboutOthers(
leadingIcon = Outlined.Settings,
label = stringResource(AboutRes.string.settings),
onClickAction = onSettingsItemClick,
testTag = "TODO",
testTag = AboutOthersSettingsItemTestTag,
modifier = modifier
.padding(
horizontal = 16.dp,
Expand Down

0 comments on commit 2883d08

Please sign in to comment.