From f6500bfee41c5f8238d303488b916b13b5b13337 Mon Sep 17 00:00:00 2001 From: Geneva Parayno Date: Wed, 13 Dec 2023 09:56:52 +0800 Subject: [PATCH] PIA-984 Add Protocol Connection Tests --- .../Settings/ProtocolsSettingsScreen.swift | 28 +++++++- .../Tests/ServerConnectionTests.swift | 68 ++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift b/PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift index 3fcd08a7..1ef4a919 100644 --- a/PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift +++ b/PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift @@ -13,6 +13,10 @@ extension XCUIApplication { staticText(with: "Protocol Selection") } + var protocolSelectionPopover: XCUIElement { + otherElement(with: "ProtocolPopoverSelectionView") + } + var dataEncryptionButton: XCUIElement { staticText(with: "Data Encryption") } @@ -22,7 +26,7 @@ extension XCUIApplication { } var useSmallPacketsSwitch: XCUIElement { - switches(with: "User Small Packets") + switches(with: "Use Small Packets") } var openVPN: XCUIElement { @@ -33,6 +37,10 @@ extension XCUIApplication { staticText(with: "IPSec (IKEv2)") } + var wireguard: XCUIElement { + staticText(with: "WireGuard®") + } + func navigateToProtocolSettings() { guard dashboardMenuButton.exists else { return } dashboardMenuButton.tap() @@ -45,4 +53,22 @@ extension XCUIApplication { protocolsSettingsButton.tap() } } + + func selectProtocol(protocolName: String) { + protocolSelectionButton.tap() + guard protocolSelectionPopover.exists else {return} + protocolSelectionPopover.staticTexts[protocolName].tap() + } + + func enableSmallPackets() { + if ((useSmallPacketsSwitch.value as! String) != "1") { + useSmallPacketsSwitch.tap() + } + } + + func disableSmallPackets() { + if ((useSmallPacketsSwitch.value as! String) != "0") { + useSmallPacketsSwitch.tap() + } + } } diff --git a/PIA-VPN_E2E_Tests/Tests/ServerConnectionTests.swift b/PIA-VPN_E2E_Tests/Tests/ServerConnectionTests.swift index fd0fd4aa..8b821569 100644 --- a/PIA-VPN_E2E_Tests/Tests/ServerConnectionTests.swift +++ b/PIA-VPN_E2E_Tests/Tests/ServerConnectionTests.swift @@ -15,6 +15,10 @@ class ServerConnectionTests : BaseTest { describe("server connection tests") { context("when the user navigates to homescreen upon logging in") { it("should display the vpn server defaulted to 'Automatic'") { + app.logOut() + app.navigateToLoginScreen() + app.logIn(with: CredentialsUtil.credentials(type: .valid)) + app.acceptVPNPermission() expect(app.vpnServerButton.staticTexts["Automatic"].exists).to(beTrue()) } @@ -36,10 +40,72 @@ class ServerConnectionTests : BaseTest { app.disconnectToVPN() app.navigateToRegionSelection() app.searchRegion(regionName: "Philippines").firstMatch.tap() - expect(app.connectedStatusLabel.exists).to(beTrue()) + expect(app.connectedStatusLabel.waitForExistence(timeout: app.defaultTimeout)).to(beTrue()) expect(app.vpnServerButton.staticTexts["Philippines"].exists).to(beTrue()) } } + + context("when the user changes protocol type") { + it("should connect the user to vpn successfully when the user enables small packet for IPSec(IKEv2)") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.enableSmallPackets() + app.selectProtocol(protocolName: "IPSec (IKEv2)") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + + it("should connect the user to vpn successfully when the user disables small packet for IPSec(IKEv2)") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.disableSmallPackets() + app.selectProtocol(protocolName: "IPSec (IKEv2)") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + + it("should connect the user to vpn successfully when the user enables small packet for Wireguard") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.enableSmallPackets() + app.selectProtocol(protocolName: "WireGuard®") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + + it("should connect the user to vpn successfully when the user disables small packet for Wireguard") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.disableSmallPackets() + app.selectProtocol(protocolName: "WireGuard®") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + + it("should connect the user to vpn successfully when the user enables small packet for OpenVPN") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.enableSmallPackets() + app.selectProtocol(protocolName: "OpenVPN") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + + it("should connect the user to vpn successfully when the user disables small packet for OpenVPN") { + app.disconnectToVPN() + app.navigateToProtocolSettings() + app.disableSmallPackets() + app.selectProtocol(protocolName: "OpenVPN") + app.navigateToHomeFromSettings() + app.connectToVPN() + expect(app.connectedStatusLabel.exists).to(beTrue()) + } + } } } }