Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Created August 23, 2022 00:50
Show Gist options
  • Save markchristopherng/141c30b6d09f839c75d91b70d0b6420c to your computer and use it in GitHub Desktop.
Save markchristopherng/141c30b6d09f839c75d91b70d0b6420c to your computer and use it in GitHub Desktop.
class AccountDetailsPage constructor(private val composeTestRule: ComposeContentTestRule) {
val personalDetails: PersonalDetails
get() =
with(composeTestRule) {
PersonalDetails(
preferredName = TitleValue(
title = onNestedChild(UiAssert.stringRes(R.string.glam_preferred_name), "txt_title"),
value = onNestedChild(UiAssert.stringRes(R.string.glam_preferred_name), "txt_subtitle")
),
lastName = TitleValue(
title = onNestedChild(UiAssert.stringRes(R.string.glam_surname), "txt_title"),
value = onNestedChild(UiAssert.stringRes(R.string.glam_surname), "txt_subtitle")
),
givenName = TitleValue(
title = onNestedChild(UiAssert.stringRes(R.string.glam_given_name), "txt_title"),
value = onNestedChild(UiAssert.stringRes(R.string.glam_given_name), "txt_subtitle")
),
dateOfBirth = TitleValue(
title = onNestedChild(UiAssert.stringRes(R.string.glam_date_of_birth), "txt_title"),
value = onNestedChild(UiAssert.stringRes(R.string.glam_date_of_birth), "txt_subtitle")
),
)
}
data class PersonalDetails(
val preferredName: TitleValue,
val lastName: TitleValue,
val givenName: TitleValue,
val dateOfBirth: TitleValue,
)
data class TitleValue(
val title: SemanticsNodeInteraction,
val value: SemanticsNodeInteraction
) {
fun assertText(titleText: String, valueText: String) {
title.assert(hasText(titleText))
value.assert(hasText(valueText))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment