Skip to content

Commit

Permalink
Merge pull request #1183 from xvpn/wip/PIA-659_E2E_UpdateSettings
Browse files Browse the repository at this point in the history
PIA-659: Added Settings E2E Tests
  • Loading branch information
kp-geneva-parayno authored Nov 9, 2023
2 parents e5d18bd + b279eae commit a2de346
Show file tree
Hide file tree
Showing 20 changed files with 430 additions and 45 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ jobs:
- name: Check fastlane env
run: cat fastlane/.env

- name: Run e2e tests with fastlane
run: bundle exec fastlane e2e_tests
continue-on-error: true

- name: Run tests
- name: Run unit tests
run: bundle exec fastlane tests

- name: Run e2e tests
run: bundle exec fastlane e2e_tests


36 changes: 36 additions & 0 deletions PIA VPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@
698F4F302ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 698F4F2F2ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift */; };
698F4F312ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 698F4F2F2ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift */; };
698F4F322ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 698F4F2F2ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift */; };
699F23B22AFBA66000EBC5E6 /* SettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23AC2AFBA66000EBC5E6 /* SettingsScreen.swift */; };
699F23B32AFBA66000EBC5E6 /* HelpSettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23AD2AFBA66000EBC5E6 /* HelpSettingsScreen.swift */; };
699F23B42AFBA66000EBC5E6 /* AutomationSettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23AE2AFBA66000EBC5E6 /* AutomationSettingsScreen.swift */; };
699F23B52AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23AF2AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift */; };
699F23B62AFBA66000EBC5E6 /* GeneralSettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23B02AFBA66000EBC5E6 /* GeneralSettingsScreen.swift */; };
699F23B72AFBA66000EBC5E6 /* PrivacySettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23B12AFBA66000EBC5E6 /* PrivacySettingsScreen.swift */; };
699F23B92AFBAC0B00EBC5E6 /* UpdateSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699F23B82AFBAC0B00EBC5E6 /* UpdateSettingsTests.swift */; };
69B70AB52ACBF51C0072A09D /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69B70AB42ACBF51C0072A09D /* LoginScreen.swift */; };
69B70ABC2ACBF8300072A09D /* CredentialsUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EC2972D27D8B8580061C56A /* CredentialsUtil.swift */; };
69B70ABE2ACC2CFE0072A09D /* AccessibilityId.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69B70ABD2ACC2CFE0072A09D /* AccessibilityId.swift */; };
Expand Down Expand Up @@ -707,6 +714,13 @@
6947AADB2ACDC8AE001BCC66 /* PIA-VPN-e2e-simulator.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = "PIA-VPN-e2e-simulator.xctestplan"; sourceTree = "<group>"; };
698F4F2C2AB978BF0010B2B0 /* PIACircleImageView.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = PIACircleImageView.swift; sourceTree = "<group>"; tabWidth = 4; };
698F4F2F2ABA1DA10010B2B0 /* PIAConnectionLiveActivityManager.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = PIAConnectionLiveActivityManager.swift; sourceTree = "<group>"; tabWidth = 4; };
699F23AC2AFBA66000EBC5E6 /* SettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsScreen.swift; sourceTree = "<group>"; };
699F23AD2AFBA66000EBC5E6 /* HelpSettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelpSettingsScreen.swift; sourceTree = "<group>"; };
699F23AE2AFBA66000EBC5E6 /* AutomationSettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutomationSettingsScreen.swift; sourceTree = "<group>"; };
699F23AF2AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProtocolsSettingsScreen.swift; sourceTree = "<group>"; };
699F23B02AFBA66000EBC5E6 /* GeneralSettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneralSettingsScreen.swift; sourceTree = "<group>"; };
699F23B12AFBA66000EBC5E6 /* PrivacySettingsScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivacySettingsScreen.swift; sourceTree = "<group>"; };
699F23B82AFBAC0B00EBC5E6 /* UpdateSettingsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateSettingsTests.swift; sourceTree = "<group>"; };
69B70AB02ACBF51C0072A09D /* PIA-VPN_E2E_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "PIA-VPN_E2E_Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
69B70AB42ACBF51C0072A09D /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
69B70ABD2ACC2CFE0072A09D /* AccessibilityId.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityId.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1283,6 +1297,7 @@
35EDD6262ADE5D1E007B9ACB /* Tests */ = {
isa = PBXGroup;
children = (
699F23B82AFBAC0B00EBC5E6 /* UpdateSettingsTests.swift */,
69C587FC2AD00C6300B95EF9 /* PIAExampleWithAuthenticatedAppTest.swift */,
35EDD6292ADE5F08007B9ACB /* SignInTests.swift */,
35EDD6322ADE7281007B9ACB /* OnboardingTests.swift */,
Expand All @@ -1293,6 +1308,7 @@
35EDD62B2ADE62FE007B9ACB /* Screens */ = {
isa = PBXGroup;
children = (
699F23AB2AFBA66000EBC5E6 /* Settings */,
69B70AB42ACBF51C0072A09D /* LoginScreen.swift */,
35EDD6342ADE7424007B9ACB /* VPNPermissionScreen.swift */,
35EDD6362ADE761A007B9ACB /* HomeScreen.swift */,
Expand All @@ -1319,6 +1335,19 @@
path = Core;
sourceTree = "<group>";
};
699F23AB2AFBA66000EBC5E6 /* Settings */ = {
isa = PBXGroup;
children = (
699F23AC2AFBA66000EBC5E6 /* SettingsScreen.swift */,
699F23AD2AFBA66000EBC5E6 /* HelpSettingsScreen.swift */,
699F23AE2AFBA66000EBC5E6 /* AutomationSettingsScreen.swift */,
699F23AF2AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift */,
699F23B02AFBA66000EBC5E6 /* GeneralSettingsScreen.swift */,
699F23B12AFBA66000EBC5E6 /* PrivacySettingsScreen.swift */,
);
path = Settings;
sourceTree = "<group>";
};
69B70AB12ACBF51C0072A09D /* PIA-VPN_E2E_Tests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2472,15 +2501,22 @@
35EDD63E2AE76A3B007B9ACB /* WaitHelper.swift in Sources */,
35EDD6282ADE5D31007B9ACB /* BaseTest.swift in Sources */,
35EDD6352ADE7424007B9ACB /* VPNPermissionScreen.swift in Sources */,
699F23B32AFBA66000EBC5E6 /* HelpSettingsScreen.swift in Sources */,
69B70ABC2ACBF8300072A09D /* CredentialsUtil.swift in Sources */,
35EDD6372ADE761A007B9ACB /* HomeScreen.swift in Sources */,
35EDD63B2AE62D15007B9ACB /* ElementHelper.swift in Sources */,
69C587FD2AD00C6300B95EF9 /* PIAExampleWithAuthenticatedAppTest.swift in Sources */,
699F23B22AFBA66000EBC5E6 /* SettingsScreen.swift in Sources */,
35EDD6422AE7A83D007B9ACB /* WelcomeScreen.swift in Sources */,
699F23B92AFBAC0B00EBC5E6 /* UpdateSettingsTests.swift in Sources */,
699F23B42AFBA66000EBC5E6 /* AutomationSettingsScreen.swift in Sources */,
35EDD62A2ADE5F08007B9ACB /* SignInTests.swift in Sources */,
69B70AB52ACBF51C0072A09D /* LoginScreen.swift in Sources */,
35EDD6332ADE7281007B9ACB /* OnboardingTests.swift in Sources */,
699F23B52AFBA66000EBC5E6 /* ProtocolsSettingsScreen.swift in Sources */,
69B70AC02ACC2CFE0072A09D /* AccessibilityId.swift in Sources */,
699F23B62AFBA66000EBC5E6 /* GeneralSettingsScreen.swift in Sources */,
699F23B72AFBA66000EBC5E6 /* PrivacySettingsScreen.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions PIA-VPN_E2E_Tests/Core/BaseTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import Quick
import Nimble
import XCTest

class BaseTest: QuickSpec{
class BaseTest: QuickSpec {
static var app: XCUIApplication!

override class func spec(){
override class func spec() {
beforeEach {
app = XCUIApplication()
app.launch()
Expand Down
6 changes: 5 additions & 1 deletion PIA-VPN_E2E_Tests/Helpers/ElementHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension XCUIApplication {
var defaultTimeout: TimeInterval { 10.0 }
var shortTimeout: TimeInterval { 5.0 }

func navigationbar(with id: String) -> XCUIElement{
func navigationbar(with id: String) -> XCUIElement {
return navigationBars[id]
}

Expand Down Expand Up @@ -51,5 +51,9 @@ extension XCUIApplication {
func image(with id: String) -> XCUIElement {
return images[id]
}

func switches(with id: String) -> XCUIElement {
return switches[id]
}
}

6 changes: 3 additions & 3 deletions PIA-VPN_E2E_Tests/Helpers/WaitHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import XCTest

enum ElementError: Error, CustomStringConvertible{
enum ElementError: Error, CustomStringConvertible {
case visibilityTimeout
case invisibilityTimeout

Expand All @@ -34,7 +34,7 @@ class WaitHelper{
onSuccess()
}

else{
else {
onFailure(.visibilityTimeout)
}
}
Expand All @@ -48,7 +48,7 @@ class WaitHelper{
onSuccess()
}

else{
else {
onFailure(.invisibilityTimeout)
}
}
Expand Down
1 change: 0 additions & 1 deletion PIA-VPN_E2E_Tests/PIA-VPN-e2e-simulator.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:PIA VPN.xcodeproj",
"identifier" : "69B70AAF2ACBF51C0072A09D",
Expand Down
2 changes: 1 addition & 1 deletion PIA-VPN_E2E_Tests/Screens/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import XCTest

extension XCUIApplication{
extension XCUIApplication {
/// Sometimes a system alert to request permissions about Notifications or VPN profile installation can appear
/// at any time when the app is running
/// This makes not possible to contitnue with the test unless the alert is dismissed
Expand Down
31 changes: 28 additions & 3 deletions PIA-VPN_E2E_Tests/Screens/HomeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import XCTest

extension XCUIApplication{
extension XCUIApplication {
var dashboardMenuButton: XCUIElement{
button(with: PIALibraryAccessibility.Id.Dashboard.menu)
}
Expand All @@ -17,14 +17,23 @@ extension XCUIApplication{
button(with: AccessibilityId.Dashboard.connectionButton)
}

var confirmationDialogButton: XCUIElement{
var confirmationDialogButton: XCUIElement {
button(with: PIALibraryAccessibility.Id.Dialog.destructive)
}

var logOutButton: XCUIElement{
var logOutButton: XCUIElement {
staticText(with: "Log out")
}

var settingsButton: XCUIElement {
staticText(with: "Settings")
}

var settingsBackButton: XCUIElement {
button(with: "Settings")
}


func logOut() {
guard dashboardMenuButton.exists else { return }
dashboardMenuButton.tap()
Expand All @@ -37,4 +46,20 @@ extension XCUIApplication{
welcomeLoginButton.waitForExistence(timeout: defaultTimeout)
}
}

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

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

func navigateToHomeScreenFromSettings() {
if settingsBackButton.waitForExistence(timeout: defaultTimeout) {
settingsBackButton.tap()
}
closeButton.tap()
}
}
6 changes: 3 additions & 3 deletions PIA-VPN_E2E_Tests/Screens/LoginScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ extension XCUIApplication {
otherElement(with: PIALibraryAccessibility.Id.Login.Error.banner)
}

func fillLoginScreen(with credentials: Credentials) {
func logIn(with credentials: Credentials) {
loginUsernameTextField.waitForExistence(timeout: defaultTimeout) && loginPasswordTextField.waitForExistence(timeout: defaultTimeout)
loginUsernameTextField.tap()
loginUsernameTextField.typeText(credentials.username)
loginPasswordTextField.tap()
loginPasswordTextField.typeText(credentials.password)
loginButton.tap()
}

/// This method authenticates the user and installs the VPN profile
Expand All @@ -41,8 +42,7 @@ extension XCUIApplication {
logOut()

navigateToLoginScreen()
fillLoginScreen(with: CredentialsUtil.credentials(type: .valid))
loginButton.tap()
logIn(with: CredentialsUtil.credentials(type: .valid))

guard vpnPermissionScreen.waitForExistence(timeout: defaultTimeout) else { return }
guard vpnPermissionButton.exists else { return }
Expand Down
28 changes: 28 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/AutomationSettingsScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AutomationSettingsScreen.swift
// PIA-VPN_E2E_Tests
//
// Created by Geneva Parayno on 6/11/23.
// Copyright © 2023 Private Internet Access Inc. All rights reserved.
//

import XCTest

extension XCUIApplication {
var enableAutomationSwitch: XCUIElement{
switches(with: "Enable Automation")
}

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

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

if automationSettingsButton.waitForExistence(timeout: defaultTimeout) {
automationSettingsButton.tap()
}
}
}
44 changes: 44 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/GeneralSettingsScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// GeneralSettingsScreen.swift
// PIA-VPN_E2E_Tests
//
// Created by Geneva Parayno on 2/11/23.
// Copyright © 2023 Private Internet Access Inc. All rights reserved.
//

import XCTest

extension XCUIApplication {
var connectSiriButton: XCUIElement {
staticText(with: "'Connect' Siri Shortcut")
}

var disconnectSiriButton: XCUIElement {
staticText(with: "'Disconnect' Siri Shortcut")
}

var serviceCommMessageSwitch: XCUIElement {
switches(with: "Show Service Communication Messages")
}

var geoLocatedRegionsSwitch: XCUIElement {
switches(with: "Show Geo-located Regions")
}

var resetSettingsButton: XCUIElement {
staticText(with: "Reset settings to default")
}

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

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

if generalSettingsButton.waitForExistence(timeout: defaultTimeout) {
generalSettingsButton.tap()
}
}
}
36 changes: 36 additions & 0 deletions PIA-VPN_E2E_Tests/Screens/Settings/HelpSettingsScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// HelpSettingsScreen.swift
// PIA-VPN_E2E_Tests
//
// Created by Geneva Parayno on 6/11/23.
// Copyright © 2023 Private Internet Access Inc. All rights reserved.
//

import XCTest

extension XCUIApplication {
var sendDebugButton: XCUIElement {
staticText(with: "Send Debug Log to support")
}

var helpImprovePIASwitch: XCUIElement {
switches(with: "Help improve PIA")
}

var latestNewsButton: XCUIElement {
staticText(with: "Latest News")
}

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

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

if helpSettingsButton.waitForExistence(timeout: defaultTimeout) {
automationSettingsButton.tap()
}
}
}
Loading

0 comments on commit a2de346

Please sign in to comment.