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
21 changes: 11 additions & 10 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 @@ -15,10 +15,10 @@ public struct VaultListItem: Equatable, Identifiable, Sendable, VaultItemWithDec
/// 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 @@ -29,10 +29,10 @@ public struct VaultListItem: Equatable, Identifiable, Sendable, VaultItemWithDec
}

// 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 @@ -55,7 +55,7 @@ extension VaultListItem {
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 @@ -78,7 +78,7 @@ extension VaultListItem {
nil
}
}

/// An image asset for this item that can be used in the UI.
var icon: ImageAsset {
switch itemType {
Expand Down Expand Up @@ -121,7 +121,7 @@ extension VaultListItem {
Asset.Images.clock24
}
}

/// The accessibility ID for the ciphers icon.
var iconAccessibilityId: String {
switch itemType {
Expand All @@ -142,8 +142,8 @@ extension VaultListItem {
return ""
}
}
/// The accessibility ID for each vault item .

/// The accessibility ID for each vault item.
var vaultItemAccessibilityId: String {
switch itemType {
case let .group(vaultListGroup, _):
Expand All @@ -160,7 +160,8 @@ extension VaultListItem {
return "TOTPCell"
}
}



/// The login view containing the uri's to download the special decorative icon, if applicable.
var loginView: BitwardenSdk.LoginView? {
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
Loading