diff options
| author | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2024-12-05 16:41:03 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-12-10 09:20:10 +0100 |
| commit | e6227d775b4408103ef483123e454b6ee6cbc096 (patch) | |
| tree | 801677a2d2f59a42bd1786c24e5d0dd88d09e399 | |
| parent | 38919ce212484d621809551a603e95ae27f412e9 (diff) | |
| download | mullvadvpn-e6227d775b4408103ef483123e454b6ee6cbc096.tar.xz mullvadvpn-e6227d775b4408103ef483123e454b6ee6cbc096.zip | |
Remove String conformance of AccessibilityIdentifier
14 files changed, 38 insertions, 31 deletions
diff --git a/ios/MullvadVPN/Classes/AccessbilityIdentifier.swift b/ios/MullvadVPN/Classes/AccessbilityIdentifier.swift index bf013d251c..bb86dd95c1 100644 --- a/ios/MullvadVPN/Classes/AccessbilityIdentifier.swift +++ b/ios/MullvadVPN/Classes/AccessbilityIdentifier.swift @@ -8,7 +8,7 @@ import UIKit -public enum AccessibilityIdentifier: String { +public enum AccessibilityIdentifier: Equatable { // Buttons case addAccessMethodButton case accessMethodAddButton @@ -214,8 +214,14 @@ public enum AccessibilityIdentifier: String { case unknown } +extension AccessibilityIdentifier: CustomStringConvertible { + public var description: String { + "\(self)" + } +} + extension UIAccessibilityIdentification { func setAccessibilityIdentifier(_ value: AccessibilityIdentifier?) { - accessibilityIdentifier = value.map { "\($0)" } + accessibilityIdentifier = value.map(\.description) } } diff --git a/ios/MullvadVPN/Coordinators/Settings/SettingsViewControllerFactory.swift b/ios/MullvadVPN/Coordinators/Settings/SettingsViewControllerFactory.swift index cf14003b64..f93ebba2dc 100644 --- a/ios/MullvadVPN/Coordinators/Settings/SettingsViewControllerFactory.swift +++ b/ios/MullvadVPN/Coordinators/Settings/SettingsViewControllerFactory.swift @@ -103,7 +103,7 @@ struct SettingsViewControllerFactory { value: "Multihop", comment: "" ) - host.view.accessibilityIdentifier = AccessibilityIdentifier.multihopView.rawValue + host.view.setAccessibilityIdentifier(.multihopView) return .viewController(host) } @@ -129,7 +129,7 @@ struct SettingsViewControllerFactory { value: "DAITA", comment: "" ) - host.view.accessibilityIdentifier = AccessibilityIdentifier.daitaView.rawValue + host.view.setAccessibilityIdentifier(.daitaView) return .viewController(host) } diff --git a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift index bf6445c021..b6f4843fd4 100644 --- a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift +++ b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift @@ -375,10 +375,10 @@ class AccountDeletionContentView: UIView { } @objc private func didPress(button: AppButton) { - switch AccessibilityIdentifier(rawValue: button.accessibilityIdentifier ?? "") { - case .deleteButton: + switch button.accessibilityIdentifier { + case AccessibilityIdentifier.deleteButton.description: delegate?.didTapDeleteButton(contentView: self, button: button) - case .cancelButton: + case AccessibilityIdentifier.cancelButton.description: delegate?.didTapCancelButton(contentView: self, button: button) default: return } diff --git a/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift b/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift index 2cb35fec16..1562d6ecf7 100644 --- a/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift +++ b/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift @@ -141,10 +141,10 @@ class SetupAccountCompletedContentView: UIView { } @objc private func tapped(button: AppButton) { - switch AccessibilityIdentifier(rawValue: button.accessibilityIdentifier ?? "") { - case .learnAboutPrivacyButton: + switch button.accessibilityIdentifier { + case AccessibilityIdentifier.learnAboutPrivacyButton.description: delegate?.didTapPrivacyButton(view: self, button: button) - case .startUsingTheAppButton: + case AccessibilityIdentifier.startUsingTheAppButton.description: delegate?.didTapStartingAppButton(view: self, button: button) default: return } diff --git a/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift b/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift index ba89ae2875..425d3b3eb9 100644 --- a/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift +++ b/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift @@ -250,12 +250,12 @@ final class WelcomeContentView: UIView { } @objc private func tapped(button: AppButton) { - switch AccessibilityIdentifier(rawValue: button.accessibilityIdentifier ?? "") { - case .purchaseButton: + switch button.accessibilityIdentifier { + case AccessibilityIdentifier.purchaseButton.description: delegate?.didTapPurchaseButton(welcomeContentView: self, button: button) - case .redeemVoucherButton: + case AccessibilityIdentifier.redeemVoucherButton.description: delegate?.didTapRedeemVoucherButton(welcomeContentView: self, button: button) - case .infoButton: + case AccessibilityIdentifier.infoButton.description: delegate?.didTapInfoButton(welcomeContentView: self, button: button) default: return } diff --git a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsCellFactory.swift b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsCellFactory.swift index 26499008c8..3e7733a105 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsCellFactory.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsCellFactory.swift @@ -80,7 +80,8 @@ final class VPNSettingsCellFactory: CellFactoryProtocol { } cell.titleLabel.text = portString - cell.accessibilityIdentifier = "\(item.accessibilityIdentifier.rawValue) (\(portString))" + // TODO: replace this with a tagged AccessibilityIdentifier + cell.accessibilityIdentifier = "\(item.accessibilityIdentifier.description) (\(portString))" cell.applySubCellStyling() case .wireGuardCustomPort: diff --git a/ios/MullvadVPN/Views/CustomToggleStyle.swift b/ios/MullvadVPN/Views/CustomToggleStyle.swift index e114d17adc..e968a921f3 100644 --- a/ios/MullvadVPN/Views/CustomToggleStyle.swift +++ b/ios/MullvadVPN/Views/CustomToggleStyle.swift @@ -56,7 +56,7 @@ struct CustomToggleStyle: ToggleStyle { ) .opacity(disabled ? 0.4 : 1) } - .accessibilityIdentifier(accessibilityId?.rawValue ?? "") + .accessibilityIdentifier(accessibilityId?.description ?? "") .onTapGesture { toggle(configuration) } diff --git a/ios/MullvadVPNUITests/Base/BaseUITestCase.swift b/ios/MullvadVPNUITests/Base/BaseUITestCase.swift index e7ef66f0fd..e8ed5e5042 100644 --- a/ios/MullvadVPNUITests/Base/BaseUITestCase.swift +++ b/ios/MullvadVPNUITests/Base/BaseUITestCase.swift @@ -248,7 +248,7 @@ class BaseUITestCase: XCTestCase { // Ensure changelog is no longer shown _ = app - .otherElements[AccessibilityIdentifier.changeLogAlert.rawValue] + .otherElements[AccessibilityIdentifier.changeLogAlert.description] .waitForNonExistence(timeout: Self.shortTimeout) } diff --git a/ios/MullvadVPNUITests/ConnectivityTests.swift b/ios/MullvadVPNUITests/ConnectivityTests.swift index 6b66a2d514..673a8dc2db 100644 --- a/ios/MullvadVPNUITests/ConnectivityTests.swift +++ b/ios/MullvadVPNUITests/ConnectivityTests.swift @@ -67,7 +67,7 @@ class ConnectivityTests: LoggedOutUITestCase { .tapSelectLocationButton() let filterCloseButtons = self.app.buttons - .matching(identifier: AccessibilityIdentifier.relayFilterChipCloseButton.rawValue) + .matching(identifier: AccessibilityIdentifier.relayFilterChipCloseButton.description) .allElementsBoundByIndex for filterCloseButton in filterCloseButtons where filterCloseButton.isHittable { diff --git a/ios/MullvadVPNUITests/Pages/AccountPage.swift b/ios/MullvadVPNUITests/Pages/AccountPage.swift index fd3d5d448e..9d8326983f 100644 --- a/ios/MullvadVPNUITests/Pages/AccountPage.swift +++ b/ios/MullvadVPNUITests/Pages/AccountPage.swift @@ -18,27 +18,27 @@ class AccountPage: Page { } @discardableResult func tapRedeemVoucherButton() -> Self { - app.buttons[AccessibilityIdentifier.redeemVoucherButton.rawValue].tap() + app.buttons[AccessibilityIdentifier.redeemVoucherButton.description].tap() return self } @discardableResult func tapAdd30DaysTimeButton() -> Self { - app.buttons[AccessibilityIdentifier.purchaseButton.rawValue].tap() + app.buttons[AccessibilityIdentifier.purchaseButton.description].tap() return self } @discardableResult func tapRestorePurchasesButton() -> Self { - app.buttons[AccessibilityIdentifier.restorePurchasesButton.rawValue].tap() + app.buttons[AccessibilityIdentifier.restorePurchasesButton.description].tap() return self } @discardableResult func tapLogOutButton() -> Self { - app.buttons[AccessibilityIdentifier.logoutButton.rawValue].tap() + app.buttons[AccessibilityIdentifier.logoutButton.description].tap() return self } @discardableResult func tapDeleteAccountButton() -> Self { - app.buttons[AccessibilityIdentifier.deleteButton.rawValue].tap() + app.buttons[AccessibilityIdentifier.deleteButton.description].tap() return self } diff --git a/ios/MullvadVPNUITests/Pages/DeviceManagementPage.swift b/ios/MullvadVPNUITests/Pages/DeviceManagementPage.swift index 68340a260f..9b24b1276c 100644 --- a/ios/MullvadVPNUITests/Pages/DeviceManagementPage.swift +++ b/ios/MullvadVPNUITests/Pages/DeviceManagementPage.swift @@ -19,7 +19,7 @@ class DeviceManagementPage: Page { @discardableResult func tapRemoveDeviceButton(cellIndex: Int) -> Self { app - .otherElements.matching(identifier: AccessibilityIdentifier.deviceCell.rawValue).element(boundBy: cellIndex) + .otherElements.matching(identifier: AccessibilityIdentifier.deviceCell.description).element(boundBy: cellIndex) .buttons[AccessibilityIdentifier.deviceCellRemoveButton] .tap() diff --git a/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift b/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift index db401a0305..5c6498487d 100644 --- a/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift +++ b/ios/MullvadVPNUITests/Pages/SelectLocationPage.swift @@ -30,7 +30,7 @@ class SelectLocationPage: Page { } @discardableResult func tapCountryLocationCellExpandButton(withIndex: Int) -> Self { - let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.countryLocationCell.rawValue) + let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.countryLocationCell.description) .element(boundBy: withIndex) let expandButton = cell.buttons[AccessibilityIdentifier.expandButton] expandButton.tap() @@ -38,7 +38,7 @@ class SelectLocationPage: Page { } @discardableResult func tapCityLocationCellExpandButton(withIndex: Int) -> Self { - let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.cityLocationCell.rawValue) + let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.cityLocationCell.description) .element(boundBy: withIndex) let expandButton = cell.buttons[AccessibilityIdentifier.expandButton] expandButton.tap() @@ -46,7 +46,7 @@ class SelectLocationPage: Page { } @discardableResult func tapRelayLocationCell(withIndex: Int) -> Self { - let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.relayLocationCell.rawValue) + let cell = app.cells.containing(.any, identifier: AccessibilityIdentifier.relayLocationCell.description) .element(boundBy: withIndex) cell.tap() return self @@ -79,7 +79,7 @@ class SelectLocationPage: Page { _ = app.buttons[.openCustomListsMenuButton].waitForExistence(timeout: BaseUITestCase.shortTimeout) let customListEllipsisButtons = app.buttons - .matching(identifier: AccessibilityIdentifier.openCustomListsMenuButton.rawValue).allElementsBoundByIndex + .matching(identifier: AccessibilityIdentifier.openCustomListsMenuButton.description).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 diff --git a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift index c47897c41b..83999ab7b1 100644 --- a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift +++ b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift @@ -19,8 +19,8 @@ class VPNSettingsPage: Page { _ subButtonAccessibilityIdentifier: AccessibilityIdentifier ) -> XCUIElement { let tableView = app.tables[AccessibilityIdentifier.vpnSettingsTableView] - let matchingCells = tableView.otherElements[cellAccessiblityIdentifier.rawValue] - let expandButton = matchingCells.buttons[subButtonAccessibilityIdentifier] + let matchingCells = tableView.otherElements[cellAccessiblityIdentifier.description] + let expandButton = matchingCells.buttons[AccessibilityIdentifier.expandButton] let lastCell = tableView.cells.allElementsBoundByIndex.last! tableView.scrollDownToElement(element: lastCell) return expandButton diff --git a/ios/MullvadVPNUITests/XCUIElementQuery+Extensions.swift b/ios/MullvadVPNUITests/XCUIElementQuery+Extensions.swift index 509ec7d0da..3b70e275c6 100644 --- a/ios/MullvadVPNUITests/XCUIElementQuery+Extensions.swift +++ b/ios/MullvadVPNUITests/XCUIElementQuery+Extensions.swift @@ -15,6 +15,6 @@ extension XCUIElementQuery { } subscript(key: AccessibilityIdentifier) -> XCUIElement { - self[key.rawValue] + self[key.description] } } |
