Skip to content

Commit

Permalink
Reuse end to end test in settings migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mojganii committed Nov 15, 2024
1 parent 6b3af94 commit 0420524
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 334 deletions.
186 changes: 84 additions & 102 deletions .github/workflows/ios-end-to-end-tests-settings-migration.yml
Original file line number Diff line number Diff line change
@@ -1,126 +1,108 @@
---
name: iOS settings migration tests
name: iOS Settings Migration Tests

concurrency:
group: ios-end-to-end-tests
cancel-in-progress: false

permissions:
contents: read
issues: write
pull-requests: write

on:
workflow_dispatch:
schedule:
# At midnight every day.
# Notifications for scheduled workflows are sent to the user who last modified the cron
# syntax in the workflow file. If you update this you must have notifications for
# Github Actions enabled, so these don't go unnoticed.
# syntax in the workflow file. If you update this, ensure notifications for
# GitHub Actions are enabled.
# https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/notifications-for-workflow-runs
- cron: '0 0 * * *'

# Global environment variables for easy updates
env:
TEST_DEVICE_UDID: 00008130-0019181022F3803A
OLD_APP_COMMIT_HASH: "98c3489ede22a7eb4a6fcb69b4bd504abbe83d5f"

jobs:
test:
name: Settings migration end to end tests
runs-on: [self-hosted, macOS, ios-test]
env:
OLD_APP_COMMIT_HASH: 895b7d98825e678f5d7023d5ea3c9b7beee89280
set_commit_hash:
name: Set Commit Hash Environment Variable
runs-on:
- self-hosted
- macOS
- ios-test
outputs:
old_app_commit_hash: ${{ steps.set-hash.outputs.old_app_commit_hash }}
steps:
- name: Configure Rust
uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
target: aarch64-apple-ios

- name: Uninstall app
timeout-minutes: 5
run: ios-deploy --id ${{ env.TEST_DEVICE_UDID }} --uninstall_only --bundle_id net.mullvad.MullvadVPN
- name: Set OLD_APP_COMMIT_HASH
id: set-hash
run: echo "::set-output name=old_app_commit_hash::${{ env.OLD_APP_COMMIT_HASH }}"

- name: Checkout old repository version
uses: actions/checkout@v4
with:
ref: ${{ env.OLD_APP_COMMIT_HASH }}

- name: Change DNS settings on old app version
uses: ./.github/actions/ios-end-to-end-tests
with:
ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }}
test_device_identifier_uuid: ${{ secrets.IOS_TEST_DEVICE_IDENTIFIER_UUID }}
has_time_account_number: ${{ secrets.IOS_HAS_TIME_ACCOUNT_NUMBER_PRODUCTION }}
no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }}
test_device_udid: ${{ env.TEST_DEVICE_UDID }}
xcode_test_plan: 'MullvadVPNUITestsChangeDNSSettings'
partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }}

- name: Store test report for changing DNS settings
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report-change-dns-settings
path: ios/test-report/junit.xml

- name: Checkout repository to get the current app version
uses: actions/checkout@v4

- name: Verify DNS settings still changed on current app version
uses: ./.github/actions/ios-end-to-end-tests
if: always()
with:
ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }}
test_device_identifier_uuid: ${{ secrets.IOS_TEST_DEVICE_IDENTIFIER_UUID }}
has_time_account_number: ${{ secrets.IOS_HAS_TIME_ACCOUNT_NUMBER_PRODUCTION }}
no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }}
test_device_udid: ${{ env.TEST_DEVICE_UDID }}
partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }}
xcode_test_plan: 'MullvadVPNUITestsVerifyDNSSettingsChanged'
uninstall_app:
name: Uninstall Old App
runs-on:
- self-hosted
- macOS
- ios-test
needs: set_commit_hash
env:
TEST_DEVICE_UDID: 00008130-0019181022F3803A
steps:
- name: Install ios-deploy
run: brew install ios-deploy

- name: Store test report for verifying DNS settings
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report-verify-dns-settings
path: ios/test-report/junit.xml
- name: Verify Device Connection
run: ios-deploy --detect

- name: Checkout old repository version
uses: actions/checkout@v4
with:
ref: ${{ env.OLD_APP_COMMIT_HASH }}
- name: Uninstall Old App from Device
timeout-minutes: 10
run: ios-deploy --id ${{ env.TEST_DEVICE_UDID }} --uninstall_only --bundle_id net.mullvad.MullvadVPN

