Skip to content

Commit 0c5c4bc

Browse files
committed
Remove app uninstall step from iOS end-to-end tests
1 parent bbb8761 commit 0c5c4bc

File tree

13 files changed

+128
-72
lines changed

13 files changed

+128
-72
lines changed

.github/actions/ios/run-ios-e2e-tests/action.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ runs:
3939
env:
4040
TEST_NAME: ${{ inputs.test_name }}
4141
OUTPUTS_PATH: ${{ inputs.outputs_path }}
42-
43-
- name: Uninstall app
44-
run: ios-deploy --id $TEST_DEVICE_UDID --uninstall_only --bundle_id net.mullvad.MullvadVPN
45-
shell: bash
46-
env:
47-
TEST_DEVICE_UDID: ${{ inputs.test_device_udid }}
48-
4942
- name: Run end-to-end-tests
5043
run: |
5144
# Forcing the filesystem buffers to be flushed to ensure the

ios/MullvadVPN.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,8 @@
10331033
F0ADF1D12D01B55C00299F09 /* ChipModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0ADF1D02D01B55C00299F09 /* ChipModel.swift */; };
10341034
F0ADF1D32D01B6B400299F09 /* FeatureIndicatorsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0ADF1D22D01B6B400299F09 /* FeatureIndicatorsViewModel.swift */; };
10351035
F0ADF1D52D01DCFD00299F09 /* ChipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0ADF1D42D01DCFD00299F09 /* ChipView.swift */; };
1036+
F0AF894F2F55A78B00DE9740 /* UITestSettingsResetPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AF894A2F55A77800DE9740 /* UITestSettingsResetPolicy.swift */; };
1037+
F0AF89502F55A8F400DE9740 /* UITestSettingsResetPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AF894A2F55A77800DE9740 /* UITestSettingsResetPolicy.swift */; };
10361038
F0B06BC22EAA4191008C0A0B /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = F0B06BC12EAA4191008C0A0B /* Localizable.xcstrings */; };
10371039
F0B06BC32EAA4191008C0A0B /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = F0B06BC12EAA4191008C0A0B /* Localizable.xcstrings */; };
10381040
F0B06BC42EAA4191008C0A0B /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = F0B06BC12EAA4191008C0A0B /* Localizable.xcstrings */; };
@@ -2487,6 +2489,7 @@
24872489
F0ADF1D22D01B6B400299F09 /* FeatureIndicatorsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureIndicatorsViewModel.swift; sourceTree = "<group>"; };
24882490
F0ADF1D42D01DCFD00299F09 /* ChipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipView.swift; sourceTree = "<group>"; };
24892491
F0AE6DB72E4A3285001A7B23 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2492+
F0AF894A2F55A77800DE9740 /* UITestSettingsResetPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITestSettingsResetPolicy.swift; sourceTree = "<group>"; };
24902493
F0B06BC12EAA4191008C0A0B /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
24912494
F0B0E6962AFE6E7E001DC66B /* XCTest+Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTest+Async.swift"; sourceTree = "<group>"; };
24922495
F0B495752D02025200CFEC2A /* ChipContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipContainerView.swift; sourceTree = "<group>"; };
@@ -3718,6 +3721,7 @@
37183721
58C76A072A33850E00100D75 /* ApplicationTarget.swift */,
37193722
F0EF2B762F4C801D00C7ECA7 /* AppResetManager.swift */,
37203723
F0F1EF8C2BE8FF0A00CED01D /* LaunchArguments.swift */,
3724+
F0AF894A2F55A77800DE9740 /* UITestSettingsResetPolicy.swift */,
37213725
);
37223726
path = Shared;
37233727
sourceTree = "<group>";
@@ -6670,6 +6674,7 @@
66706674
7A6652B82BB44C3E0042D848 /* LocationDiffableDataSourceProtocol.swift in Sources */,
66716675
5827B0A82B0F49EF00CCBBA1 /* ProxyConfigurationInteractorProtocol.swift in Sources */,
66726676
7A5869B92B56E7F000640D27 /* IPOverrideViewControllerDelegate.swift in Sources */,
6677+
F0AF894F2F55A78B00DE9740 /* UITestSettingsResetPolicy.swift in Sources */,
66736678
586C0D7A2B039CE300E7CDD7 /* ShadowsocksCipherPicker.swift in Sources */,
66746679
7A2F41092EC38FD20013D3C5 /* StoreSubscription.swift in Sources */,
66756680
58B93A1326C3F13600A55733 /* TunnelState.swift in Sources */,
@@ -6997,6 +7002,7 @@
69977002
4495ECD12D0B170700A7358B /* UDPOverTCPObfuscationSettingsPage.swift in Sources */,
69987003
850201DB2B503D7700EF8C96 /* RelayTests.swift in Sources */,
69997004
7A9F29352CAA8829005F2089 /* AccessMethodsTests.swift in Sources */,
7005+
F0AF89502F55A8F400DE9740 /* UITestSettingsResetPolicy.swift in Sources */,
70007006
7A45CFC62C05FF6A00D80B21 /* ScreenshotTests.swift in Sources */,
70017007
852D054D2BC3DE3A008578D2 /* APIAccessPage.swift in Sources */,
70027008
85139B2D2B84B4A700734217 /* OutOfTimePage.swift in Sources */,

