diff --git a/ios/Configurations/UITests.xcconfig.template b/ios/Configurations/UITests.xcconfig.template index c2a0fe821b9e..e39224eedfe0 100644 --- a/ios/Configurations/UITests.xcconfig.template +++ b/ios/Configurations/UITests.xcconfig.template @@ -7,8 +7,6 @@ IOS_DEVICE_PIN_CODE = TEST_DEVICE_IDENTIFIER_UUID = // Mullvad accounts used by UI tests -NO_TIME_ACCOUNT_NUMBER[config=Debug] = -NO_TIME_ACCOUNT_NUMBER[config=Staging] = HAS_TIME_ACCOUNT_NUMBER[config=Debug] = HAS_TIME_ACCOUNT_NUMBER[config=Staging] = FIVE_WIREGUARD_KEYS_ACCOUNT_NUMBER = diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index aa8c56501933..ea4432d9ef62 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -641,7 +641,6 @@ 8556EB562B9B0AC500D26DD4 /* RevokedDevicePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8556EB552B9B0AC500D26DD4 /* RevokedDevicePage.swift */; }; 855D9F5B2B63E56B00D7C64D /* ProblemReportPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */; }; 8587A05D2B84D43100152938 /* ChangeLogAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8587A05C2B84D43100152938 /* ChangeLogAlert.swift */; }; - 8590896C2B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 859089682B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.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 */; }; 85B267612B849ADB0098E3CD /* mullvad-api.h in Headers */ = {isa = PBXBuildFile; fileRef = 85B267602B849ADB0098E3CD /* mullvad-api.h */; }; @@ -1903,7 +1902,6 @@ 8556EB552B9B0AC500D26DD4 /* RevokedDevicePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RevokedDevicePage.swift; sourceTree = ""; }; 855D9F5A2B63E56B00D7C64D /* ProblemReportPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemReportPage.swift; sourceTree = ""; }; 8587A05C2B84D43100152938 /* ChangeLogAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeLogAlert.swift; sourceTree = ""; }; - 859089682B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedInWithoutTimeUITestCase.swift; sourceTree = ""; }; 859089692B61763B003AF5F5 /* LoggedInWithTimeUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedInWithTimeUITestCase.swift; sourceTree = ""; }; 8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseUITestCase.swift; sourceTree = ""; }; 8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggedOutUITestCase.swift; sourceTree = ""; }; @@ -3613,7 +3611,6 @@ isa = PBXGroup; children = ( 8590896A2B61763B003AF5F5 /* BaseUITestCase.swift */, - 859089682B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift */, 859089692B61763B003AF5F5 /* LoggedInWithTimeUITestCase.swift */, 8590896B2B61763B003AF5F5 /* LoggedOutUITestCase.swift */, 8518F6372B60157E009EB113 /* LoggedInWithoutTimeUITestCase.swift */, @@ -5652,7 +5649,6 @@ 852969362B4E9724007EAD4C /* AccessbilityIdentifier.swift in Sources */, 85E3BDE52B70E18C00FA71FD /* Networking.swift in Sources */, 85C7A2E92B89024B00035D5A /* SettingsTests.swift in Sources */, - 8590896C2B61763B003AF5F5 /* LoggedInWithoutTimeUITestCase.swift in Sources */, 8590896F2B61763B003AF5F5 /* LoggedOutUITestCase.swift in Sources */, 85557B202B5FBBD700795FE1 /* AccountPage.swift in Sources */, 852969352B4E9270007EAD4C /* LoginPage.swift in Sources */, diff --git a/ios/MullvadVPNUITests/AccountTests.swift b/ios/MullvadVPNUITests/AccountTests.swift index f78235360154..6c8d9094b9d5 100644 --- a/ios/MullvadVPNUITests/AccountTests.swift +++ b/ios/MullvadVPNUITests/AccountTests.swift @@ -58,7 +58,7 @@ class AccountTests: LoggedOutUITestCase { func testLogin() throws { LoginPage(app) .tapAccountNumberTextField() - .enterText(self.noTimeAccountNumber) + .enterText(hasTimeAccountNumber) .tapAccountNumberSubmitButton() .verifySuccessIconShown() .verifyDeviceLabelShown() diff --git a/ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift b/ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift index 9c994921fb84..e592862cbf33 100644 --- a/ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift +++ b/ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift @@ -60,6 +60,16 @@ class DNSSettingsPage: Page { return self } + @discardableResult func tapBlockAdsSwitchIfOn() -> Self { + let blockAdsSwitch = app.cells[AccessibilityIdentifier.blockAdvertising] + .switches[AccessibilityIdentifier.customSwitch] + + if blockAdsSwitch.value as? String == "1" { + tapBlockAdsSwitch() + } + return self + } + @discardableResult func tapBlockTrackerSwitch() -> Self { app.cells[AccessibilityIdentifier.blockTracking] .switches[AccessibilityIdentifier.customSwitch] diff --git a/ios/MullvadVPNUITests/RelayTests.swift b/ios/MullvadVPNUITests/RelayTests.swift index 6db6dd5f6126..b3ebedda0953 100644 --- a/ios/MullvadVPNUITests/RelayTests.swift +++ b/ios/MullvadVPNUITests/RelayTests.swift @@ -40,6 +40,22 @@ class RelayTests: LoggedInWithTimeUITestCase { } func testAdBlockingViaDNS() throws { + // Undo enabling block ads in teardown + addTeardownBlock { + HeaderBar(self.app) + .tapSettingsButton() + + SettingsPage(self.app) + .tapVPNSettingsCell() + + VPNSettingsPage(self.app) + .tapDNSSettingsCell() + + DNSSettingsPage(self.app) + .tapDNSContentBlockersHeaderExpandButton() + .tapBlockAdsSwitchIfOn() + } + HeaderBar(app) .tapSettingsButton() @@ -57,7 +73,7 @@ class RelayTests: LoggedInWithTimeUITestCase { TunnelControlPage(app) .tapSecureConnectionButton() - allowAddVPNConfigurations() // Allow adding VPN configurations iOS permission + allowAddVPNConfigurationsIfAsked() // Allow adding VPN configurations iOS permission TunnelControlPage(app) .waitForSecureConnectionLabel() @@ -90,6 +106,18 @@ class RelayTests: LoggedInWithTimeUITestCase { } func testWireGuardOverTCPManually() throws { + addTeardownBlock { + HeaderBar(self.app) + .tapSettingsButton() + + SettingsPage(self.app) + .tapVPNSettingsCell() + + VPNSettingsPage(self.app) + .tapWireGuardObfuscationExpandButton() + .tapWireGuardObfuscationOffCell() + } + HeaderBar(app) .tapSettingsButton() @@ -168,6 +196,7 @@ class RelayTests: LoggedInWithTimeUITestCase { .enterText("4001") .dismissKeyboard() .swipeDownToDismissModal() + .swipeDownToDismissModal() // After editing text field the table is first responder for the first swipe so we need to swipe twice to swipe the modal TunnelControlPage(app) .tapSecureConnectionButton() diff --git a/ios/MullvadVPNUITests/Test base classes/BaseUITestCase.swift b/ios/MullvadVPNUITests/Test base classes/BaseUITestCase.swift index ae4011cfc7ef..82feccc89ef5 100644 --- a/ios/MullvadVPNUITests/Test base classes/BaseUITestCase.swift +++ b/ios/MullvadVPNUITests/Test base classes/BaseUITestCase.swift @@ -17,8 +17,6 @@ class BaseUITestCase: XCTestCase { // swiftlint:disable force_cast let displayName = Bundle(for: BaseUITestCase.self) .infoDictionary?["DisplayName"] as! String - let noTimeAccountNumber = Bundle(for: BaseUITestCase.self) - .infoDictionary?["NoTimeAccountNumber"] as! String let hasTimeAccountNumber = Bundle(for: BaseUITestCase.self) .infoDictionary?["HasTimeAccountNumber"] as! String let fiveWireGuardKeysAccountNumber = Bundle(for: BaseUITestCase.self) diff --git a/ios/MullvadVPNUITests/Test base classes/LoggedInWithoutTimeUITestCase.swift b/ios/MullvadVPNUITests/Test base classes/LoggedInWithoutTimeUITestCase.swift deleted file mode 100644 index 8c40c4e76abe..000000000000 --- a/ios/MullvadVPNUITests/Test base classes/LoggedInWithoutTimeUITestCase.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// LoggedInWithoutTimeUITestCase.swift -// MullvadVPNUITests -// -// Created by Niklas Berglund on 2024-01-23. -// Copyright © 2024 Mullvad VPN AB. All rights reserved. -// - -import Foundation - -/// Base class for tests that should start from a state of being logged on to an account without time left -class LoggedInWithoutTimeUITestCase: BaseUITestCase { - override func setUp() { - super.setUp() - - agreeToTermsOfServiceIfShown() - dismissChangeLogIfShown() - logoutIfLoggedIn() - - login(accountNumber: noTimeAccountNumber) - - // Relaunch app so that tests start from a deterministic state - app.terminate() - app.launch() - } -}