summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPNUITests/SettingsMigrationTests.swift
blob: 5c59aa398b78b723a727314e8c8b1b7e9c02a6b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//
//  SettingsMigrationTests.swift
//  MullvadVPNUITests
//
//  Created by Niklas Berglund on 2024-03-15.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import XCTest

/// Pre-Release iOS Settings Migration Testing Instructions
///
/// Before releasing a new version, ensure the settings migration process works as expected.
/// Follow these steps to validate that user settings persist correctly across app updates:
///
/// 1. Remove the installed app:
///    Uninstall the current app from the test device to ensure a clean environment.
/// 2. Switch to an older released version:
///    Checkout an app version released approximately 6 months ago for testing migration over a meaningful time span.
/// 3. Run `testChangeCustomDNSSettings`:
///    Modify DNS settings in the older app version to simulate real-world user interactions.
/// 4. Checkout the release branch:
///    Switch to the branch containing the new app version to be released.
///    - Run `testVerifyCustomDNSSettingsStillChanged`:
///      Verify that DNS settings changed in step 3 persist after upgrading.
/// 5. Return to the older version:
///    Checkout the same older version used in step 2 to continue testing additional settings.
/// 6. Run `testChangeVPNSettings`:
///    Modify VPN-related settings in the older app version.
/// 7. Switch back to the release branch:
///    Return to the branch checked out in step 4.
///    - Run `testVerifySettingsStillChanged`:
///      Confirm that VPN settings changed in step 6 persist after upgrading.
///
/// These steps ensure the app's settings migration logic is robust and reliable,
/// providing a seamless user experience during upgrades.
class SettingsMigrationTests: BaseUITestCase {
    let customDNSServerIPAddress = "123.123.123.123"
    let wireGuardPort = "4001"

    override class func shouldUninstallAppInTeardown() -> Bool {
        return false
    }

    override func setUp() async throws {
        try await super.setUp()

        agreeToTermsOfServiceIfShown()

        // Relaunch app so that tests start from a deterministic state
        app.terminate()
        app.launch()
    }

    func testChangeCustomDNSSettings() {
        let hasTimeAccountNumber = getAccountWithTime()

        addTeardownBlock {
            self.deleteTemporaryAccountWithTime(accountNumber: hasTimeAccountNumber)
        }

        logoutIfLoggedIn()
        login(accountNumber: hasTimeAccountNumber)

        HeaderBar(app)
            .tapSettingsButton()

        SettingsPage(app)
            .tapVPNSettingsCell()

        VPNSettingsPage(app)
            .tapDNSSettingsCell()

        DNSSettingsPage(app)
            .tapEditButton()
            .tapAddAServer()
            .tapEnterIPAddressTextField()
            .enterText(customDNSServerIPAddress)
            .dismissKeyboard()
            .tapUseCustomDNSSwitch()
            .tapDoneButton()
    }

    func testVerifyCustomDNSSettingsStillChanged() {
        HeaderBar(app)
            .tapSettingsButton()

        SettingsPage(app)
            .tapVPNSettingsCell()

        VPNSettingsPage(app)
            .tapDNSSettingsCell()

        DNSSettingsPage(app)
            .verifyUseCustomDNSSwitchOn()
            .verifyCustomDNSIPAddress(customDNSServerIPAddress)
    }

    func testChangeVPNSettings() {
        let hasTimeAccountNumber = getAccountWithTime()

        addTeardownBlock {
            self.deleteTemporaryAccountWithTime(accountNumber: hasTimeAccountNumber)
        }

        logoutIfLoggedIn()
        login(accountNumber: hasTimeAccountNumber)

        HeaderBar(app)
            .tapSettingsButton()

        SettingsPage(app)
            .tapVPNSettingsCell()

        VPNSettingsPage(app)
            .tapDNSSettingsCell()

        DNSSettingsPage(app)
            .tapDNSContentBlockersHeaderExpandButton()
            .tapBlockAdsSwitch()
            .tapBlockTrackerSwitch()
            .tapBlockMalwareSwitch()
            .tapBlockGamblingSwitch()
            .tapBlockAdultContentSwitch()
            .tapBlockSocialMediaSwitch()
            .tapBackButton()

        VPNSettingsPage(app)
            .tapWireGuardPortsExpandButton()
            .tapCustomWireGuardPortTextField()
            .enterText(wireGuardPort)
            .dismissKeyboard()
            .tapQuantumResistantTunnelExpandButton()
            .tapQuantumResistantTunnelOnCell()
            .tapWireGuardObfuscationExpandButton()
            .tapUDPOverTCPPortSelectorButton()

        UDPOverTCPObfuscationSettingsPage(app)
            .tapPort5001Cell()
            .tapPort80Cell()
            .tapBackButton()

        VPNSettingsPage(app)
            .tapShadowsocksPortSelectorButton()

        ShadowsocksObfuscationSettingsPage(app)
            .tapAutomaticPortCell()
            .tapCustomCell()
            .enterText("1234")
            .tapBackButton()

        VPNSettingsPage(app)
            .tapWireGuardObfuscationUdpOverTcpCell()
    }

    func testVerifySettingsStillChanged() {
        HeaderBar(app)
            .tapSettingsButton()

        SettingsPage(app)
            .tapVPNSettingsCell()

        VPNSettingsPage(app)
            .tapDNSSettingsCell()

        DNSSettingsPage(app)
            .tapDNSContentBlockersHeaderExpandButton()
            .verifyBlockAdsSwitchOn()
            .verifyBlockTrackerSwitchOn()
            .verifyBlockMalwareSwitchOn()
            .verifyBlockAdultContentSwitchOn()
            .verifyBlockGamblingSwitchOn()
            .verifyBlockSocialMediaSwitchOn()
            .tapBackButton()

        VPNSettingsPage(app)
            .tapQuantumResistantTunnelExpandButton()
            .verifyQuantumResistantTunnelOnSelected()
            .tapWireGuardPortsExpandButton()
            .verifyCustomWireGuardPortSelected(portNumber: wireGuardPort)
            .tapWireGuardObfuscationExpandButton()
            .verifyWireGuardObfuscationOnSelected()
            .verifyUDPOverTCPPort80Selected()
    }
}