ios/MullvadVPN/SceneDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, @preconcurrency Setting
169169
guard let windowScene = scene as? UIWindowScene else { return }
170170
let launchViewController = LaunchViewController(
171171
launchArguments: appDelegate.launchArguments,
172-
tunnelManager: tunnelManager)
172+
tunnelManager: tunnelManager,
173+
accessMethodRepository: accessMethodRepository)
173174

174175
launchViewController.onAppReady = { [weak self] in
175176
guard let self = self else { return }

ios/MullvadVPN/View controllers/Launch/LaunchViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ class LaunchViewController: UIViewController {
1414

1515
var onAppReady: (() -> Void)?
1616

17-
init(launchArguments: LaunchArguments, tunnelManager: TunnelManager) {
17+
init(
18+
launchArguments: LaunchArguments, tunnelManager: TunnelManager,
19+
accessMethodRepository: any AccessMethodRepositoryProtocol
20+
) {
1821
self.appResetManager = AppResetManager(
19-
launchArguments: launchArguments, tunnelManager: tunnelManager)
22+
launchArguments: launchArguments, tunnelManager: tunnelManager,
23+
accessMethodRepository: accessMethodRepository)
2024
super.init(nibName: nil, bundle: nil)
2125
setupLaunchScreen()
2226
self.appResetManager.onAppReady = { [weak self] in

ios/MullvadVPNUITests/Base/BaseUITestCase.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class BaseUITestCase: XCTestCase {
182182
///
183183
/// Return `all` to ensure the application starts from a clean state
184184
/// before tests are executed.
185-
class var settingsResetPolicy: LaunchArguments.LocalDataResetPolicy {
185+
class var settingsResetPolicy: UITestSettingsResetPolicy {
186186
return .all
187187
}
188188

@@ -198,7 +198,7 @@ class BaseUITestCase: XCTestCase {
198198
let argumentsJsonString = try? LaunchArguments(
199199
target: .uiTests,
200200
authenticationState: Self.authenticationState,
201-
localDataResetPolicy: Self.settingsResetPolicy,
201+
settingsResetPolicy: Self.settingsResetPolicy
202202
).toJSON()
203203
app.launchEnvironment[LaunchArguments.tag] = argumentsJsonString
204204
app.launch()
@@ -209,7 +209,10 @@ class BaseUITestCase: XCTestCase {
209209

210210
func agreeToTermsOfServiceIfShown() {
211211
let timeout: XCUIElement.Timeout =
212-
Self.authenticationState == .forceLoggedOut ? .longerThanMullvadAPITimeout : .short
212+
Self.authenticationState == .forceLoggedOut && isLoggedIn()
213+
? .longerThanMullvadAPITimeout
214+
: .short
215+
213216
if app.otherElements["termsOfServiceView"].existsAfterWait(timeout: timeout) {
214217
TermsOfServicePage(app)
215218
.tapAgreeButton()
@@ -373,17 +376,17 @@ class BaseUITestCase: XCTestCase {
373376
}
374377
}
375378

376-
func relaunch() throws {
377-
app.terminate()
378-
XCTAssertTrue(app.wait(for: .notRunning, timeout: 5))
379-
380-
let arguments = LaunchArguments(
381-
target: .uiTests,
382-
authenticationState: .keepLoggedIn,
383-
localDataResetPolicy: .none
384-
)
385-
386-
app.launchEnvironment[LaunchArguments.tag] = try arguments.toJSON()
387-
app.launch()
388-
}
379+
// func relaunch() throws {
380+
// app.terminate()
381+
// XCTAssertTrue(app.wait(for: .notRunning, timeout: 5))
382+
//
383+
// let arguments = LaunchArguments(
384+
// target: .uiTests,
385+
// authenticationState: .keepLoggedIn,
386+
// localDataResetPolicy: .none
387+
// )
388+
//
389+
// app.launchEnvironment[LaunchArguments.tag] = try arguments.toJSON()
390+
// app.launch()
391+
// }
389392
}

ios/MullvadVPNUITests/Base/LoggedInWithTimeUITestCase.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,32 @@ import XCTest
1111

1212
/// Base class for tests that should start from a state of being logged on to an account with time left
1313
class LoggedInWithTimeUITestCase: BaseUITestCase {
14-
var hasTimeAccountNumber: String?
14+
private var hasTimeAccountNumber: String? {
15+
getAccountWithTime()
16+
}
1517

1618
override class var authenticationState: LaunchArguments.AuthenticationState { .keepLoggedIn }
1719

20+
override class var settingsResetPolicy: UITestSettingsResetPolicy { .all }
21+
1822
override func setUp() async throws {
1923
try await super.setUp()
20-
hasTimeAccountNumber = getAccountWithTime()
24+
guard !isLoggedIn() else { return }
2125
guard let hasTimeAccountNumber = self.hasTimeAccountNumber else {
2226
XCTFail("hasTimeAccountNumber unexpectedly not set")
2327
return
2428
}
25-
2629
login(accountNumber: hasTimeAccountNumber)
2730
}
2831

29-
override func tearDown() async throws {
30-
try await super.tearDown()
31-
32-
guard let hasTimeAccountNumber = self.hasTimeAccountNumber else {
33-
XCTFail("hasTimeAccountNumber unexpectedly not set")
34-
return
35-
}
36-
37-
self.deleteTemporaryAccountWithTime(accountNumber: hasTimeAccountNumber)
38-
}
32+
// override func tearDown() async throws {
33+
// try await super.tearDown()
34+
//
35+
// guard let hasTimeAccountNumber = self.hasTimeAccountNumber else {
36+
// XCTFail("hasTimeAccountNumber unexpectedly not set")
37+
// return
38+
// }
39+
//
40+
// self.deleteTemporaryAccountWithTime(accountNumber: hasTimeAccountNumber)
41+
// }
3942
}

ios/MullvadVPNUITests/Base/LoggedOutUITestCase.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import Foundation
1010

1111
/// Base class for tests which should start from a logged out state
1212
class LoggedOutUITestCase: BaseUITestCase {
13+
override class var authenticationState: LaunchArguments.AuthenticationState {
14+
.forceLoggedOut
15+
}
16+
override class var settingsResetPolicy: UITestSettingsResetPolicy {
17+
.all
18+
}
1319

1420
func disableBridgesAccessMethod() {
1521
HeaderBar(app)

ios/MullvadVPNUITests/CustomListsTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
import XCTest
1010

1111
class CustomListsTests: LoggedInWithTimeUITestCase {
12+
override class var authenticationState: LaunchArguments.AuthenticationState {
13+
.keepLoggedIn
14+
}
15+
16+
override class var settingsResetPolicy: UITestSettingsResetPolicy { .none }
17+
1218
func testCreateCustomListPersistAfterAppRestarts() throws {
1319
TunnelControlPage(app)
1420
.tapSelectLocationButton()
@@ -20,7 +26,8 @@ class CustomListsTests: LoggedInWithTimeUITestCase {
2026
self.deleteCustomList(named: customListName)
2127
}
2228

23-
try relaunch()
29+
app.terminate()
30+
app.launch()
2431

2532
TunnelControlPage(app)
2633
.tapSelectLocationButton()

ios/MullvadVPNUITests/Payment/PaymentTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class PaymentTests: LoggedOutUITestCase {
7373
}
7474

7575
// Relaunch to get to out-of-time view.
76-
try relaunch()
76+
app.terminate()
77+
app.launch()
7778

7879
HeaderBar(app)
7980
.tapAccountButton()

ios/MullvadVPNUITests/Screenshots/ScreenshotTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ScreenshotTests: LoggedInWithTimeUITestCase {
2626
// We can't close banners in the screenshot tests due to how the NotificationController view
2727
// is overridden, so we need to restart the app once to make sure the "new device" notification
2828
// isn't visible.
29-
try relaunch()
29+
app.terminate()
30+
app.launch()
3031

3132
TunnelControlPage(app)
3233
.tapSelectLocationButton()

0 commit comments

Comments
 (0)