- name: Change all other settings on old app version
uses: ./.github/actions/ios-end-to-end-tests
if: always()
with:
ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }}
test_device_identifier_uuid: ${{ secrets.IOS_TEST_DEVICE_IDENTIFIER_UUID }}
has_time_account_number: ${{ secrets.IOS_HAS_TIME_ACCOUNT_NUMBER_PRODUCTION }}
no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }}
test_device_udid: ${{ env.TEST_DEVICE_UDID }}
partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }}
xcode_test_plan: 'MullvadVPNUITestsChangeSettings'
- name: Verify Uninstallation
run: |
if ios-deploy --id ${{ env.TEST_DEVICE_UDID }} --list | grep net.mullvad.MullvadVPN; then
echo "Uninstallation failed."
exit 1
else
echo "App successfully uninstalled."
fi
- name: Store test report for changing all settings
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report-change-all-other-settings
path: ios/test-report/junit.xml
change_dns_settings:
name: Change DNS Settings on Old App Version
uses: ./.github/workflows/ios-end-to-end-tests.yml
needs:
- set_commit_hash
- uninstall_app
with:
arg_tests_json_key: "mullvadVPNUITestsChangeDNSSettings"
commit_hash: ${{ needs.set_commit_hash.outputs.old_app_commit_hash }}
secrets: inherit

- name: Checkout repository to get the current app version
uses: actions/checkout@v4
verify_dns_settings:
name: Verify DNS Settings on Current App Version
needs:
- change_dns_settings
uses: ./.github/workflows/ios-end-to-end-tests.yml
with:
arg_tests_json_key: "mullvadVPNUITestsVerifyDNSSettingsChanged"
secrets: inherit

- name: Verify all other settings still changed on current app version
uses: ./.github/actions/ios-end-to-end-tests
if: always()
with:
ios_device_pin_code: ${{ secrets.IOS_DEVICE_PIN_CODE }}
test_device_identifier_uuid: ${{ secrets.IOS_TEST_DEVICE_IDENTIFIER_UUID }}
has_time_account_number: ${{ secrets.IOS_HAS_TIME_ACCOUNT_NUMBER_PRODUCTION }}
no_time_account_number: ${{ secrets.IOS_NO_TIME_ACCOUNT_NUMBER_PRODUCTION }}
test_device_udid: ${{ env.TEST_DEVICE_UDID }}
partner_api_token: ${{ secrets.STAGEMOLE_PARTNER_AUTH }}
xcode_test_plan: 'MullvadVPNUITestsVerifySettingsChanged'
change_other_settings:
name: Change All Other Settings on Old App Version
needs:
- set_commit_hash
- verify_dns_settings
uses: ./.github/workflows/ios-end-to-end-tests.yml
with:
arg_tests_json_key: "mullvadVPNUITestsChangeSettings"
commit_hash: ${{ needs.set_commit_hash.outputs.old_app_commit_hash }}
secrets: inherit

