From 4ee32d6e7a1df68546321f545fdc61bed886fcf0 Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 4 Aug 2024 18:20:58 +0900 Subject: [PATCH 1/3] Fix test tag style of About screen --- .../testing/robot/AboutScreenRobot.kt | 17 ++++++----- .../droidkaigi/confsched/about/AboutScreen.kt | 30 ++----------------- .../confsched/about/section/AboutCredits.kt | 21 +++++++++---- .../about/section/AboutDroidKaigiDetail.kt | 7 +++-- .../about/section/AboutFooterLinks.kt | 21 +++++++++---- .../confsched/about/section/AboutOthers.kt | 20 +++++++++---- 6 files changed, 62 insertions(+), 54 deletions(-) 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 d4853f254..c0795fef9 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,17 +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.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" + +object AboutCreditsSectionTestTag { + const val Title = "AboutCreditsTitle" + const val StaffItem = "AboutCreditsStaffItem" + const val ContributorsItem = "AboutCreditsContributorsItem" + const val SponsorsItem = "AboutCreditsSponsorsItem" +} fun LazyListScope.aboutCredits( modifier: Modifier = Modifier, @@ -32,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, @@ -43,7 +52,7 @@ fun LazyListScope.aboutCredits( AboutContentColumn( leadingIcon = Outlined.Diversity1, label = stringResource(AboutRes.string.contributor), - testTag = AboutCreditsContributorsItemTestTag, + testTag = ContributorsItem, onClickAction = onContributorsItemClick, modifier = modifier .padding( @@ -55,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,7 +76,7 @@ fun LazyListScope.aboutCredits( AboutContentColumn( leadingIcon = Outlined.Apartment, label = stringResource(AboutRes.string.staff), - testTag = AboutCreditsSponsorsItemTestTag, + 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..50f3893f7 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,22 @@ 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 +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..947507ba1 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,26 @@ 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" +object AboutFooterLinksSectionTestTag { + const val Section = "FooterLinksSection" + const val LinksYouTubeItemTestTag = "AboutFooterLinksYouTubeItem" + const val LinksXItemTestTag = "AboutFooterLinksXItem" + const val LinksMediumItemTestTag = "AboutFooterLinksMediumItem" +} @Composable fun AboutFooterLinks( @@ -38,22 +46,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..54bffd044 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,19 @@ 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" +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 +45,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 +57,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 +69,7 @@ fun LazyListScope.aboutOthers( AboutContentColumn( leadingIcon = Outlined.FileCopy, label = stringResource(AboutRes.string.license), - testTag = AboutOthersLicenseItemTestTag, + testTag = LicenseItem, onClickAction = onLicenseItemClick, modifier = modifier .padding( @@ -73,7 +81,7 @@ fun LazyListScope.aboutOthers( AboutContentColumn( leadingIcon = Outlined.PrivacyTip, label = stringResource(AboutRes.string.privacy_policy), - testTag = AboutOthersPrivacyPolicyItemTestTag, + testTag = PrivacyPolicyItem, onClickAction = onPrivacyPolicyItemClick, modifier = modifier .padding( From 47c295a2c5caa8ca3016ed6ddc0b5c4b7b8d155b Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 4 Aug 2024 18:30:14 +0900 Subject: [PATCH 2/3] Add @Suppress("ConstPropertyName") --- .../github/droidkaigi/confsched/about/section/AboutCredits.kt | 2 +- .../droidkaigi/confsched/about/section/AboutDroidKaigiDetail.kt | 1 + .../droidkaigi/confsched/about/section/AboutFooterLinks.kt | 1 + .../io/github/droidkaigi/confsched/about/section/AboutOthers.kt | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) 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 4225bef84..9a19c7e2a 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 @@ -22,7 +22,7 @@ import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag.S import io.github.droidkaigi.confsched.about.section.AboutCreditsSectionTestTag.StaffItem import org.jetbrains.compose.resources.stringResource - +@Suppress("ConstPropertyName") object AboutCreditsSectionTestTag { const val Title = "AboutCreditsTitle" const val StaffItem = "AboutCreditsStaffItem" 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 50f3893f7..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 @@ -23,6 +23,7 @@ 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" } 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 947507ba1..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 @@ -27,6 +27,7 @@ import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview +@Suppress("ConstPropertyName") object AboutFooterLinksSectionTestTag { const val Section = "FooterLinksSection" const val LinksYouTubeItemTestTag = "AboutFooterLinksYouTubeItem" 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 54bffd044..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 @@ -27,6 +27,7 @@ import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview +@Suppress("ConstPropertyName") object AboutOthersSectionTestTag { const val Title = "AboutOthersTitle" const val CodeOfConductItem = "AboutOthersCodeOfConductItem" From 918f50caa0ad34b9e33926b16c31b22292f06cdb Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 4 Aug 2024 18:35:25 +0900 Subject: [PATCH 3/3] Fix format --- .../io/github/droidkaigi/confsched/about/section/AboutCredits.kt | 1 - 1 file changed, 1 deletion(-) 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 9a19c7e2a..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 @@ -13,7 +13,6 @@ 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