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
41 changes: 29 additions & 12 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,7 @@
///
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 @@ -16,10 +16,10 @@
/// of the `CipherView` to be displayed when needed (Optional).
///
case cipher(CipherView, Fido2CredentialAutofillView? = nil)

/// The wrapped item is a group of items.
case group(VaultListGroup, Int)

/// A TOTP Code Item.
///
/// - Parameters
Expand All @@ -28,12 +28,12 @@
///
case totp(name: String, totpModel: VaultListTOTP)
}

// MARK: Properties

/// The identifier for the item.
public let id: String

/// The type of item being displayed by this item.
public let itemType: ItemType
}
Expand All @@ -56,7 +56,7 @@
guard let id = cipherView.id else { return nil }
self.init(id: id, itemType: .cipher(cipherView))
}

/// Initialize a `VaultListItem` from a `CipherView`.
/// - Parameters:
/// - cipherView: The `CipherView` used to initialize the `VaultListItem`.
Expand All @@ -79,7 +79,7 @@
nil
}
}

/// An image asset for this item that can be used in the UI.
var icon: ImageAsset {
switch itemType {
Expand All @@ -103,7 +103,7 @@
case .collection:
Asset.Images.collections24
case .folder,
.noFolder:
.noFolder:
Asset.Images.folder24
case .identity:
Asset.Images.idCard24
Expand All @@ -122,7 +122,7 @@
Asset.Images.clock24
}
}

/// The accessibility ID for the ciphers icon.
var iconAccessibilityId: String {
switch itemType {
Expand All @@ -143,7 +143,24 @@
return ""
}
}


var vaultItemAccessibilityId: String {
switch itemType {
case let .group(vaultListGroup, _):
if vaultListGroup.isFolder {
return "FolderCell"

Check warning on line 151 in BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift

View check run for this annotation

Codecov / codecov/patch

BitwardenShared/UI/Vault/Vault/VaultList/VaultListItem.swift#L151

Added line #L151 was not covered by tests
} else if vaultListGroup.collectionId != nil {
return "CollectionCell"
} else {
return "ItemFilterCell"
}
case .cipher:
return "CipherCell"
case .totp:
return "TOTPCell"
}
}
ifernandezdiaz marked this conversation as resolved.
Show resolved Hide resolved

/// 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 +172,7 @@
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 @@ -141,7 +141,6 @@ private struct SearchableVaultListView: View {
)
.background(Asset.Colors.backgroundSecondary.swiftUIColor)
}
.accessibilityIdentifier("CipherCell")
}
}
}
Expand Down Expand Up @@ -188,7 +187,7 @@ private struct SearchableVaultListView: View {
private var vaultFilterRow: some View {
SearchVaultFilterRowView(
hasDivider: false,
accessibilityID: "ActiveFilterRow",
accessibilityID: "ActiveFilterName",
ifernandezdiaz marked this conversation as resolved.
Show resolved Hide resolved
store: store.child(
state: \.vaultFilterState,
mapAction: { action in
Expand Down Expand Up @@ -265,7 +264,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 @@ -73,7 +73,7 @@ struct VaultListItemRowView: View {
.accessibilityIdentifier("CipherSubTitleLabel")
}
}
.accessibilityElement(children: .combine)
ifernandezdiaz marked this conversation as resolved.
Show resolved Hide resolved


Spacer()

Expand All @@ -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 @@ -25,7 +25,6 @@ struct VaultListSectionView<Content: View>: View {
SectionHeaderView(String(section.items.count))
}
}
.accessibilityElement(children: .combine)
ifernandezdiaz marked this conversation as resolved.
Show resolved Hide resolved

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