- name: Store test report for verifying all other settings
uses: actions/upload-artifact@v4
if: always()
with:
name: test-report-verify-all-other-settings
path: ios/test-report/junit.xml
verify_other_settings:
name: Verify All Other Settings on Current App Version
needs:
- change_other_settings
uses: ./.github/workflows/ios-end-to-end-tests.yml
with:
arg_tests_json_key: "mullvadVPNUITestsVerifySettingsChanged"
secrets: inherit
16 changes: 0 additions & 16 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,6 @@
8529693A2B4F0238007EAD4C /* TermsOfServicePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 852969392B4F0238007EAD4C /* TermsOfServicePage.swift */; };
8529693C2B4F0257007EAD4C /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8529693B2B4F0257007EAD4C /* Alert.swift */; };
852A26462BA9C9CB006EB9C8 /* DNSSettingsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 852A26452BA9C9CB006EB9C8 /* DNSSettingsPage.swift */; };
852BC66F2BAB44F500A47558 /* MullvadVPNUITestsVerifySettingsChanged.xctestplan in Resources */ = {isa = PBXBuildFile; fileRef = 852BC66C2BAB44F500A47558 /* MullvadVPNUITestsVerifySettingsChanged.xctestplan */; };
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 */; };
Expand Down Expand Up @@ -1955,10 +1951,6 @@
852969392B4F0238007EAD4C /* TermsOfServicePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServicePage.swift; sourceTree = "<group>"; };
8529693B2B4F0257007EAD4C /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
852A26452BA9C9CB006EB9C8 /* DNSSettingsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DNSSettingsPage.swift; sourceTree = "<group>"; };
852BC66C2BAB44F500A47558 /* MullvadVPNUITestsVerifySettingsChanged.xctestplan */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MullvadVPNUITestsVerifySettingsChanged.xctestplan; sourceTree = "<group>"; };
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>"; };
Expand Down Expand Up @@ -3857,11 +3849,7 @@
7A83C4002A55B81A00DFB83A /* MullvadVPNCI.xctestplan */,
7A02D4EA2A9CEC7A00C19E31 /* MullvadVPNScreenshots.xctestplan */,
852969302B4D9E70007EAD4C /* MullvadVPNUITestsAll.xctestplan */,
852BC6722BAB450B00A47558 /* MullvadVPNUITestsChangeDNSSettings.xctestplan */,
852BC66D2BAB44F500A47558 /* MullvadVPNUITestsChangeSettings.xctestplan */,
85006A8E2B73EF67004AD8FB /* MullvadVPNUITestsSmoke.xctestplan */,
852BC66E2BAB44F500A47558 /* MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan */,
852BC66C2BAB44F500A47558 /* MullvadVPNUITestsVerifySettingsChanged.xctestplan */,
);
path = TestPlans;
sourceTree = "<group>";
Expand Down Expand Up @@ -5052,10 +5040,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
852BC66F2BAB44F500A47558 /* MullvadVPNUITestsVerifySettingsChanged.xctestplan in Resources */,
852BC6712BAB44F500A47558 /* MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan in Resources */,
852BC6702BAB44F500A47558 /* MullvadVPNUITestsChangeSettings.xctestplan in Resources */,
852BC6732BAB450B00A47558 /* MullvadVPNUITestsChangeDNSSettings.xctestplan in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@
reference = "container:TestPlans/MullvadVPNUITestsAll.xctestplan"
default = "YES">
</TestPlanReference>
<TestPlanReference
reference = "container:TestPlans/MullvadVPNUITestsVerifyDNSSettingsChanged.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:TestPlans/MullvadVPNUITestsChangeSettings.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:TestPlans/MullvadVPNUITestsVerifySettingsChanged.xctestplan">
</TestPlanReference>
<TestPlanReference
reference = "container:TestPlans/MullvadVPNUITestsChangeDNSSettings.xctestplan">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
Expand Down
30 changes: 0 additions & 30 deletions ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ class VPNSettingsPage: Page {
.tap()
return self
}

@discardableResult func tapMultihopSwitch() -> Self {
app.cells[AccessibilityIdentifier.multihopSwitch]
.switches[AccessibilityIdentifier.customSwitch]
.tap()
return self
}

@discardableResult func verifyCustomWireGuardPortSelected(portNumber: String) -> Self {
let cell = app.cells[AccessibilityIdentifier.wireGuardCustomPort]
XCTAssertTrue(cell.isSelected)
Expand Down Expand Up @@ -164,26 +156,4 @@ class VPNSettingsPage: Page {
XCTAssertTrue(cell.isSelected)
return self
}

@discardableResult func verifyMultihopSwitchOn() -> Self {
let switchElement = app.cells[.multihopSwitch]
.switches[AccessibilityIdentifier.customSwitch]

guard let switchValue = switchElement.value as? String else {
XCTFail("Failed to read switch state")
return self
}

XCTAssertEqual(switchValue, "1")
return self
}

@discardableResult func tapMultihopSwitchIfOn() -> Self {
let switchElement = app.cells[.multihopSwitch].switches[AccessibilityIdentifier.customSwitch]

if switchElement.value as? String == "1" {
tapMultihopSwitch()
}
return self
}
}
38 changes: 1 addition & 37 deletions ios/MullvadVPNUITests/RelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,43 +245,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
.tapDisconnectButton()
}

func testMultihopSettings() throws {
// Undo enabling Multihop in teardown
addTeardownBlock {
HeaderBar(self.app)
.tapSettingsButton()

SettingsPage(self.app)
.tapVPNSettingsCell()

VPNSettingsPage(self.app)
.tapMultihopSwitchIfOn()
}

HeaderBar(app)
.tapSettingsButton()

SettingsPage(app)
.tapVPNSettingsCell()

VPNSettingsPage(app)
.tapMultihopSwitch()
.tapBackButton()

SettingsPage(app)
.tapDoneButton()

TunnelControlPage(app)
.tapSecureConnectionButton()

allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.verifyConnectingOverMultihop()
.tapDisconnectButton()
}


/// Connect to a relay in the default country and city, get name and IP address of the relay the app successfully connects to. Assumes user is logged on and at tunnel control page.
private func getDefaultRelayInfo() -> RelayInfo {
TunnelControlPage(app)
Expand Down
2 changes: 0 additions & 2 deletions ios/MullvadVPNUITests/SettingsMigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class SettingsMigrationTests: BaseUITestCase {
.tapUDPOverTCPPort80Cell()
.tapQuantumResistantTunnelExpandButton()
.tapQuantumResistantTunnelOnCell()
.tapMultihopSwitch()
}

func testVerifySettingsStillChanged() {
Expand Down Expand Up @@ -153,6 +152,5 @@ class SettingsMigrationTests: BaseUITestCase {
.verifyUDPOverTCPPort80Selected()
.tapQuantumResistantTunnelExpandButton()
.verifyQuantumResistantTunnelOnSelected()
.verifyMultihopSwitchOn()
}
}
Loading

0 comments on commit 0420524

Please sign in to comment.