diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/AboutScreenRobot.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/AboutScreenRobot.kt index 8e1613a4b..2690f033b 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/AboutScreenRobot.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/AboutScreenRobot.kt @@ -3,7 +3,10 @@ package io.github.droidkaigi.confsched.testing.robot import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasTestTag import io.github.droidkaigi.confsched.about.AboutScreen -import io.github.droidkaigi.confsched.about.AboutTestTag +import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag +import io.github.droidkaigi.confsched.about.section.AboutDetailSectionTestTag +import io.github.droidkaigi.confsched.about.section.AboutFooterLinksSectionTestTag +import io.github.droidkaigi.confsched.about.section.AboutOthersSectionTestTag import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.testing.DefaultScreenRobot import io.github.droidkaigi.confsched.testing.ScreenRobot @@ -25,25 +28,25 @@ class AboutScreenRobot @Inject constructor( fun checkDetailSectionDisplayed() { composeTestRule - .onNode(hasTestTag(AboutTestTag.DetailSection.Section)) + .onNode(hasTestTag(AboutDetailSectionTestTag.Section)) .assertIsDisplayed() } - fun checkCreditsSectionDisplayed() { + fun checkCreditsSectionTitleDisplayed() { composeTestRule - .onNode(hasTestTag(AboutTestTag.CreditsSection.Section)) + .onNode(hasTestTag(AboutCreditsSectionTestTag.Title)) .assertIsDisplayed() } - fun checkOthersSectionDisplayed() { + fun checkOthersSectionTitleDisplayed() { composeTestRule - .onNode(hasTestTag(AboutTestTag.OthersSection.Section)) + .onNode(hasTestTag(AboutOthersSectionTestTag.Title)) .assertIsDisplayed() } fun checkFooterLinksSectionDisplayed() { composeTestRule - .onNode(hasTestTag(AboutTestTag.FooterLinksSection.Section)) + .onNode(hasTestTag(AboutFooterLinksSectionTestTag.Section)) .assertIsDisplayed() } } diff --git a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/AboutScreen.kt b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/AboutScreen.kt index f7316308e..7ccecfbd4 100644 --- a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/AboutScreen.kt +++ b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/AboutScreen.kt @@ -29,29 +29,8 @@ import io.github.droidkaigi.confsched.model.AboutItem.YouTube const val aboutScreenRoute = "about" -object AboutTestTag { - private const val suffix = "TestTag" - private const val prefix = "ProfileCard" - - object DetailSection { - private const val detailSectionPrefix = "${prefix}_DetailSection" - const val Section = "${detailSectionPrefix}_$suffix" - } - - object CreditsSection { - private const val creditsSectionPrefix = "${prefix}_CreditsSection" - const val Section = "${creditsSectionPrefix}_$suffix" - } - - object OthersSection { - private const val othersSectionPrefix = "${prefix}_OthersSection" - const val Section = "${othersSectionPrefix}_$suffix" - } - - object FooterLinksSection { - private const val footerLinksSectionPrefix = "${prefix}_FooterLinksSection" - const val Section = "${footerLinksSectionPrefix}_$suffix" - } +object AboutScreenTestTag { + const val Screen = "AboutScreen" } fun NavGraphBuilder.aboutScreen( @@ -88,7 +67,7 @@ fun AboutScreen( val layoutDirection = LocalLayoutDirection.current Scaffold( - modifier = modifier, + modifier = modifier.testTag(AboutScreenTestTag.Screen), snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, contentWindowInsets = WindowInsets( left = contentPadding.calculateLeftPadding(layoutDirection), @@ -114,7 +93,6 @@ fun AboutScreen( onStaffItemClick = { onAboutItemClick(AboutItem.Staff) }, - modifier = Modifier.testTag(AboutTestTag.CreditsSection.Section), ) aboutOthers( onCodeOfConductItemClick = { @@ -126,7 +104,6 @@ fun AboutScreen( onPrivacyPolicyItemClick = { onAboutItemClick(AboutItem.PrivacyPolicy) }, - modifier = Modifier.testTag(AboutTestTag.OthersSection.Section), ) item { AboutFooterLinks( @@ -141,7 +118,6 @@ fun AboutScreen( onMediumClick = { onAboutItemClick(Medium) }, - modifier = Modifier.testTag(AboutTestTag.FooterLinksSection.Section), ) } } diff --git a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutCredits.kt b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutCredits.kt index cb174cebb..4ed4267a0 100644 --- a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutCredits.kt +++ b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutCredits.kt @@ -9,18 +9,25 @@ import androidx.compose.material.icons.outlined.SentimentVerySatisfied import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import conference_app_2024.feature.about.generated.resources.contributor import conference_app_2024.feature.about.generated.resources.credits_title -import conference_app_2024.feature.about.generated.resources.sponsor import conference_app_2024.feature.about.generated.resources.staff import io.github.droidkaigi.confsched.about.AboutRes import io.github.droidkaigi.confsched.about.component.AboutContentColumn +import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag.ContributorsItem +import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag.SponsorsItem +import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag.StaffItem import org.jetbrains.compose.resources.stringResource -const val AboutCreditsStaffItemTestTag = "AboutCreditsStaffItem" -const val AboutCreditsContributorsItemTestTag = "AboutCreditsContributorsItem" -const val AboutCreditsSponsorsItemTestTag = "AboutCreditsSponsorsItem" +@Suppress("ConstPropertyName") +object AboutCreditsSectionTestTag { + const val Title = "AboutCreditsTitle" + const val StaffItem = "AboutCreditsStaffItem" + const val ContributorsItem = "AboutCreditsContributorsItem" + const val SponsorsItem = "AboutCreditsSponsorsItem" +} fun LazyListScope.aboutCredits( modifier: Modifier = Modifier, @@ -33,6 +40,7 @@ fun LazyListScope.aboutCredits( text = stringResource(AboutRes.string.credits_title), style = MaterialTheme.typography.titleMedium, modifier = modifier + .testTag(AboutCreditsSectionTestTag.Title) .padding( start = 16.dp, top = 32.dp, @@ -44,7 +52,7 @@ fun LazyListScope.aboutCredits( AboutContentColumn( leadingIcon = Outlined.Diversity1, label = stringResource(AboutRes.string.contributor), - testTag = AboutCreditsContributorsItemTestTag, + testTag = ContributorsItem, onClickAction = onContributorsItemClick, modifier = modifier .padding( @@ -56,7 +64,7 @@ fun LazyListScope.aboutCredits( AboutContentColumn( leadingIcon = Outlined.SentimentVerySatisfied, label = stringResource(AboutRes.string.staff), - testTag = AboutCreditsStaffItemTestTag, + testTag = StaffItem, onClickAction = onStaffItemClick, modifier = modifier .padding( @@ -67,8 +75,8 @@ fun LazyListScope.aboutCredits( item { AboutContentColumn( leadingIcon = Outlined.Apartment, - label = stringResource(AboutRes.string.sponsor), - testTag = AboutCreditsSponsorsItemTestTag, + label = stringResource(AboutRes.string.staff), + testTag = SponsorsItem, onClickAction = onSponsorsItemClick, modifier = modifier .padding( diff --git a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutDroidKaigiDetail.kt b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutDroidKaigiDetail.kt index 21f9292c2..a38d20821 100644 --- a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutDroidKaigiDetail.kt +++ b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutDroidKaigiDetail.kt @@ -17,19 +17,23 @@ import conference_app_2024.feature.about.generated.resources.Res import conference_app_2024.feature.about.generated.resources.about_header import conference_app_2024.feature.about.generated.resources.description import io.github.droidkaigi.confsched.about.AboutRes -import io.github.droidkaigi.confsched.about.AboutTestTag import io.github.droidkaigi.confsched.about.component.AboutDroidKaigiDetailSummaryCard import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview +@Suppress("ConstPropertyName") +object AboutDetailSectionTestTag { + const val Section = "DetailSection" +} + @Composable fun AboutDroidKaigiDetail( modifier: Modifier = Modifier, ) { Column( - modifier = modifier.testTag(AboutTestTag.DetailSection.Section), + modifier = modifier.testTag(AboutDetailSectionTestTag.Section), ) { Image( painter = painterResource(Res.drawable.about_header), diff --git a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutFooterLinks.kt b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutFooterLinks.kt index 23604b863..ce3d94686 100644 --- a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutFooterLinks.kt +++ b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutFooterLinks.kt @@ -13,18 +13,27 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import conference_app_2024.feature.about.generated.resources.app_version import conference_app_2024.feature.about.generated.resources.content_description_youtube import io.github.droidkaigi.confsched.about.AboutRes import io.github.droidkaigi.confsched.about.component.AboutFooterLinksIcon +import io.github.droidkaigi.confsched.about.section.AboutFooterLinksSectionTestTag.LinksMediumItemTestTag +import io.github.droidkaigi.confsched.about.section.AboutFooterLinksSectionTestTag.LinksXItemTestTag +import io.github.droidkaigi.confsched.about.section.AboutFooterLinksSectionTestTag.LinksYouTubeItemTestTag +import io.github.droidkaigi.confsched.about.section.AboutFooterLinksSectionTestTag.Section import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview -const val AboutFooterLinksYouTubeItemTestTag = "AboutFooterLinksYouTubeItem" -const val AboutFooterLinksXItemTestTag = "AboutFooterLinksXItem" -const val AboutFooterLinksMediumItemTestTag = "AboutFooterLinksMediumItem" +@Suppress("ConstPropertyName") +object AboutFooterLinksSectionTestTag { + const val Section = "FooterLinksSection" + const val LinksYouTubeItemTestTag = "AboutFooterLinksYouTubeItem" + const val LinksXItemTestTag = "AboutFooterLinksXItem" + const val LinksMediumItemTestTag = "AboutFooterLinksMediumItem" +} @Composable fun AboutFooterLinks( @@ -38,22 +47,23 @@ fun AboutFooterLinks( verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally, modifier = modifier + .testTag(Section) .fillMaxWidth() .padding(top = 24.dp, bottom = 16.dp), ) { Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { AboutFooterLinksIcon( - testTag = AboutFooterLinksYouTubeItemTestTag, + testTag = LinksYouTubeItemTestTag, contentDescription = stringResource(AboutRes.string.content_description_youtube), onClick = onYouTubeClick, ) AboutFooterLinksIcon( - testTag = AboutFooterLinksXItemTestTag, + testTag = LinksXItemTestTag, contentDescription = "X", onClick = onXClick, ) AboutFooterLinksIcon( - testTag = AboutFooterLinksMediumItemTestTag, + testTag = LinksMediumItemTestTag, contentDescription = "Medium", onClick = onMediumClick, ) diff --git a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutOthers.kt b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutOthers.kt index 95d2554ea..a31b3c234 100644 --- a/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutOthers.kt +++ b/feature/about/src/commonMain/kotlin/io/github/droidkaigi/confsched/about/section/AboutOthers.kt @@ -12,6 +12,7 @@ import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import conference_app_2024.feature.about.generated.resources.code_of_conduct import conference_app_2024.feature.about.generated.resources.license @@ -19,13 +20,20 @@ import conference_app_2024.feature.about.generated.resources.others_title import conference_app_2024.feature.about.generated.resources.privacy_policy import io.github.droidkaigi.confsched.about.AboutRes import io.github.droidkaigi.confsched.about.component.AboutContentColumn +import io.github.droidkaigi.confsched.about.section.AboutOthersSectionTestTag.CodeOfConductItem +import io.github.droidkaigi.confsched.about.section.AboutOthersSectionTestTag.LicenseItem +import io.github.droidkaigi.confsched.about.section.AboutOthersSectionTestTag.PrivacyPolicyItem import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview -const val AboutOthersCodeOfConductItemTestTag = "AboutOthersCodeOfConductItem" -const val AboutOthersLicenseItemTestTag = "AboutOthersLicenseItem" -const val AboutOthersPrivacyPolicyItemTestTag = "AboutOthersPrivacyPolicyItem" +@Suppress("ConstPropertyName") +object AboutOthersSectionTestTag { + const val Title = "AboutOthersTitle" + const val CodeOfConductItem = "AboutOthersCodeOfConductItem" + const val LicenseItem = "AboutOthersLicenseItem" + const val PrivacyPolicyItem = "AboutOthersPrivacyPolicyItem" +} fun LazyListScope.aboutOthers( modifier: Modifier = Modifier, @@ -38,6 +46,7 @@ fun LazyListScope.aboutOthers( text = stringResource(AboutRes.string.others_title), style = MaterialTheme.typography.titleMedium, modifier = modifier + .testTag(AboutOthersSectionTestTag.Title) .padding( start = 16.dp, top = 32.dp, @@ -49,7 +58,7 @@ fun LazyListScope.aboutOthers( AboutContentColumn( leadingIcon = Outlined.Gavel, label = stringResource(AboutRes.string.code_of_conduct), - testTag = AboutOthersCodeOfConductItemTestTag, + testTag = CodeOfConductItem, onClickAction = onCodeOfConductItemClick, modifier = modifier .padding( @@ -61,7 +70,7 @@ fun LazyListScope.aboutOthers( AboutContentColumn( leadingIcon = Outlined.FileCopy, label = stringResource(AboutRes.string.license), - testTag = AboutOthersLicenseItemTestTag, + testTag = LicenseItem, onClickAction = onLicenseItemClick, modifier = modifier .padding( @@ -73,7 +82,7 @@ fun LazyListScope.aboutOthers( AboutContentColumn( leadingIcon = Outlined.PrivacyTip, label = stringResource(AboutRes.string.privacy_policy), - testTag = AboutOthersPrivacyPolicyItemTestTag, + testTag = PrivacyPolicyItem, onClickAction = onPrivacyPolicyItemClick, modifier = modifier .padding(