Skip to content

Commit

Permalink
Merge branch 'write-test-that-makes-sure-connecting-works-without-the…
Browse files Browse the repository at this point in the history
…-api-ios-463'
  • Loading branch information
pinkisemils committed May 13, 2024
2 parents 4380b7a + abed837 commit 53364a8
Show file tree
Hide file tree
Showing 24 changed files with 401 additions and 34 deletions.
24 changes: 19 additions & 5 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@
852BC6702BAB44F500A47558 /* MullvadVPNUITestsChangeSettings.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 852BC66D2BAB44F500A47558 /* MullvadVPNUITestsChangeSettings.xctestplan */; };
852BC6712BAB44F500A47558 /* MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 852BC66E2BAB44F500A47558 /* MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan */; };
852BC6732BAB450B00A47558 /* MullvadVPNUITestsChangeDNSSettings.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 852BC6722BAB450B00A47558 /* MullvadVPNUITestsChangeDNSSettings.xctestplan */; };
852D054D2BC3DE3A008578D2 /* APIAccessPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 852D054C2BC3DE3A008578D2 /* APIAccessPage.swift */; };
852D054F2BC43DF7008578D2 /* AddAccessMethodPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 852D054E2BC43DF7008578D2 /* AddAccessMethodPage.swift */; };
8532E6872B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8532E6862B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift */; };
8542CE242B95F7B9006FCA14 /* VPNSettingsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8542CE232B95F7B9006FCA14 /* VPNSettingsPage.swift */; };
8542F7532BCFBD050035C042 /* SelectLocationFilterPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8542F7522BCFBD050035C042 /* SelectLocationFilterPage.swift */; };
Expand All @@ -644,9 +646,10 @@
8556EB542B9A1D7100D26DD4 /* BridgingHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 8556EB532B9A1D7100D26DD4 /* BridgingHeader.h */; };
8556EB562B9B0AC500D26DD4 /* RevokedDevicePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8556EB552B9B0AC500D26DD4 /* RevokedDevicePage.swift */; };
855D9F5B2B63E56B00D7C64D /* ProblemReportPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */; };
856952E22BD6B04C008C1F84 /* XCUIElement+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 856952E12BD6B04C008C1F84 /* XCUIElement+Extensions.swift */; };
8585CBE32BC684180015B6A4 /* EditAccessMethodPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8585CBE22BC684180015B6A4 /* EditAccessMethodPage.swift */; };
8587A05D2B84D43100152938 /* ChangeLogAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8587A05C2B84D43100152938 /* ChangeLogAlert.swift */; };
8590896F2B61763B003AF5F5 /* LoggedOutUITestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */; };
85A42B862BB1D627007BABF7 /* XCUIElement+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A42B852BB1D627007BABF7 /* XCUIElement+Extensions.swift */; };
85A42B882BB44D31007BABF7 /* DeviceManagementPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85A42B872BB44D31007BABF7 /* DeviceManagementPage.swift */; };
85B267612B849ADB0098E3CD /* mullvad-api.h in Headers */ = {isa = PBXBuildFile; fileRef = 85B267602B849ADB0098E3CD /* mullvad-api.h */; };
85C7A2E92B89024B00035D5A /* SettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C7A2E82B89024B00035D5A /* SettingsTests.swift */; };
Expand Down Expand Up @@ -1883,7 +1886,6 @@
850201DE2B5040A500EF8C96 /* TunnelControlPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelControlPage.swift; sourceTree = "<group>"; };
850201E22B51A93C00EF8C96 /* SettingsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPage.swift; sourceTree = "<group>"; };
85139B2C2B84B4A700734217 /* OutOfTimePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutOfTimePage.swift; sourceTree = "<group>"; };
8518F6372B60157E009EB113 /* LoggedInWithoutTimeUITestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggedInWithoutTimeUITestCase.swift; sourceTree = "<group>"; };
852969252B4D9C1F007EAD4C /* MullvadVPNUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MullvadVPNUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
852969272B4D9C1F007EAD4C /* AccountTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountTests.swift; sourceTree = "<group>"; };
852969302B4D9E70007EAD4C /* MullvadVPNUITestsAll.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = MullvadVPNUITestsAll.xctestplan; sourceTree = "<group>"; };
Expand All @@ -1898,6 +1900,8 @@
852BC66D2BAB44F500A47558 /* MullvadVPNUITestsChangeSettings.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MullvadVPNUITestsChangeSettings.xctestplan; sourceTree = "<group>"; };
852BC66E2BAB44F500A47558 /* MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan; sourceTree = "<group>"; };
852BC6722BAB450B00A47558 /* MullvadVPNUITestsChangeDNSSettings.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MullvadVPNUITestsChangeDNSSettings.xctestplan; sourceTree = "<group>"; };
852D054C2BC3DE3A008578D2 /* APIAccessPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIAccessPage.swift; sourceTree = "<group>"; };
852D054E2BC43DF7008578D2 /* AddAccessMethodPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccessMethodPage.swift; sourceTree = "<group>"; };
8532E6862B8CCED600ACECD1 /* ProblemReportSubmittedPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemReportSubmittedPage.swift; sourceTree = "<group>"; };
8542CE232B95F7B9006FCA14 /* VPNSettingsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNSettingsPage.swift; sourceTree = "<group>"; };
8542F7522BCFBD050035C042 /* SelectLocationFilterPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectLocationFilterPage.swift; sourceTree = "<group>"; };
Expand All @@ -1912,11 +1916,12 @@
8556EB532B9A1D7100D26DD4 /* BridgingHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; };
8556EB552B9B0AC500D26DD4 /* RevokedDevicePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RevokedDevicePage.swift; sourceTree = "<group>"; };
855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemReportPage.swift; sourceTree = "<group>"; };
856952E12BD6B04C008C1F84 /* XCUIElement+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Extensions.swift"; sourceTree = "<group>"; };
8585CBE22BC684180015B6A4 /* EditAccessMethodPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAccessMethodPage.swift; sourceTree = "<group>"; };
8587A05C2B84D43100152938 /* ChangeLogAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeLogAlert.swift; sourceTree = "<group>"; };
859089692B61763B003AF5F5 /* LoggedInWithTimeUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedInWithTimeUITestCase.swift; sourceTree = "<group>"; };
8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseUITestCase.swift; sourceTree = "<group>"; };
8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedOutUITestCase.swift; sourceTree = "<group>"; };
85A42B852BB1D627007BABF7 /* XCUIElement+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Extensions.swift"; sourceTree = "<group>"; };
85A42B872BB44D31007BABF7 /* DeviceManagementPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceManagementPage.swift; sourceTree = "<group>"; };
85B267602B849ADB0098E3CD /* mullvad-api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "mullvad-api.h"; path = "../../mullvad-api/include/mullvad-api.h"; sourceTree = "<group>"; };
85C7A2E82B89024B00035D5A /* SettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3766,7 +3771,6 @@
8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */,
859089692B61763B003AF5F5 /* LoggedInWithTimeUITestCase.swift */,
8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */,
8518F6372B60157E009EB113 /* LoggedInWithoutTimeUITestCase.swift */,
);
path = "Test base classes";
sourceTree = "<group>";
Expand All @@ -3783,6 +3787,10 @@
85557B0C2B591B0F00795FE1 /* Networking */,
852969312B4E9220007EAD4C /* Pages */,
850201DA2B503D7700EF8C96 /* RelayTests.swift */,
8518F6392B601910009EB113 /* Test base classes */,
856952E12BD6B04C008C1F84 /* XCUIElement+Extensions.swift */,
85557B152B5ABBBE00795FE1 /* XCUIElementQuery+Extensions.swift */,
85C7A2E82B89024B00035D5A /* SettingsTests.swift */,
85D039972BA4711800940E7F /* SettingsMigrationTests.swift */,
85C7A2E82B89024B00035D5A /* SettingsTests.swift */,
8518F6392B601910009EB113 /* Test base classes */,
Expand Down Expand Up @@ -3818,6 +3826,9 @@
8542CE232B95F7B9006FCA14 /* VPNSettingsPage.swift */,
85FB5A0B2B6903990015DCED /* WelcomePage.swift */,
8542F7522BCFBD050035C042 /* SelectLocationFilterPage.swift */,
852D054C2BC3DE3A008578D2 /* APIAccessPage.swift */,
852D054E2BC43DF7008578D2 /* AddAccessMethodPage.swift */,
8585CBE22BC684180015B6A4 /* EditAccessMethodPage.swift */,
);
path = Pages;
sourceTree = "<group>";
Expand Down Expand Up @@ -5799,6 +5810,7 @@
buildActionMask = 2147483647;
files = (
A9BFB0012BD00B7F00F2BCA1 /* CustomListPage.swift in Sources */,
8585CBE32BC684180015B6A4 /* EditAccessMethodPage.swift in Sources */,
8556EB522B9A1C6900D26DD4 /* MullvadApi.swift in Sources */,
85EC620C2B838D10005AFFB5 /* MullvadAPIWrapper.swift in Sources */,
A9DF789D2B7D1E8B0094E4AD /* LoggedInWithTimeUITestCase.swift in Sources */,
Expand All @@ -5808,10 +5820,11 @@
850201DD2B503D8C00EF8C96 /* SelectLocationPage.swift in Sources */,
85D039982BA4711800940E7F /* SettingsMigrationTests.swift in Sources */,
850201DB2B503D7700EF8C96 /* RelayTests.swift in Sources */,
852D054D2BC3DE3A008578D2 /* APIAccessPage.swift in Sources */,
85139B2D2B84B4A700734217 /* OutOfTimePage.swift in Sources */,
85A42B862BB1D627007BABF7 /* XCUIElement+Extensions.swift in Sources */,
852969362B4E9724007EAD4C /* AccessbilityIdentifier.swift in Sources */,
85E3BDE52B70E18C00FA71FD /* Networking.swift in Sources */,
856952E22BD6B04C008C1F84 /* XCUIElement+Extensions.swift in Sources */,
85C7A2E92B89024B00035D5A /* SettingsTests.swift in Sources */,
8590896F2B61763B003AF5F5 /* LoggedOutUITestCase.swift in Sources */,
85557B202B5FBBD700795FE1 /* AccountPage.swift in Sources */,
Expand All @@ -5838,6 +5851,7 @@
85557B122B594FC900795FE1 /* ConnectivityTests.swift in Sources */,
852969332B4E9232007EAD4C /* Page.swift in Sources */,
A9A557F32B7E19B10017ADA8 /* SettingsPage.swift in Sources */,
852D054F2BC43DF7008578D2 /* AddAccessMethodPage.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
25 changes: 24 additions & 1 deletion ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import UIKit

public enum AccessibilityIdentifier: String {
// Buttons
case addAccessMethodButton
case accessMethodAddButton
case accountButton
case accessMethodUnreachableBackButton
case accessMethodUnreachableSaveButton
case agreeButton
case alertOkButton
case applyButton
Expand Down Expand Up @@ -56,6 +60,7 @@ public enum AccessibilityIdentifier: String {

// Cells
case deviceCell
case accessMethodProtocolSelectionCell
case vpnSettingsCell
case dnsSettingsAddServerCell
case dnsSettingsUseCustomDNSCell
Expand Down Expand Up @@ -83,20 +88,31 @@ public enum AccessibilityIdentifier: String {
case customListLocationCell

// Labels
case accountPagePaidUntilLabel
case accountPageDeviceNameLabel
case socks5ServerCell
case socks5PortCell
case accountPagePaidUntilLabel
case addAccessMethodTestStatusReachableLabel
case addAccessMethodTestStatusTestingLabel
case addAccessMethodTestStatusUnreachableLabel
case headerDeviceNameLabel
case connectionStatusConnectedLabel
case connectionStatusNotConnectedLabel
case welcomeAccountNumberLabel
case connectionPanelDetailLabel

// Views
case accessMethodProtocolPickerView
case accessMethodUnreachableAlert
case accountView
case addLocationsView
case addAccessMethodTableView
case apiAccessView
case alertContainerView
case alertTitle
case changeLogAlert
case deviceManagementView
case editAccessMethodView
case headerBarView
case loginView
case outOfTimeView
Expand All @@ -121,17 +137,24 @@ public enum AccessibilityIdentifier: String {
case editCustomListEditLocationsTableView

// Other UI elements
case accessMethodEnableSwitch
case accessMethodNameTextField
case logOutSpinnerAlertView
case connectionPanelInAddressRow
case connectionPanelOutAddressRow
case customSwitch
case customWireGuardPortTextField
case dnsContentBlockersHeaderView
case dnsSettingsEnterIPAddressTextField
case loginStatusIconAuthenticating
case loginStatusIconFailure
case loginStatusIconSuccess
case loginTextField
case selectLocationSearchTextField
case problemReportEmailTextField
case problemReportMessageTextView
case deleteAccountTextField
case socks5AuthenticationSwitch

// DNS settings
case dnsSettings
Expand Down
1 change: 1 addition & 0 deletions ios/MullvadVPN/Coordinators/AccountCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ final class AccountCoordinator: Coordinator, Presentable, Presenting {
private func logOut() {
let presentation = AlertPresentation(
id: "account-logout-alert",
accessibilityIdentifier: .logOutSpinnerAlertView,
icon: .spinner,
message: nil,
buttons: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct SwitchCellContentConfiguration: UIContentConfiguration, Equatable {
var color = UIColor.Cell.titleTextColor
}

var accessibilityIdentifier: AccessibilityIdentifier?

/// Text label.
var text: String?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class SwitchCellContentView: UIView, UIContentView, UITextFieldDelegate {
private func configureSwitch() {
switchContainer.control.isOn = actualConfiguration.isOn
switchContainer.transform = CGAffineTransform(scaleX: 0.85, y: 0.85)
switchContainer.accessibilityIdentifier = accessibilityIdentifier
}

private func addSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct SocksSectionHandler {
contentConfiguration.inputText = subject.value.socks.server
contentConfiguration.textFieldProperties = .withSmartFeaturesDisabled()
contentConfiguration.editingEvents.onChange = subject.bindTextAction(to: \.socks.server)
cell.accessibilityIdentifier = .socks5ServerCell
cell.contentConfiguration = contentConfiguration
}

Expand All @@ -52,6 +53,7 @@ struct SocksSectionHandler {
if case .phone = cell.traitCollection.userInterfaceIdiom {
contentConfiguration.textFieldProperties.keyboardType = .numberPad
}
cell.accessibilityIdentifier = .socks5PortCell
cell.contentConfiguration = contentConfiguration
}

Expand All @@ -60,6 +62,7 @@ struct SocksSectionHandler {
contentConfiguration.text = itemIdentifier.text
contentConfiguration.isOn = subject.value.socks.authenticate
contentConfiguration.onChange = subject.bindSwitchAction(to: \.socks.authenticate)
contentConfiguration.accessibilityIdentifier = .socks5AuthenticationSwitch
cell.contentConfiguration = contentConfiguration
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class EditAccessMethodViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.accessibilityIdentifier = .editAccessMethodView
view.backgroundColor = .secondaryColor
tableView.backgroundColor = .secondaryColor
navigationItem.largeTitleDisplayMode = .never
Expand Down Expand Up @@ -197,6 +198,7 @@ class EditAccessMethodViewController: UITableViewController {

private func configureEnableMethod(_ cell: UITableViewCell, itemIdentifier: EditAccessMethodItemIdentifier) {
var contentConfiguration = SwitchCellContentConfiguration()
contentConfiguration.accessibilityIdentifier = .accessMethodEnableSwitch
contentConfiguration.text = itemIdentifier.text
contentConfiguration.isOn = subject.value.isEnabled
contentConfiguration.onChange = UIAction { [weak self] action in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class MethodSettingsCellConfiguration {
contentConfiguration.inputText = subject.value.name
contentConfiguration.editingEvents.onChange = subject.bindTextAction(to: \.name)

cell.accessibilityIdentifier = .accessMethodNameTextField
cell.setDisabled(isTesting)
cell.contentConfiguration = contentConfiguration
}
Expand Down Expand Up @@ -153,6 +154,7 @@ class MethodSettingsCellConfiguration {
cell.disclosureType = .chevron
}

cell.accessibilityIdentifier = .accessMethodProtocolSelectionCell
cell.setDisabled(isTesting)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ class MethodSettingsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()

view.accessibilityIdentifier = .addAccessMethodTableView
view.directionalLayoutMargins = UIMetrics.contentLayoutMargins
view.backgroundColor = .secondaryColor

navigationItem.rightBarButtonItem = saveBarButton
navigationItem.rightBarButtonItem?.accessibilityIdentifier = .accessMethodAddButton
navigationItem.rightBarButtonItem?.isAccessibilityElement = true
isModalInPresentation = true

configureTableView()
Expand Down Expand Up @@ -307,6 +310,7 @@ class MethodSettingsViewController: UITableViewController {
case .failed:
let presentation = AlertPresentation(
id: "api-access-methods-testing-status-failed-alert",
accessibilityIdentifier: .accessMethodUnreachableAlert,
icon: .warning,
message: NSLocalizedString(
"METHOD_SETTINGS_SAVE_PROMPT",
Expand All @@ -323,6 +327,7 @@ class MethodSettingsViewController: UITableViewController {
comment: ""
),
style: .default,
accessibilityId: .accessMethodUnreachableSaveButton,
handler: { [weak self] in
self?.onSave()
}
Expand All @@ -334,7 +339,8 @@ class MethodSettingsViewController: UITableViewController {
value: "Back to editing",
comment: ""
),
style: .default
style: .default,
accessibilityId: .accessMethodUnreachableBackButton
),
]
)
Expand Down
Loading

0 comments on commit 53364a8

Please sign in to comment.