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

[QA-967] Adding missing IDs for Vault page elements #1252

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ private struct VaultAutofillListSearchableView: View {
),
timeProvider: timeProvider
)
.accessibilityIdentifier("CipherCell")
}

/// The content displayed in the view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ private struct VaultItemSelectionSearchableView: View {
),
timeProvider: CurrentTime()
)
.accessibilityIdentifier("CipherCell")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct SearchVaultFilterRowView: View {
Text(store.state.searchVaultFilterType.filterTitle)
.foregroundStyle(Asset.Colors.textPrimary.swiftUIColor)
.styleGuide(.body)
.accessibilityIdentifier("ActiveFilterNameLabel")

Spacer()

Expand All @@ -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 {
Expand Down
26 changes: 22 additions & 4 deletions BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ›๏ธ Remove all unneeded spaces added in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird because the extra spaces we saw on Github are not there when checking the file on XCode ๐Ÿ‘€

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xcode doesn't remove trailing whitespace by default, but you can change that here:
Screenshot 2025-01-10 at 2 01 52โ€ฏPM

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,7 +27,7 @@ public struct VaultListItem: Equatable, Identifiable, Sendable, VaultItemWithDec
///
case totp(name: String, totpModel: VaultListTOTP)
}

// MARK: Properties

/// The identifier for the item.
Expand Down Expand Up @@ -103,7 +102,7 @@ extension VaultListItem {
case .collection:
Asset.Images.collections24
case .folder,
.noFolder:
.noFolder:
Asset.Images.folder24
case .identity:
Asset.Images.idCard24
Expand Down Expand Up @@ -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 {
Expand All @@ -155,7 +173,7 @@ extension VaultListItem {
totpModel.loginView
}
}

/// Whether to show or not the Fido2 credential RpId
var shouldShowFido2CredentialRpId: Bool {
switch itemType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Comment on lines +256 to +263
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ›๏ธ Repeated code.


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, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ private struct SearchableVaultListView: View {
)
.background(Asset.Colors.backgroundSecondary.swiftUIColor)
}
.accessibilityIdentifier("CipherCell")
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -265,7 +263,6 @@ private struct SearchableVaultListView: View {
),
timeProvider: timeProvider
)
.accessibilityIdentifier("CipherCell")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -111,6 +113,8 @@ struct VaultListItemRowView: View {
.padding(.leading, 22 + 16 + 16)
}
}
.accessibilityElement(children: .combine)
.accessibilityIdentifier(store.state.item.vaultItemAccessibilityId)
}

// MARK: - Private Views
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct VaultListSectionView<Content: View>: View {
}
}
.accessibilityElement(children: .combine)
ifernandezdiaz marked this conversation as resolved.
Show resolved Hide resolved

LazyVStack(alignment: .leading, spacing: 0) {
ForEach(section.items) { item in
itemContent(item)
Expand Down
Loading