BIT-1599: Add test tags as resources for selection dialogs (#1081)

This commit is contained in:
David Perez 2024-03-04 11:03:26 -06:00 committed by Álison Fernandes
parent 3eabdbf8b6
commit cfc6dff1d7
4 changed files with 13 additions and 15 deletions

View file

@ -15,9 +15,12 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Dialog
import com.x8bit.bitwarden.R import com.x8bit.bitwarden.R
@ -32,6 +35,7 @@ import com.x8bit.bitwarden.ui.platform.components.util.maxDialogHeight
* [BitwardenSelectionRow]. * [BitwardenSelectionRow].
*/ */
@Suppress("LongMethod") @Suppress("LongMethod")
@OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
fun BitwardenSelectionDialog( fun BitwardenSelectionDialog(
title: String, title: String,
@ -45,6 +49,7 @@ fun BitwardenSelectionDialog(
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Column( Column(
modifier = Modifier modifier = Modifier
.semantics { testTagsAsResourceId = true }
.requiredHeightIn( .requiredHeightIn(
max = configuration.maxDialogHeight, max = configuration.maxDialogHeight,
) )

View file

@ -9,7 +9,6 @@ import androidx.compose.ui.test.hasScrollToNodeAction
import androidx.compose.ui.test.hasText import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.isDialog import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
@ -492,9 +491,8 @@ class SearchScreenTest : BaseComposeTest() {
.performClick() .performClick()
composeTestRule composeTestRule
.onNode(isDialog()) .onAllNodesWithText("mockName-$number")
.onChildren() .filterToOne(hasAnyAncestor(isDialog()))
.filterToOne(hasText("mockName-$number"))
.assertIsDisplayed() .assertIsDisplayed()
} }
@ -703,9 +701,8 @@ class SearchScreenTest : BaseComposeTest() {
.performClick() .performClick()
composeTestRule composeTestRule
.onNode(isDialog()) .onAllNodesWithText("mockName-$number")
.onChildren() .filterToOne(hasAnyAncestor(isDialog()))
.filterToOne(hasText("mockName-$number"))
.assertIsDisplayed() .assertIsDisplayed()
} }

View file

@ -12,7 +12,6 @@ import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isPopup import androidx.compose.ui.test.isPopup
import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
@ -444,9 +443,8 @@ class SendScreenTest : BaseComposeTest() {
.performClick() .performClick()
composeTestRule composeTestRule
.onNode(isDialog()) .onAllNodesWithText(DEFAULT_SEND_ITEM.name)
.onChildren() .filterToOne(hasAnyAncestor(isDialog()))
.filterToOne(hasText(DEFAULT_SEND_ITEM.name))
.assertIsDisplayed() .assertIsDisplayed()
} }

View file

@ -12,7 +12,6 @@ import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.isDisplayed import androidx.compose.ui.test.isDisplayed
import androidx.compose.ui.test.isPopup import androidx.compose.ui.test.isPopup
import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
@ -985,9 +984,8 @@ class VaultItemListingScreenTest : BaseComposeTest() {
.performClick() .performClick()
composeTestRule composeTestRule
.onNode(isDialog()) .onAllNodesWithText("mockTitle-$number")
.onChildren() .filterToOne(hasAnyAncestor(isDialog()))
.filterToOne(hasText("mockTitle-$number"))
.assertIsDisplayed() .assertIsDisplayed()
} }