diff --git a/BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListView.swift b/BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListView.swift index adcaf1159..c1ce7739c 100644 --- a/BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListView.swift +++ b/BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListView.swift @@ -192,7 +192,6 @@ private struct VaultAutofillListSearchableView: View { ), timeProvider: timeProvider ) - .accessibilityIdentifier("CipherCell") } /// The content displayed in the view. diff --git a/BitwardenShared/UI/Vault/Vault/VaultItemSelection/VaultItemSelectionView.swift b/BitwardenShared/UI/Vault/Vault/VaultItemSelection/VaultItemSelectionView.swift index de7e6ddb7..1bef289f4 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultItemSelection/VaultItemSelectionView.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultItemSelection/VaultItemSelectionView.swift @@ -238,7 +238,6 @@ private struct VaultItemSelectionSearchableView: View { ), timeProvider: CurrentTime() ) - .accessibilityIdentifier("CipherCell") } } } diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/SearchVaultFilterRowView/SearchVaultFilterRowView.swift b/BitwardenShared/UI/Vault/Vault/VaultList/SearchVaultFilterRowView/SearchVaultFilterRowView.swift index 2f102a73f..5077ad5a6 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/SearchVaultFilterRowView/SearchVaultFilterRowView.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/SearchVaultFilterRowView/SearchVaultFilterRowView.swift @@ -23,6 +23,7 @@ struct SearchVaultFilterRowView: View { Text(store.state.searchVaultFilterType.filterTitle) .foregroundStyle(Asset.Colors.textPrimary.swiftUIColor) .styleGuide(.body) + .accessibilityIdentifier("ActiveFilterNameLabel") Spacer() @@ -44,14 +45,13 @@ struct SearchVaultFilterRowView: View { .frame(width: 44, height: 44, alignment: .trailing) .contentShape(Rectangle()) } - .accessibilityIdentifier("OpenOrgFilter") .accessibilityLabel(Localizations.filterByVault) + .accessibilityIdentifier("ActiveFilterRow") .foregroundColor(Asset.Colors.textSecondary.swiftUIColor) } .padding(.horizontal, 16) .padding(.vertical, 9) .frame(minHeight: 60) - .accessibilityIdentifier(accessibilityID ?? "") .background(Asset.Colors.backgroundSecondary.swiftUIColor) if hasDivider { diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift index fd9e3b105..32667aa1c 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift @@ -5,7 +5,6 @@ import Foundation /// public struct VaultListItem: Equatable, Identifiable, Sendable, VaultItemWithDecorativeIcon { // MARK: Types - /// An enumeration for the type of item being displayed by this item. public enum ItemType: Equatable, Sendable { /// The wrapped item is a cipher. @@ -28,7 +27,7 @@ public struct VaultListItem: Equatable, Identifiable, Sendable, VaultItemWithDec /// case totp(name: String, totpModel: VaultListTOTP) } - + // MARK: Properties /// The identifier for the item. @@ -103,7 +102,7 @@ extension VaultListItem { case .collection: Asset.Images.collections24 case .folder, - .noFolder: + .noFolder: Asset.Images.folder24 case .identity: Asset.Images.idCard24 @@ -144,6 +143,25 @@ extension VaultListItem { } } + /// The accessibility ID for each vault item. + var vaultItemAccessibilityId: String { + switch itemType { + case let .group(vaultListGroup, _): + if vaultListGroup.isFolder { + return "FolderCell" + } + if vaultListGroup.collectionId != nil { + return "CollectionCell" + } + return "ItemFilterCell" + case .cipher: + return "CipherCell" + case .totp: + return "TOTPCell" + } + } + + /// The login view containing the uri's to download the special decorative icon, if applicable. var loginView: BitwardenSdk.LoginView? { switch itemType { @@ -155,7 +173,7 @@ extension VaultListItem { totpModel.loginView } } - + /// Whether to show or not the Fido2 credential RpId var shouldShowFido2CredentialRpId: Bool { switch itemType { diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItemTests.swift b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItemTests.swift index cbf894fd6..3800ab5df 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItemTests.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListItemTests.swift @@ -235,6 +235,73 @@ class VaultListItemTests: BitwardenTestCase { // swiftlint:disable:this type_bod ) } + /// `getter:vaultItemAccessibilityId` gets the appropriate id for each vault item. + func test_vaultItemAccessibilityId() { // swiftlint:disable:this function_body_length + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .login))?.vaultItemAccessibilityId, + "CipherCell" + ) + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .card))?.vaultItemAccessibilityId, + "CipherCell" + ) + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .identity))?.vaultItemAccessibilityId, + "CipherCell" + ) + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .secureNote))?.vaultItemAccessibilityId, + "CipherCell" + ) + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .sshKey))?.vaultItemAccessibilityId, + "CipherCell" + ) + XCTAssertEqual( + VaultListItem(cipherView: .fixture(type: .sshKey))?.vaultItemAccessibilityId, + "CipherCell" + ) + + XCTAssertEqual( + VaultListItem.fixtureTOTP(totp: .fixture()).vaultItemAccessibilityId, + "TOTPCell" + ) + + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.collection(id: "", name: "", organizationId: "1"), 1)) + .vaultItemAccessibilityId, + "CollectionCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.folder(id: "", name: ""), 1)).vaultItemAccessibilityId, + "FolderCell" + ) + + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.login, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.card, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.identity, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.secureNote, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.sshKey, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + XCTAssertEqual( + VaultListItem(id: "", itemType: .group(.totp, 1)).vaultItemAccessibilityId, + "ItemFilterCell" + ) + } /// `name` returns the expected value. func test_name() { XCTAssertEqual(subject.name, "") diff --git a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListView.swift b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListView.swift index 57319dd3e..2625eee56 100644 --- a/BitwardenShared/UI/Vault/Vault/VaultList/VaultListView.swift +++ b/BitwardenShared/UI/Vault/Vault/VaultList/VaultListView.swift @@ -141,7 +141,6 @@ private struct SearchableVaultListView: View { ) .background(Asset.Colors.backgroundSecondary.swiftUIColor) } - .accessibilityIdentifier("CipherCell") } } } @@ -188,7 +187,6 @@ private struct SearchableVaultListView: View { private var vaultFilterRow: some View { SearchVaultFilterRowView( hasDivider: false, - accessibilityID: "ActiveFilterRow", store: store.child( state: \.vaultFilterState, mapAction: { action in @@ -265,7 +263,6 @@ private struct SearchableVaultListView: View { ), timeProvider: timeProvider ) - .accessibilityIdentifier("CipherCell") } } diff --git a/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewItemDetailsView.swift b/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewItemDetailsView.swift index fe731bde8..7420d0588 100644 --- a/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewItemDetailsView.swift +++ b/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewItemDetailsView.swift @@ -140,7 +140,6 @@ struct ViewItemDetailsView: View { // swiftlint:disable:this type_body_length SectionView(Localizations.itemInformation, contentSpacing: 12) { BitwardenTextValueField(title: Localizations.name, value: store.state.name) .accessibilityElement(children: .contain) - .accessibilityIdentifier("ItemRow") // check for type switch store.state.type { diff --git a/BitwardenShared/UI/Vault/Views/VaultListItemRow/VaultListItemRowView.swift b/BitwardenShared/UI/Vault/Views/VaultListItemRow/VaultListItemRowView.swift index 1f6b330c0..19e3b59cc 100644 --- a/BitwardenShared/UI/Vault/Views/VaultListItemRow/VaultListItemRowView.swift +++ b/BitwardenShared/UI/Vault/Views/VaultListItemRow/VaultListItemRowView.swift @@ -92,10 +92,12 @@ struct VaultListItemRowView: View { Text(group.name) .styleGuide(.body) .foregroundColor(Asset.Colors.textPrimary.swiftUIColor) + .accessibilityIdentifier("GroupNameLabel") Spacer() Text("\(count)") .styleGuide(.body) .foregroundColor(Asset.Colors.textSecondary.swiftUIColor) + .accessibilityIdentifier("GroupCountLabel") case let .totp(name, model): totpCodeRow(name, model) @@ -111,6 +113,8 @@ struct VaultListItemRowView: View { .padding(.leading, 22 + 16 + 16) } } + .accessibilityElement(children: .combine) + .accessibilityIdentifier(store.state.item.vaultItemAccessibilityId) } // MARK: - Private Views diff --git a/BitwardenShared/UI/Vault/Views/VaultListSectionView.swift b/BitwardenShared/UI/Vault/Views/VaultListSectionView.swift index 2548a5fb8..255fc8556 100644 --- a/BitwardenShared/UI/Vault/Views/VaultListSectionView.swift +++ b/BitwardenShared/UI/Vault/Views/VaultListSectionView.swift @@ -26,7 +26,7 @@ struct VaultListSectionView: View { } } .accessibilityElement(children: .combine) - + LazyVStack(alignment: .leading, spacing: 0) { ForEach(section.items) { item in itemContent(item)