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

Fix test tag style of About screen #230

Merged
Merged
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
Expand Up @@ -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
Expand All @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand All @@ -114,7 +93,6 @@ fun AboutScreen(
onStaffItemClick = {
onAboutItemClick(AboutItem.Staff)
},
modifier = Modifier.testTag(AboutTestTag.CreditsSection.Section),
)
aboutOthers(
onCodeOfConductItemClick = {
Expand All @@ -126,7 +104,6 @@ fun AboutScreen(
onPrivacyPolicyItemClick = {
onAboutItemClick(AboutItem.PrivacyPolicy)
},
modifier = Modifier.testTag(AboutTestTag.OthersSection.Section),
)
item {
AboutFooterLinks(
Expand All @@ -141,7 +118,6 @@ fun AboutScreen(
onMediumClick = {
onAboutItemClick(Medium)
},
modifier = Modifier.testTag(AboutTestTag.FooterLinksSection.Section),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,28 @@ 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
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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
Loading