Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIA-986: Dashboard Connection Details Tests #50

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions PIA VPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
2985E5671856BD1200D70E28 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2985E5661856BD1200D70E28 /* QuartzCore.framework */; };
299E58511856BD31004CFD63 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 299E58501856BD31004CFD63 /* SystemConfiguration.framework */; };
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 */; };
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 @@ -839,6 +841,8 @@
2985E5661856BD1200D70E28 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
299E58501856BD31004CFD63 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
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>"; };
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 @@ -1658,6 +1662,7 @@
35EDD65B2B047839007B9ACB /* QuickSettingsTests.swift */,
35DC7A5D2B0B325700502BED /* VPNServerListTests.swift */,
35C8064B2B1075620078A2C6 /* ServerConnectionTests.swift */,
3510B3B62B2F9C2D0004851B /* DashboardTests.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand All @@ -1673,6 +1678,7 @@
35EDD6432AE7B480007B9ACB /* Common.swift */,
35EDD6592B035B51007B9ACB /* SideMenuScreen.swift */,
35DC7A5F2B0B440200502BED /* RegionSelectionScreen.swift */,
3510B3B82B2FB3A40004851B /* EditDashboardScreen.swift */,
);
path = Screens;
sourceTree = "<group>";
Expand Down Expand Up @@ -3320,9 +3326,11 @@
699F23B92AFBAC0B00EBC5E6 /* SettingsTests.swift in Sources */,
699F23B42AFBA66000EBC5E6 /* AutomationSettingsScreen.swift in Sources */,
35EDD62A2ADE5F08007B9ACB /* SignInTests.swift in Sources */,
3510B3B92B2FB3A40004851B /* EditDashboardScreen.swift in Sources */,
69B70AB52ACBF51C0072A09D /* LoginScreen.swift in Sources */,
35EDD65C2B047839007B9ACB /* QuickSettingsTests.swift in Sources */,
35EDD6332ADE7281007B9ACB /* OnboardingTests.swift in Sources */,
3510B3B72B2F9C2D0004851B /* DashboardTests.swift in Sources */,
699F23B52AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift in Sources */,
69B70AC02ACC2CFE0072A09D /* AccessibilityId.swift in Sources */,
35DC7A5E2B0B325700502BED /* VPNServerListTests.swift in Sources */,
Expand Down
7 changes: 4 additions & 3 deletions PIA VPN/Settings/SettingPopoverSelectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extension TransportPopoverSelectionView: UITableViewDelegate, UITableViewDataSou
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

self.accessibilityIdentifier = "TransportPopoverSelectionView"
guard let cell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) else {
fatalError("no transport available")
}
Expand Down Expand Up @@ -203,6 +203,7 @@ extension PortPopoverSelectionView: UITableViewDelegate, UITableViewDataSource {
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
self.accessibilityIdentifier = "PortPopoverSelectionView"

guard let cell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) else {
fatalError("no transport available")
Expand Down Expand Up @@ -260,7 +261,7 @@ extension DataEncryptionPopoverSelectionView: UITableViewDelegate, UITableViewDa
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

self.accessibilityIdentifier = "DataEncryptionPopoverSelectionView"
guard let cell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) else {
fatalError("no transport available")
}
Expand Down Expand Up @@ -313,7 +314,7 @@ extension HandshakePopoverSelectionView: UITableViewDelegate, UITableViewDataSou
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

self.accessibilityIdentifier = "HandshakePopoverSelectionView"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

