Skip to content

Commit

Permalink
Added Dedicated IP Tests; Optimised elements and methods on test scre…
Browse files Browse the repository at this point in the history
…en classes (#57)
  • Loading branch information
kp-geneva-parayno authored Jan 9, 2024
1 parent db0d80b commit 28d3363
Show file tree
Hide file tree
Showing 22 changed files with 264 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
env:
TEST_RUNNER_PIA_TEST_USER: ${{ secrets.PIA_ACCOUNT_USERNAME}}
TEST_RUNNER_PIA_TEST_PASSWORD: ${{ secrets.PIA_ACCOUNT_PASSWORD }}
TEST_RUNNER_PIA_TEST_DEDICATEDIP: ${{ secrets.PIA_TEST_DEDICATEDIP }}

steps:
- name: Setup Git credentials
Expand Down
12 changes: 12 additions & 0 deletions PIA VPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@
299E585F1856C6EE004CFD63 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 299E585E1856C6EE004CFD63 /* libz.dylib */; };
3510B3B72B2F9C2D0004851B /* DashboardTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3510B3B62B2F9C2D0004851B /* DashboardTests.swift */; };
3510B3B92B2FB3A40004851B /* EditDashboardScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3510B3B82B2FB3A40004851B /* EditDashboardScreen.swift */; };
3510B3BB2B4394A80004851B /* DedicatedIPTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3510B3BA2B4394A80004851B /* DedicatedIPTests.swift */; };
3510B3BD2B439B930004851B /* DedicatedIPUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3510B3BC2B439B930004851B /* DedicatedIPUtil.swift */; };
3510B3BF2B439D590004851B /* DedicatedIPScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3510B3BE2B439D590004851B /* DedicatedIPScreen.swift */; };
3524670B26B431B800E3F0AC /* TrustedNetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3524670A26B431B800E3F0AC /* TrustedNetworkHelper.swift */; };
3524670C26B432BC00E3F0AC /* TrustedNetworkHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3524670A26B431B800E3F0AC /* TrustedNetworkHelper.swift */; };
3524670E26B432ED00E3F0AC /* DashboardViewController+ServerSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3524670D26B432ED00E3F0AC /* DashboardViewController+ServerSelection.swift */; };
Expand Down Expand Up @@ -912,6 +915,9 @@
299E585E1856C6EE004CFD63 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
3510B3B62B2F9C2D0004851B /* DashboardTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardTests.swift; sourceTree = "<group>"; };
3510B3B82B2FB3A40004851B /* EditDashboardScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditDashboardScreen.swift; sourceTree = "<group>"; };
3510B3BA2B4394A80004851B /* DedicatedIPTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DedicatedIPTests.swift; sourceTree = "<group>"; };
3510B3BC2B439B930004851B /* DedicatedIPUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DedicatedIPUtil.swift; sourceTree = "<group>"; };
3510B3BE2B439D590004851B /* DedicatedIPScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DedicatedIPScreen.swift; sourceTree = "<group>"; };
3524670A26B431B800E3F0AC /* TrustedNetworkHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustedNetworkHelper.swift; sourceTree = "<group>"; };
3524670D26B432ED00E3F0AC /* DashboardViewController+ServerSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DashboardViewController+ServerSelection.swift"; sourceTree = "<group>"; };
3545E97F26AAD60C00B812CC /* ServerSelectionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSelectionDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1787,6 +1793,7 @@
35DC7A5D2B0B325700502BED /* VPNServerListTests.swift */,
35C8064B2B1075620078A2C6 /* ServerConnectionTests.swift */,
3510B3B62B2F9C2D0004851B /* DashboardTests.swift */,
3510B3BA2B4394A80004851B /* DedicatedIPTests.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand All @@ -1803,6 +1810,7 @@
35EDD6592B035B51007B9ACB /* SideMenuScreen.swift */,
35DC7A5F2B0B440200502BED /* RegionSelectionScreen.swift */,
3510B3B82B2FB3A40004851B /* EditDashboardScreen.swift */,
3510B3BE2B439D590004851B /* DedicatedIPScreen.swift */,
);
path = Screens;
sourceTree = "<group>";
Expand Down Expand Up @@ -1987,6 +1995,7 @@
isa = PBXGroup;
children = (
7EC2972D27D8B8580061C56A /* CredentialsUtil.swift */,
3510B3BC2B439B930004851B /* DedicatedIPUtil.swift */,
);
path = Util;
sourceTree = "<group>";
Expand Down Expand Up @@ -3678,6 +3687,7 @@
35EDD6282ADE5D31007B9ACB /* BaseTest.swift in Sources */,
35EDD65E2B048C68007B9ACB /* QuickSettingsScreen.swift in Sources */,
35EDD65A2B035B51007B9ACB /* SideMenuScreen.swift in Sources */,
3510B3BB2B4394A80004851B /* DedicatedIPTests.swift in Sources */,
35EDD6352ADE7424007B9ACB /* VPNPermissionScreen.swift in Sources */,
35C8064C2B1075620078A2C6 /* ServerConnectionTests.swift in Sources */,
699F23B32AFBA66000EBC5E6 /* HelpSettingsScreen.swift in Sources */,
Expand All @@ -3688,6 +3698,8 @@
35DC7A602B0B440200502BED /* RegionSelectionScreen.swift in Sources */,
699F23B22AFBA66000EBC5E6 /* SettingsScreen.swift in Sources */,
35EDD6422AE7A83D007B9ACB /* WelcomeScreen.swift in Sources */,
3510B3BD2B439B930004851B /* DedicatedIPUtil.swift in Sources */,
3510B3BF2B439D590004851B /* DedicatedIPScreen.swift in Sources */,
699F23B92AFBAC0B00EBC5E6 /* SettingsTests.swift in Sources */,
699F23B42AFBA66000EBC5E6 /* AutomationSettingsScreen.swift in Sources */,
35EDD62A2ADE5F08007B9ACB /* SignInTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
value = "xxx"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "PIA_TEST_DEDICATEDIP"
value = "xxx"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
2 changes: 1 addition & 1 deletion PIA VPN/DedicatedIpRowViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DedicatedIpRowViewCell: UITableViewCell, Restylable {
private weak var server: Server!

func fill(withServer server: Server) {

self.accessibilityIdentifier = "DedicatedIpRowViewCell"
viewShouldRestyle()
self.server = server

Expand Down
71 changes: 71 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/DedicatedIPScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// DedicatedIPScreen.swift
// PIA-VPN_E2E_Tests
//
// Created by Geneva Parayno on 2/1/24.
// Copyright © 2024 Private Internet Access Inc. All rights reserved.
//

import XCTest

extension XCUIApplication {
var dedicatedIPHeader: XCUIElement {
staticText(with: "Dedicated IP")
}

var dedicatedIPTextField: XCUIElement {
textField(with: "The textfield to type the Dedicated IP token")
}

var dedicatedIPList: XCUIElement {
cell(with: "DedicatedIpRowViewCell")
}

var invalidTokenErrorMessage: XCUIElement {
staticText(with: "Your token is invalid. Please make sure you have entered the token correctly.")
}

var emptyTokenErrorMessage: XCUIElement {
staticText(with: "Please make sure you have entered the token correctly")
}

var deleteTokenButton: XCUIElement {
button(with: "Delete")
}

var confirmDeleteButton: XCUIElement {
staticText(with: "OK")
}

func navigateToDedicatedIPScreen() {
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else {return}
dashboardMenuButton.tap()

if dedicatedIPButton.waitForExistence(timeout: defaultTimeout) {
dedicatedIPButton.tap()
}

WaitHelper.waitForElementToBeVisible(dedicatedIPHeader, timeout: defaultTimeout,
onSuccess:{print("successful navigation to dedicated ip screen")}, onFailure:{error in print("dedicatedIPHeader is not visible")})
}

func activateDedicatedIP (with dedicatedIP:DedicatedIP) {
guard dedicatedIPTextField.waitForExistence(timeout: defaultTimeout) else {return}
dedicatedIPTextField.tap()
dedicatedIPTextField.typeText(dedicatedIP.token)
button(with:"Activate").tap()
dedicatedIPList.waitForExistence(timeout: defaultTimeout)
}

func deleteDedicatedIP() {
guard dedicatedIPList.waitForExistence(timeout: defaultTimeout) else {return}

let pressDuration: TimeInterval = 1.0
let sourceCoordinate = dedicatedIPList.coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.5))
let leftmostCoordinate = coordinate(withNormalizedOffset: CGVector(dx: 0.01, dy: 0.5))
sourceCoordinate.press(forDuration: pressDuration, thenDragTo: leftmostCoordinate)

confirmDeleteButton.tap()
dedicatedIPTextField.waitForExistence(timeout: defaultTimeout)
}
}
2 changes: 1 addition & 1 deletion PIA-VPN_E2E_Tests/Screens/EditDashboardScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension XCUIApplication {
}

func navigateToEditDashboardScreen () {
guard dashboardEditButton.exists else { return }
guard dashboardEditButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardEditButton.tap()
WaitHelper.waitForElementToNotBeVisible(regionTileCell, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("RegionTileCollectionViewCell is not visible")})
}
Expand Down
15 changes: 8 additions & 7 deletions PIA-VPN_E2E_Tests/Screens/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension XCUIApplication {
}

func logOut() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if logOutButton.waitForExistence(timeout: defaultTimeout) {
Expand All @@ -76,43 +76,44 @@ extension XCUIApplication {
}

func navigateToHome() {
closeButton.waitForExistence(timeout: defaultTimeout)
closeButton.tap()
WaitHelper.waitForElementToBeVisible(dashboardMenuButton, timeout: defaultTimeout,
onSuccess:{print("successful navigation to Home screen")}, onFailure:{error in print("dashboardMenuButton is not visible")})
}

func enableVPNKillSwitchOnHome() {
if(enableVPNKillSwitchButton.exists) {
if(enableVPNKillSwitchButton.waitForExistence(timeout: defaultTimeout)) {
enableVPNKillSwitchButton.tap()
}
}

func disableVPNKillSwitchOnHome() {
if(disableVPNKillSwitchButton.exists) {
if(disableVPNKillSwitchButton.waitForExistence(timeout: defaultTimeout)) {
disableVPNKillSwitchButton.tap()
}
}

func enableNetworkManagementOnHome() {
if(enableNetworkManagementButton.exists) {
if(enableNetworkManagementButton.waitForExistence(timeout: defaultTimeout)) {
enableNetworkManagementButton.tap()
}
}

func disableNetworkManagementOnHome() {
if(disableNetworkManagementButton.exists) {
if(disableNetworkManagementButton.waitForExistence(timeout: defaultTimeout)) {
disableNetworkManagementButton.tap()
}
}

func connectToVPN() {
if (disconnectedStatusLabel.exists) {
if (disconnectedStatusLabel.waitForExistence(timeout: defaultTimeout)) {
connectionButton.tap()
}
}

func disconnectToVPN() {
if (connectedStatusLabel.exists) {
if (connectedStatusLabel.waitForExistence(timeout: defaultTimeout)) {
connectionButton.tap()
}
}
Expand Down
2 changes: 1 addition & 1 deletion PIA-VPN_E2E_Tests/Screens/LoginScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension XCUIApplication {
logIn(with: CredentialsUtil.credentials(type: .valid))

guard vpnPermissionScreen.waitForExistence(timeout: defaultTimeout) else { return }
guard vpnPermissionButton.exists else { return }
guard vpnPermissionButton.waitForExistence(timeout: defaultTimeout) else { return }
vpnPermissionButton.tap()

swipeUp()
Expand Down
9 changes: 6 additions & 3 deletions PIA-VPN_E2E_Tests/Screens/RegionSelectionScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension XCUIApplication {
}

func navigateToRegionSelection(){
guard regionTileCell.exists else { return }
guard regionTileCell.waitForExistence(timeout: defaultTimeout) else { return }
regionTileCell.tap()
WaitHelper.waitForElementToBeVisible(regionSelectionHeader, timeout: defaultTimeout,
onSuccess:{print("successful navigation to region selection screen")}, onFailure:{error in print("regionSelectionHeader is not visible")})
Expand All @@ -52,6 +52,9 @@ extension XCUIApplication {
}

func getRegionList() -> XCUIElementQuery {
while(!searchRegionField.isHittable) {
swipeDown()
}
let query = cells.matching(NSPredicate(format: "identifier == %@", "uitests.regions.region_name"))
return query
}
Expand All @@ -62,7 +65,7 @@ extension XCUIApplication {
let regionAddAsAFavouriteButton = region.buttons["Add a favorite region"]
let regionRemoveAsAFavouriteButton = region.buttons["Remove a favorite region"]

if(regionRemoveAsAFavouriteButton.exists) {
if(regionRemoveAsAFavouriteButton.waitForExistence(timeout: defaultTimeout)) {
regionRemoveAsAFavouriteButton.tap()
}
WaitHelper.waitForElementToBeVisible(regionAddAsAFavouriteButton, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("regionRemoveAsAFavouriteButton is not visible")})
Expand Down Expand Up @@ -90,7 +93,7 @@ extension XCUIApplication {
}

func sortRegionsBy(sortType: String) {
guard sortButton.exists else {return}
guard sortButton.waitForExistence(timeout: defaultTimeout) else {return}
sortButton.tap()
WaitHelper.waitForElementToBeVisible(sortPopUpHeader, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("sortPopUpHeader is not visible")})
button(with: sortType).tap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension XCUIApplication {
}

func navigateToAutomationSettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension XCUIApplication {
}

func navigateToGeneralSettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extension XCUIApplication {
}

func navigateToHelpSettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension XCUIApplication {
}

func navigateToPrivacySettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand Down
12 changes: 6 additions & 6 deletions PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ extension XCUIApplication {
}

func navigateToProtocolSettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand All @@ -80,31 +80,31 @@ extension XCUIApplication {

func selectProtocol(protocolName: String) {
protocolSelectionButton.tap()
guard protocolSelectionPopover.exists else {return}
guard protocolSelectionPopover.waitForExistence(timeout: defaultTimeout) else {return}
protocolSelectionPopover.staticTexts[protocolName].tap()
}

func selectDataEncryption(dataEncryption: String) {
dataEncryptionButton.tap()
guard dataEncryptionPopover.exists else {return}
guard dataEncryptionPopover.waitForExistence(timeout: defaultTimeout) else {return}
dataEncryptionPopover.staticTexts[dataEncryption].tap()
}

func selectHandshake(handshake: String) {
handshakeButton.tap()
guard handshakePopover.exists else {return}
guard handshakePopover.waitForExistence(timeout: defaultTimeout) else {return}
handshakePopover.staticTexts[handshake].tap()
}

func selectTransport(transport: String) {
transportButton.tap()
guard transportPopover.exists else {return}
guard transportPopover.waitForExistence(timeout: defaultTimeout) else {return}
transportPopover.staticTexts[transport].tap()
}

func selectRemotePort(port: String) {
remotePortButton.tap()
guard remotePortPopover.exists else {return}
guard remotePortPopover.waitForExistence(timeout: defaultTimeout) else {return}
remotePortPopover.staticTexts[port].tap()
}

Expand Down
2 changes: 1 addition & 1 deletion PIA-VPN_E2E_Tests/Screens/Settings/SettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension XCUIApplication {
}

func navigateToSettings() {
guard dashboardMenuButton.exists else { return }
guard dashboardMenuButton.waitForExistence(timeout: defaultTimeout) else { return }
dashboardMenuButton.tap()

if settingsButton.waitForExistence(timeout: defaultTimeout) {
Expand Down
4 changes: 4 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/SideMenuScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ extension XCUIApplication {
var settingsButton: XCUIElement {
staticText(with: "Settings")
}

var dedicatedIPButton: XCUIElement {
staticText(with: "Dedicated IP")
}
}
Loading

0 comments on commit 28d3363

Please sign in to comment.