Skip to content

Commit

Permalink
PIA-984 Add Protocol Connection Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-geneva-parayno committed Dec 13, 2023
1 parent 4eb986d commit f6500bf
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
28 changes: 27 additions & 1 deletion PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ extension XCUIApplication {
staticText(with: "Protocol Selection")
}

var protocolSelectionPopover: XCUIElement {
otherElement(with: "ProtocolPopoverSelectionView")
}

var dataEncryptionButton: XCUIElement {
staticText(with: "Data Encryption")
}
Expand All @@ -22,7 +26,7 @@ extension XCUIApplication {
}

var useSmallPacketsSwitch: XCUIElement {
switches(with: "User Small Packets")
switches(with: "Use Small Packets")
}

var openVPN: XCUIElement {
Expand All @@ -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()
Expand All @@ -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()
}
}
}
68 changes: 67 additions & 1 deletion PIA-VPN_E2E_Tests/Tests/ServerConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand All @@ -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())
}
}
}
}
}

0 comments on commit f6500bf

Please sign in to comment.