guard let cell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) else {
fatalError("no transport available")
}
Expand Down
1 change: 1 addition & 0 deletions PIA VPN/Tiles/ConnectionTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ConnectionTileCollectionViewCell: UICollectionViewCell, TileableCell {
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier = "ConnectionTileCollectionViewCell"
Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
2 changes: 2 additions & 0 deletions PIA VPN/Tiles/FavoriteServersTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class FavoriteServersTileCollectionViewCell: UICollectionViewCell, TileableCell,
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier = "FavoriteServersTileCollectionViewCell"

Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
2 changes: 2 additions & 0 deletions PIA VPN/Tiles/IPTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class IPTileCollectionViewCell: UICollectionViewCell, TileableCell {
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier = "IPTileCollectionViewCell"

Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
2 changes: 2 additions & 0 deletions PIA VPN/Tiles/QuickConnectTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class QuickConnectTileCollectionViewCell: UICollectionViewCell, TileableCell, Se
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier="QuickConnectTileCollectionViewCell"

Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
1 change: 1 addition & 0 deletions PIA VPN/Tiles/SubscriptionTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SubscriptionTileCollectionViewCell: UICollectionViewCell, TileableCell {
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier = "SubscriptionTileCollectionViewCell"
Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
1 change: 1 addition & 0 deletions PIA VPN/Tiles/UsageTileCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class UsageTileCollectionViewCell: UICollectionViewCell, TileableCell {
private var currentTileStatus: TileStatus?

func setupCellForStatus(_ status: TileStatus) {
self.accessibilityIdentifier = "UsageTileCollectionViewCell"
Theme.current.applyPrincipalBackground(self)
Theme.current.applyPrincipalBackground(self.contentView)
self.accessoryImageRight.image = Theme.current.dragDropImage()
Expand Down
9 changes: 8 additions & 1 deletion PIA-VPN_E2E_Tests/Helpers/ElementHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ extension XCUIApplication {
return switches[id]
}

func findButtonWithPartialText(_ partialText: String) -> XCUIElement? {
func findElementWithPartialText(_ partialText: String) -> XCUIElement? {
let predicate = NSPredicate(format: "label CONTAINS[c] %@", partialText)
let matchingStaticTexts = staticTexts.matching(predicate)

return matchingStaticTexts.firstMatch
}
}

extension XCUIElement {
func findChildElement(matching elementType: XCUIElement.ElementType, identifier: String) -> XCUIElement? {
let childElementQuery = descendants(matching: elementType).matching(identifier: identifier)
return childElementQuery.element
}
}

41 changes: 41 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/EditDashboardScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// EditDashboardScreen.swift
// PIA-VPN_E2E_Tests
//
// Created by Geneva Parayno on 18/12/23.
// Copyright © 2023 Private Internet Access Inc. All rights reserved.
//

import XCTest

extension XCUIApplication {
var quickConnectTileCell: XCUIElement {
cell(with: "QuickConnectTileCollectionViewCell")
}

var ipTileCell: XCUIElement {
cell(with: "IPTileCollectionViewCell")
}

var subscriptionTileCell: XCUIElement {
cell(with: "SubscriptionTileCollectionViewCell")
}

var usageTileCell: XCUIElement {
cell(with: "UsageTileCollectionViewCell")
}

var favoriteServersTileCell: XCUIElement {
cell(with: "FavoriteServersTileCollectionViewCell")
}

var connectionTileCell: XCUIElement {
cell(with: "ConnectionTileCollectionViewCell")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call adding the accesibilityIdentifiers in all those elements 👍


func navigateToEditDashboardScreen () {
guard dashboardEditButton.exists else { return }
dashboardEditButton.tap()
WaitHelper.waitForElementToNotBeVisible(regionTileCell, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("RegionTileCollectionViewCell is not visible")})
}
}
33 changes: 6 additions & 27 deletions PIA-VPN_E2E_Tests/Screens/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ extension XCUIApplication {
button(with: PIALibraryAccessibility.Id.Dashboard.menu)
}

var dashboardEditButton: XCUIElement{
button(with: "Edit")
}

var connectionButton: XCUIElement {
button(with: AccessibilityId.Dashboard.connectionButton)
}
Expand Down Expand Up @@ -53,7 +57,7 @@ extension XCUIApplication {
button(with: "Disable VPN Kill Switch")
}

var vpnServerButton: XCUIElement {
var regionTileCell: XCUIElement {
cell(with: "RegionTileCollectionViewCell")
}

Expand All @@ -71,35 +75,10 @@ extension XCUIApplication {
}
}

func navigateToSettings() {
guard dashboardMenuButton.exists else { return }
dashboardMenuButton.tap()

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

func navigateToHomeFromSettings() {
if settingsBackButton.waitForExistence(timeout: defaultTimeout) {
settingsBackButton.tap()
navigateToHome()
}
}

func navigateToQuickSettings() {
quickSettingsButton.staticTexts["QUICK SETTINGS"].tap()
}

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

func navigateToRegionSelection(){
guard vpnServerButton.exists else { return }
vpnServerButton.tap()
onSuccess:{print("successful navigation to Home screen")}, onFailure:{error in print("dashboardMenuButton is not visible")})
}

func enableVPNKillSwitchOnHome() {
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 @@ -51,7 +51,7 @@ extension XCUIApplication {
swipeUp()

WaitHelper.waitForElementToBeVisible(connectionButton, timeout: defaultTimeout,
onSuccess:{print("successful login")}, onFailure:{error in print("connectionButton is not visible")})
onSuccess:{}, onFailure:{error in print("connectionButton is not visible")})

}
}
11 changes: 11 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/RegionSelectionScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import XCTest

extension XCUIApplication {
var regionSelectionHeader: XCUIElement {
searchField(with: "Region selection")
}

var searchRegionField: XCUIElement {
searchField(with: "Search for a region")
}
Expand All @@ -25,6 +29,13 @@ extension XCUIApplication {
staticText(with: "SORT REGIONS BY")
}

func navigateToRegionSelection(){
guard regionTileCell.exists 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")})
}

func searchRegion(regionName: String) -> XCUIElementQuery {
while(!searchRegionField.isHittable) {
swipeDown()
Expand Down
4 changes: 2 additions & 2 deletions PIA-VPN_E2E_Tests/Screens/Settings/HelpSettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ extension XCUIApplication {
}

var versionNo: XCUIElement {
findButtonWithPartialText("Version")!
findElementWithPartialText("Version")!
}

var tryWireguardNowButton: XCUIElement {
findButtonWithPartialText("Try WireGuard® now")!
findElementWithPartialText("Try WireGuard® now")!
}

func navigateToHelpSettings() {
Expand Down
48 changes: 48 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/ProtocolsSettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@ extension XCUIApplication {
staticText(with: "Data Encryption")
}

var dataEncryptionPopover: XCUIElement {
otherElement(with: "DataEncryptionPopoverSelectionView")
}

var handshakeButton: XCUIElement {
staticText(with: "Handshake")
}

var handshakePopover: XCUIElement {
otherElement(with: "HandshakePopoverSelectionView")
}

var transportButton: XCUIElement {
staticText(with: "Transport")
}

var transportPopover: XCUIElement {
otherElement(with: "TransportPopoverSelectionView")
}

var remotePortButton: XCUIElement {
staticText(with: "Remote Port")
}

var remotePortPopover: XCUIElement {
otherElement(with: "PortPopoverSelectionView")
}

var useSmallPacketsSwitch: XCUIElement {
switches(with: "Use Small Packets")
}
Expand Down Expand Up @@ -59,7 +83,31 @@ extension XCUIApplication {
guard protocolSelectionPopover.exists else {return}
protocolSelectionPopover.staticTexts[protocolName].tap()
}

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

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

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

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

func enableSmallPackets() {
if ((useSmallPacketsSwitch.value as! String) != "1") {
useSmallPacketsSwitch.tap()
Expand Down
4 changes: 4 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/QuickSettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ extension XCUIApplication {
cells.containing(.staticText, identifier: "Private Browser").firstMatch.switches.firstMatch
}

func navigateToQuickSettings() {
quickSettingsButton.staticTexts["QUICK SETTINGS"].tap()
}

func enableVPNKillSwitchQuickSetting() {
if(vpnKillSwitchQuickSettings.value as! String == "0"){
vpnKillSwitchQuickSettings.tap()
Expand Down
16 changes: 16 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/SettingsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ extension XCUIApplication {
var settingsBackButton: XCUIElement {
button(with: "Settings")
}

func navigateToSettings() {
guard dashboardMenuButton.exists else { return }
dashboardMenuButton.tap()

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

func navigateToHomeFromSettings() {
if settingsBackButton.waitForExistence(timeout: defaultTimeout) {
settingsBackButton.tap()
navigateToHome()
}
}
}
Loading
Loading