Skip to content

Commit

Permalink
Replace circular .description definition with .asString
Browse files Browse the repository at this point in the history
  • Loading branch information
acb-mv committed Dec 6, 2024
1 parent 853e883 commit a3ac449
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ public enum AccessibilityIdentifier: Equatable {
case unknown
}

extension AccessibilityIdentifier: CustomStringConvertible {
public var description: String {
extension AccessibilityIdentifier {
public var asString: String {
"\(self)"
}
}

extension UIAccessibilityIdentification {
func setAccessibilityIdentifier(_ value: AccessibilityIdentifier?) {
accessibilityIdentifier = value.map(\.description)
accessibilityIdentifier = value.map(\.asString)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ class AccountDeletionContentView: UIView {

@objc private func didPress(button: AppButton) {
switch button.accessibilityIdentifier {
case AccessibilityIdentifier.deleteButton.description:
case AccessibilityIdentifier.deleteButton.asString:
delegate?.didTapDeleteButton(contentView: self, button: button)
case AccessibilityIdentifier.cancelButton.description:
case AccessibilityIdentifier.cancelButton.asString:
delegate?.didTapCancelButton(contentView: self, button: button)
default: return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class SetupAccountCompletedContentView: UIView {

@objc private func tapped(button: AppButton) {
switch button.accessibilityIdentifier {
case AccessibilityIdentifier.learnAboutPrivacyButton.description:
case AccessibilityIdentifier.learnAboutPrivacyButton.asString:
delegate?.didTapPrivacyButton(view: self, button: button)
case AccessibilityIdentifier.startUsingTheAppButton.description:
case AccessibilityIdentifier.startUsingTheAppButton.asString:
delegate?.didTapStartingAppButton(view: self, button: button)
default: return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ final class WelcomeContentView: UIView {

@objc private func tapped(button: AppButton) {
switch button.accessibilityIdentifier {
case AccessibilityIdentifier.purchaseButton.description:
case AccessibilityIdentifier.purchaseButton.asString:
delegate?.didTapPurchaseButton(welcomeContentView: self, button: button)
case AccessibilityIdentifier.redeemVoucherButton.description:
case AccessibilityIdentifier.redeemVoucherButton.asString:
delegate?.didTapRedeemVoucherButton(welcomeContentView: self, button: button)
case AccessibilityIdentifier.infoButton.description:
case AccessibilityIdentifier.infoButton.asString:
delegate?.didTapInfoButton(welcomeContentView: self, button: button)
default: return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class VPNSettingsCellFactory: CellFactoryProtocol {

cell.titleLabel.text = portString
// TODO: replace this with a tagged AccessibilityIdentifier
cell.accessibilityIdentifier = "\(item.accessibilityIdentifier.description) (\(portString))"
cell.accessibilityIdentifier = "\(item.accessibilityIdentifier.asString) (\(portString))"
cell.applySubCellStyling()

case .wireGuardCustomPort:
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Views/CustomToggleStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct CustomToggleStyle: ToggleStyle {
)
.opacity(disabled ? 0.4 : 1)
}
.accessibilityIdentifier(accessibilityId?.description ?? "")
.accessibilityIdentifier(accessibilityId?.asString ?? "")
.onTapGesture {
toggle(configuration)
}
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/Base/BaseUITestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class BaseUITestCase: XCTestCase {

// Ensure changelog is no longer shown
_ = app
.otherElements[AccessibilityIdentifier.changeLogAlert.description]
.otherElements[AccessibilityIdentifier.changeLogAlert.asString]
.waitForNonExistence(timeout: Self.shortTimeout)
}

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/ConnectivityTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ConnectivityTests: LoggedOutUITestCase {
.tapSelectLocationButton()

let filterCloseButtons = self.app.buttons
.matching(identifier: AccessibilityIdentifier.relayFilterChipCloseButton.description)
.matching(identifier: AccessibilityIdentifier.relayFilterChipCloseButton.asString)
.allElementsBoundByIndex

for filterCloseButton in filterCloseButtons where filterCloseButton.isHittable {
Expand Down
10 changes: 5 additions & 5 deletions ios/MullvadVPNUITests/Pages/AccountPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ class AccountPage: Page {
}

@discardableResult func tapRedeemVoucherButton() -> Self {
app.buttons[AccessibilityIdentifier.redeemVoucherButton.description].tap()
app.buttons[AccessibilityIdentifier.redeemVoucherButton.asString].tap()
return self
}

@discardableResult func tapAdd30DaysTimeButton() -> Self {
app.buttons[AccessibilityIdentifier.purchaseButton.description].tap()
app.buttons[AccessibilityIdentifier.purchaseButton.asString].tap()
return self
}

@discardableResult func tapRestorePurchasesButton() -> Self {
app.buttons[AccessibilityIdentifier.restorePurchasesButton.description].tap()
app.buttons[AccessibilityIdentifier.restorePurchasesButton.asString].tap()
return self
}

@discardableResult func tapLogOutButton() -> Self {
app.buttons[AccessibilityIdentifier.logoutButton.description].tap()
app.buttons[AccessibilityIdentifier.logoutButton.asString].tap()
return self
}

@discardableResult func tapDeleteAccountButton() -> Self {
app.buttons[AccessibilityIdentifier.deleteButton.description].tap()
app.buttons[AccessibilityIdentifier.deleteButton.asString].tap()
return self
}

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/Pages/DeviceManagementPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DeviceManagementPage: Page {

@discardableResult func tapRemoveDeviceButton(cellIndex: Int) -> Self {
app
.otherElements.matching(identifier: AccessibilityIdentifier.deviceCell.description).element(boundBy: cellIndex)
.otherElements.matching(identifier: AccessibilityIdentifier.deviceCell.asString).element(boundBy: cellIndex)
.buttons[AccessibilityIdentifier.deviceCellRemoveButton]
.tap()

Expand Down
8 changes: 4 additions & 4 deletions ios/MullvadVPNUITests/Pages/SelectLocationPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ class SelectLocationPage: Page {
}

@discardableResult func tapCountryLocationCellExpandButton(withIndex: Int) -> Self {
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.countryLocationCell.description)
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.countryLocationCell.asString)
.element(boundBy: withIndex)
let expandButton = cell.buttons[AccessibilityIdentifier.expandButton]
expandButton.tap()
return self
}

@discardableResult func tapCityLocationCellExpandButton(withIndex: Int) -> Self {
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.cityLocationCell.description)
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.cityLocationCell.asString)
.element(boundBy: withIndex)
let expandButton = cell.buttons[AccessibilityIdentifier.expandButton]
expandButton.tap()
return self
}

@discardableResult func tapRelayLocationCell(withIndex: Int) -> Self {
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.relayLocationCell.description)
let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.relayLocationCell.asString)
.element(boundBy: withIndex)
cell.tap()
return self
Expand Down Expand Up @@ -79,7 +79,7 @@ class SelectLocationPage: Page {
_ = app.buttons[.openCustomListsMenuButton].waitForExistence(timeout: BaseUITestCase.shortTimeout)

let customListEllipsisButtons = app.buttons
.matching(identifier: AccessibilityIdentifier.openCustomListsMenuButton.description).allElementsBoundByIndex
.matching(identifier: AccessibilityIdentifier.openCustomListsMenuButton.asString).allElementsBoundByIndex

// This is a workaround for an issue we have with the ellipsis showing up multiple times in the accessibility hieararchy even though in the view hierarchy there is only one
// Only the actually visual one is hittable, so only the visible button will be tapped
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class VPNSettingsPage: Page {
_ subButtonAccessibilityIdentifier: AccessibilityIdentifier
) -> XCUIElement {
let tableView = app.tables[AccessibilityIdentifier.vpnSettingsTableView]
let matchingCells = tableView.otherElements[cellAccessiblityIdentifier.description]
let matchingCells = tableView.otherElements[cellAccessiblityIdentifier.asString]
let expandButton = matchingCells.buttons[AccessibilityIdentifier.expandButton]
let lastCell = tableView.cells.allElementsBoundByIndex.last!
tableView.scrollDownToElement(element: lastCell)
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/XCUIElementQuery+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ extension XCUIElementQuery {
}

subscript(key: AccessibilityIdentifier) -> XCUIElement {
self[key.description]
self[key.asString]
}
}

0 comments on commit a3ac449

Please sign in to comment.