From 888e079f0982d02e75d4fb2eeb633e15e0afdb13 Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 14 Mar 2024 14:52:53 -0500 Subject: [PATCH] BIT-2078: Add element IDs for search screen (#1145) --- .../components/listitem/BitwardenListItem.kt | 23 +++++++++----- .../platform/components/model/IconResource.kt | 5 ++++ .../platform/feature/search/SearchContent.kt | 3 ++ .../feature/search/SearchViewModel.kt | 3 ++ .../search/util/SearchTypeDataExtensions.kt | 6 ++++ .../feature/send/model/SendStatusIcon.kt | 6 ++++ .../feature/send/util/SendViewExtensions.kt | 8 ++++- .../itemlisting/VaultItemListingContent.kt | 3 ++ .../itemlisting/VaultItemListingViewModel.kt | 6 ++++ .../util/VaultItemListingDataExtensions.kt | 6 ++++ .../feature/util/CipherViewExtensions.kt | 6 +++- .../ui/vault/model/VaultTrailingIcon.kt | 3 ++ .../feature/search/util/SearchUtil.kt | 30 +++++++++++++++++++ .../send/util/SendViewExtensionsTest.kt | 5 ++++ .../itemlisting/VaultItemListingScreenTest.kt | 6 ++++ .../util/VaultItemListingDataUtil.kt | 30 +++++++++++++++++++ .../feature/util/CipherViewExtensionsTest.kt | 24 ++++++++++++--- 17 files changed, 160 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/listitem/BitwardenListItem.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/listitem/BitwardenListItem.kt index cbd9f7efa6..69ffe1c0c9 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/listitem/BitwardenListItem.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/listitem/BitwardenListItem.kt @@ -51,8 +51,10 @@ import kotlinx.collections.immutable.persistentListOf * dialog. * @param modifier An optional [Modifier] for this Composable, defaulting to an empty Modifier. * This allows the caller to specify things like padding, size, etc. + * @param labelTestTag The optional test tag for the [label]. * @param optionsTestTag The optional test tag for the options button. * @param supportingLabel An optional secondary text label to display beneath the label. + * @param supportingLabelTestTag The optional test tag for the [supportingLabel]. * @param trailingLabelIcons An optional list of small icons to be displayed after the [label]. */ @Suppress("LongMethod") @@ -63,8 +65,10 @@ fun BitwardenListItem( onClick: () -> Unit, selectionDataList: ImmutableList, modifier: Modifier = Modifier, + labelTestTag: String? = null, optionsTestTag: String? = null, supportingLabel: String? = null, + supportingLabelTestTag: String? = null, trailingLabelIcons: ImmutableList = persistentListOf(), ) { var shouldShowDialog by rememberSaveable { mutableStateOf(false) } @@ -98,25 +102,30 @@ fun BitwardenListItem( color = MaterialTheme.colorScheme.onSurface, maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(weight = 1f, fill = false), + modifier = Modifier + .semantics { labelTestTag?.let { testTag = it } } + .weight(weight = 1f, fill = false), ) - trailingLabelIcons.forEach { + trailingLabelIcons.forEach { iconResource -> Spacer(modifier = Modifier.width(8.dp)) Icon( - painter = it.iconPainter, - contentDescription = it.contentDescription, + painter = iconResource.iconPainter, + contentDescription = iconResource.contentDescription, tint = MaterialTheme.colorScheme.secondary, - modifier = Modifier.size(16.dp), + modifier = Modifier + .semantics { iconResource.testTag?.let { testTag = it } } + .size(16.dp), ) } } - supportingLabel?.let { + supportingLabel?.let { supportLabel -> Text( - text = it, + text = supportLabel, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.semantics { supportingLabelTestTag?.let { testTag = it } }, ) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/model/IconResource.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/model/IconResource.kt index 3342170b52..70c75d480a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/model/IconResource.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/model/IconResource.kt @@ -13,10 +13,12 @@ import kotlinx.parcelize.Parcelize * * @property iconPainter Painter for the icon. * @property contentDescription String for the icon's content description. + * @property testTag The optional test tag to associate with this icon. */ data class IconResource( val iconPainter: Painter, val contentDescription: String, + val testTag: String? = null, ) /** @@ -24,12 +26,14 @@ data class IconResource( * * @property iconRes Resource for the icon. * @property contentDescription The icon's content description. + * @property testTag The optional test tag to associate with this icon. */ @Parcelize data class IconRes( @DrawableRes val iconRes: Int, val contentDescription: Text, + val testTag: String? = null, ) : Parcelable /** @@ -46,4 +50,5 @@ fun IconRes.toIconResource(): IconResource = IconResource( iconPainter = painterResource(id = iconRes), contentDescription = contentDescription(), + testTag = testTag, ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchContent.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchContent.kt index 9f7d2e8d40..55d94bd792 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchContent.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchContent.kt @@ -112,7 +112,10 @@ fun SearchContent( BitwardenListItem( startIcon = it.iconData, label = it.title, + labelTestTag = it.titleTestTag, supportingLabel = it.subtitle, + supportingLabelTestTag = it.subtitleTestTag, + optionsTestTag = it.overflowTestTag, onClick = { if (it.autofillSelectionOptions.isNotEmpty()) { autofillSelectionOptionsItem = it diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchViewModel.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchViewModel.kt index fee614e581..d98b524801 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchViewModel.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/SearchViewModel.kt @@ -770,11 +770,14 @@ data class SearchState( data class DisplayItem( val id: String, val title: String, + val titleTestTag: String, val subtitle: String?, + val subtitleTestTag: String, val totpCode: String?, val iconData: IconData, val extraIconList: List, val overflowOptions: List, + val overflowTestTag: String?, val autofillSelectionOptions: List, val shouldDisplayMasterPasswordReprompt: Boolean, ) : Parcelable diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt index 2ab6236afb..44750f6dc7 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchTypeDataExtensions.kt @@ -183,13 +183,16 @@ private fun CipherView.toDisplayItem( SearchState.DisplayItem( id = id.orEmpty(), title = name, + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = this.toIconData( baseIconUrl = baseIconUrl, isIconLoadingDisabled = isIconLoadingDisabled, ), extraIconList = toLabelIcons(), overflowOptions = toOverflowActions(), + overflowTestTag = "CipherOptionsButton", totpCode = login?.totp, autofillSelectionOptions = AutofillSelectionOption .entries @@ -322,7 +325,9 @@ private fun SendView.toDisplayItem( SearchState.DisplayItem( id = id.orEmpty(), title = name, + titleTestTag = "SendNameLabel", subtitle = deletionDate.toFormattedPattern(DELETION_DATE_PATTERN, clock), + subtitleTestTag = "SendDateLabel", iconData = IconData.Local( iconRes = when (type) { SendType.TEXT -> R.drawable.ic_send_text @@ -331,6 +336,7 @@ private fun SendView.toDisplayItem( ), extraIconList = toLabelIcons(clock = clock), overflowOptions = toOverflowActions(baseWebSendUrl = baseWebSendUrl), + overflowTestTag = "SendOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/model/SendStatusIcon.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/model/SendStatusIcon.kt index 43c677f024..658789c2aa 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/model/SendStatusIcon.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/model/SendStatusIcon.kt @@ -11,25 +11,31 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText enum class SendStatusIcon( @DrawableRes val iconRes: Int, val contentDescription: Text, + val testTag: String, ) { DISABLED( iconRes = R.drawable.ic_send_disabled, contentDescription = R.string.disabled.asText(), + testTag = "DisabledSendIcon", ), PASSWORD( iconRes = R.drawable.ic_send_password, contentDescription = R.string.password.asText(), + testTag = "PasswordProtectedSendIcon", ), EXPIRED( iconRes = R.drawable.ic_send_expired, contentDescription = R.string.expired.asText(), + testTag = "ExpiredSendIcon", ), MAX_ACCESS_COUNT_REACHED( iconRes = R.drawable.ic_send_max_access_count_reached, contentDescription = R.string.maximum_access_count_reached.asText(), + testTag = "MaxAccessSendIcon", ), PENDING_DELETE( iconRes = R.drawable.ic_send_pending_delete, contentDescription = R.string.pending_delete.asText(), + testTag = "PendingDeletionSendIcon", ), } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensions.kt index ff6e4b8469..4ddcfe2258 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensions.kt @@ -19,7 +19,13 @@ fun SendView.toLabelIcons(clock: Clock = Clock.systemDefaultZone()): List, val overflowOptions: List, + val optionsTestTag: String, val isAutofill: Boolean, val shouldShowMasterPasswordReprompt: Boolean, ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataExtensions.kt index 4ee9e3edfc..d5ae625e3c 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataExtensions.kt @@ -272,13 +272,16 @@ private fun CipherView.toDisplayItem( VaultItemListingState.DisplayItem( id = id.orEmpty(), title = name, + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = this.toIconData( baseIconUrl = baseIconUrl, isIconLoadingDisabled = isIconLoadingDisabled, ), extraIconList = toLabelIcons(), overflowOptions = toOverflowActions(), + optionsTestTag = "CipherOptionsButton", isAutofill = isAutofill, shouldShowMasterPasswordReprompt = reprompt == CipherRepromptType.PASSWORD, ) @@ -308,7 +311,9 @@ private fun SendView.toDisplayItem( VaultItemListingState.DisplayItem( id = id.orEmpty(), title = name, + titleTestTag = "SendNameLabel", subtitle = deletionDate.toFormattedPattern(DELETION_DATE_PATTERN, clock), + subtitleTestTag = "SendDateLabel", iconData = IconData.Local( iconRes = when (type) { SendType.TEXT -> R.drawable.ic_send_text @@ -317,6 +322,7 @@ private fun SendView.toDisplayItem( ), extraIconList = toLabelIcons(clock = clock), overflowOptions = toOverflowActions(baseWebSendUrl = baseWebSendUrl), + optionsTestTag = "SendOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensions.kt index 011088698d..904b796970 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensions.kt @@ -53,6 +53,10 @@ fun CipherView.toLabelIcons(): List { VaultTrailingIcon.ATTACHMENT.takeIf { this.attachments?.isNotEmpty() == true }, ) .map { - IconRes(iconRes = it.iconRes, contentDescription = it.contentDescription) + IconRes( + iconRes = it.iconRes, + contentDescription = it.contentDescription, + testTag = it.testTag, + ) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/model/VaultTrailingIcon.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/model/VaultTrailingIcon.kt index 1ca08b70af..7e6a43caa3 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/model/VaultTrailingIcon.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/model/VaultTrailingIcon.kt @@ -11,13 +11,16 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText enum class VaultTrailingIcon( @DrawableRes val iconRes: Int, val contentDescription: Text, + val testTag: String, ) { COLLECTION( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), ATTACHMENT( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), } diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchUtil.kt b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchUtil.kt index 129877005a..c649c8d7ff 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchUtil.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/platform/feature/search/util/SearchUtil.kt @@ -21,7 +21,9 @@ fun createMockDisplayItemForCipher( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = "mockUsername-$number", + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Network( uri = "https://vault.bitwarden.com/icons/www.mockuri.com/icon.png", fallbackIconRes = R.drawable.ic_login_item, @@ -30,10 +32,12 @@ fun createMockDisplayItemForCipher( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -52,6 +56,7 @@ fun createMockDisplayItemForCipher( url = "www.mockuri$number.com", ), ), + overflowTestTag = "CipherOptionsButton", totpCode = "mockTotp-$number", autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, @@ -62,16 +67,20 @@ fun createMockDisplayItemForCipher( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = null, + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_secure_note_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -81,6 +90,7 @@ fun createMockDisplayItemForCipher( notes = "mockNotes-$number", ), ), + overflowTestTag = "CipherOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, @@ -91,16 +101,20 @@ fun createMockDisplayItemForCipher( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = "mockBrand-$number, *er-$number", + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_card_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -113,6 +127,7 @@ fun createMockDisplayItemForCipher( securityCode = "mockCode-$number", ), ), + overflowTestTag = "CipherOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, @@ -123,22 +138,27 @@ fun createMockDisplayItemForCipher( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = "mockFirstName-${number}mockLastName-$number", + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_identity_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"), ListingItemOverflowAction.VaultAction.EditClick(cipherId = "mockId-$number"), ), + overflowTestTag = "CipherOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, @@ -159,16 +179,20 @@ fun createMockDisplayItemForSend( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "SendNameLabel", subtitle = "Oct 27, 2023, 12:00 PM", + subtitleTestTag = "SendDateLabel", iconData = IconData.Local(R.drawable.ic_send_file), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_send_password, contentDescription = R.string.password.asText(), + testTag = "PasswordProtectedSendIcon", ), IconRes( iconRes = R.drawable.ic_send_max_access_count_reached, contentDescription = R.string.maximum_access_count_reached.asText(), + testTag = "MaxAccessSendIcon", ), ), overflowOptions = listOf( @@ -182,6 +206,7 @@ fun createMockDisplayItemForSend( ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = "mockId-$number"), ListingItemOverflowAction.SendAction.DeleteClick(sendId = "mockId-$number"), ), + overflowTestTag = "SendOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, @@ -192,16 +217,20 @@ fun createMockDisplayItemForSend( SearchState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "SendNameLabel", subtitle = "Oct 27, 2023, 12:00 PM", + subtitleTestTag = "SendDateLabel", iconData = IconData.Local(R.drawable.ic_send_text), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_send_password, contentDescription = R.string.password.asText(), + testTag = "PasswordProtectedSendIcon", ), IconRes( iconRes = R.drawable.ic_send_max_access_count_reached, contentDescription = R.string.maximum_access_count_reached.asText(), + testTag = "MaxAccessSendIcon", ), ), overflowOptions = listOf( @@ -215,6 +244,7 @@ fun createMockDisplayItemForSend( ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = "mockId-$number"), ListingItemOverflowAction.SendAction.DeleteClick(sendId = "mockId-$number"), ), + overflowTestTag = "SendOptionsButton", totpCode = null, autofillSelectionOptions = emptyList(), shouldDisplayMasterPasswordReprompt = false, diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensionsTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensionsTest.kt index 92879e3a18..8309fd0409 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensionsTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/tools/feature/send/util/SendViewExtensionsTest.kt @@ -118,22 +118,27 @@ private val ALL_SEND_STATUS_ICONS: List = listOf( IconRes( iconRes = SendStatusIcon.DISABLED.iconRes, contentDescription = SendStatusIcon.DISABLED.contentDescription, + testTag = SendStatusIcon.DISABLED.testTag, ), IconRes( iconRes = SendStatusIcon.PASSWORD.iconRes, contentDescription = SendStatusIcon.PASSWORD.contentDescription, + testTag = SendStatusIcon.PASSWORD.testTag, ), IconRes( iconRes = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.iconRes, contentDescription = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.contentDescription, + testTag = SendStatusIcon.MAX_ACCESS_COUNT_REACHED.testTag, ), IconRes( iconRes = SendStatusIcon.EXPIRED.iconRes, contentDescription = SendStatusIcon.EXPIRED.contentDescription, + testTag = SendStatusIcon.EXPIRED.testTag, ), IconRes( iconRes = SendStatusIcon.PENDING_DELETE.iconRes, contentDescription = SendStatusIcon.PENDING_DELETE.contentDescription, + testTag = SendStatusIcon.PENDING_DELETE.testTag, ), ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt index be83d2ae4a..f1639212fe 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/VaultItemListingScreenTest.kt @@ -1469,7 +1469,9 @@ private fun createDisplayItem(number: Int): VaultItemListingState.DisplayItem = VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockTitle-$number", + titleTestTag = "SendNameLabel", subtitle = "mockSubtitle-$number", + subtitleTestTag = "SendDateLabel", iconData = IconData.Local(R.drawable.ic_card_item), extraIconList = listOf( IconRes( @@ -1500,6 +1502,7 @@ private fun createDisplayItem(number: Int): VaultItemListingState.DisplayItem = ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = "mockId-$number"), ListingItemOverflowAction.SendAction.DeleteClick(sendId = "mockId-$number"), ), + optionsTestTag = "SendOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -1508,12 +1511,15 @@ private fun createCipherDisplayItem(number: Int): VaultItemListingState.DisplayI VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockTitle-$number", + titleTestTag = "CipherNameLabel", subtitle = "mockSubtitle-$number", + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_vault), extraIconList = emptyList(), overflowOptions = listOf( ListingItemOverflowAction.VaultAction.EditClick(cipherId = "mockId-$number"), ), + optionsTestTag = "CipherOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataUtil.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataUtil.kt index e642a1d096..5e53a3ea86 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataUtil.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/itemlisting/util/VaultItemListingDataUtil.kt @@ -22,7 +22,9 @@ fun createMockDisplayItemForCipher( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Network( "https://vault.bitwarden.com/icons/www.mockuri.com/icon.png", fallbackIconRes = R.drawable.ic_login_item, @@ -31,10 +33,12 @@ fun createMockDisplayItemForCipher( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -53,6 +57,7 @@ fun createMockDisplayItemForCipher( url = "www.mockuri$number.com", ), ), + optionsTestTag = "CipherOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -62,16 +67,20 @@ fun createMockDisplayItemForCipher( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_secure_note_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -81,6 +90,7 @@ fun createMockDisplayItemForCipher( notes = "mockNotes-$number", ), ), + optionsTestTag = "CipherOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -90,16 +100,20 @@ fun createMockDisplayItemForCipher( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_card_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( @@ -112,6 +126,7 @@ fun createMockDisplayItemForCipher( securityCode = "mockCode-$number", ), ), + optionsTestTag = "CipherOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -121,22 +136,27 @@ fun createMockDisplayItemForCipher( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "CipherNameLabel", subtitle = subtitle, + subtitleTestTag = "CipherSubTitleLabel", iconData = IconData.Local(R.drawable.ic_identity_item), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_collection, contentDescription = R.string.collections.asText(), + testTag = "CipherInCollectionIcon", ), IconRes( iconRes = R.drawable.ic_attachment, contentDescription = R.string.attachments.asText(), + testTag = "CipherWithAttachmentsIcon", ), ), overflowOptions = listOf( ListingItemOverflowAction.VaultAction.ViewClick(cipherId = "mockId-$number"), ListingItemOverflowAction.VaultAction.EditClick(cipherId = "mockId-$number"), ), + optionsTestTag = "CipherOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -156,16 +176,20 @@ fun createMockDisplayItemForSend( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "SendNameLabel", subtitle = "Oct 27, 2023, 12:00 PM", + subtitleTestTag = "SendDateLabel", iconData = IconData.Local(R.drawable.ic_send_file), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_send_password, contentDescription = R.string.password.asText(), + testTag = "PasswordProtectedSendIcon", ), IconRes( iconRes = R.drawable.ic_send_max_access_count_reached, contentDescription = R.string.maximum_access_count_reached.asText(), + testTag = "MaxAccessSendIcon", ), ), overflowOptions = listOf( @@ -179,6 +203,7 @@ fun createMockDisplayItemForSend( ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = "mockId-$number"), ListingItemOverflowAction.SendAction.DeleteClick(sendId = "mockId-$number"), ), + optionsTestTag = "SendOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) @@ -188,16 +213,20 @@ fun createMockDisplayItemForSend( VaultItemListingState.DisplayItem( id = "mockId-$number", title = "mockName-$number", + titleTestTag = "SendNameLabel", subtitle = "Oct 27, 2023, 12:00 PM", + subtitleTestTag = "SendDateLabel", iconData = IconData.Local(R.drawable.ic_send_text), extraIconList = listOf( IconRes( iconRes = R.drawable.ic_send_password, contentDescription = R.string.password.asText(), + testTag = "PasswordProtectedSendIcon", ), IconRes( iconRes = R.drawable.ic_send_max_access_count_reached, contentDescription = R.string.maximum_access_count_reached.asText(), + testTag = "MaxAccessSendIcon", ), ), overflowOptions = listOf( @@ -211,6 +240,7 @@ fun createMockDisplayItemForSend( ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = "mockId-$number"), ListingItemOverflowAction.SendAction.DeleteClick(sendId = "mockId-$number"), ), + optionsTestTag = "SendOptionsButton", isAutofill = false, shouldShowMasterPasswordReprompt = false, ) diff --git a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensionsTest.kt b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensionsTest.kt index 1767d9a52b..eb48f65ef8 100644 --- a/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensionsTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/ui/vault/feature/util/CipherViewExtensionsTest.kt @@ -247,7 +247,11 @@ class CipherViewExtensionsTest { ) val expected = listOf(VaultTrailingIcon.COLLECTION).map { - IconRes(iconRes = it.iconRes, contentDescription = it.contentDescription) + IconRes( + iconRes = it.iconRes, + contentDescription = it.contentDescription, + testTag = it.testTag, + ) } val result = cipher.toLabelIcons() @@ -263,7 +267,11 @@ class CipherViewExtensionsTest { ) val expected = listOf(VaultTrailingIcon.COLLECTION).map { - IconRes(iconRes = it.iconRes, contentDescription = it.contentDescription) + IconRes( + iconRes = it.iconRes, + contentDescription = it.contentDescription, + testTag = it.testTag, + ) } val result = cipher.toLabelIcons() @@ -279,7 +287,11 @@ class CipherViewExtensionsTest { ) val expected = listOf(VaultTrailingIcon.ATTACHMENT).map { - IconRes(iconRes = it.iconRes, contentDescription = it.contentDescription) + IconRes( + iconRes = it.iconRes, + contentDescription = it.contentDescription, + testTag = it.testTag, + ) } val result = cipher.toLabelIcons() @@ -295,7 +307,11 @@ class CipherViewExtensionsTest { VaultTrailingIcon.COLLECTION, VaultTrailingIcon.ATTACHMENT, ).map { - IconRes(iconRes = it.iconRes, contentDescription = it.contentDescription) + IconRes( + iconRes = it.iconRes, + contentDescription = it.contentDescription, + testTag = it.testTag, + ) } val result = cipher.toLabelIcons()