-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added VPNServerListTests, enhanced existing screens and tests
- Loading branch information
1 parent
cc600bd
commit 838708e
Showing
9 changed files
with
213 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// RegionSelectionScreen.swift | ||
// PIA-VPN_E2E_Tests | ||
// | ||
// Created by Geneva Parayno on 20/11/23. | ||
// Copyright © 2023 Private Internet Access Inc. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
extension XCUIApplication { | ||
var searchRegionField: XCUIElement { | ||
searchField(with: "Search for a region") | ||
} | ||
|
||
var cancelSearchButton: XCUIElement { | ||
button(with: "Cancel") | ||
} | ||
|
||
var sortButton: XCUIElement { | ||
button(with: "Filter") | ||
} | ||
|
||
var sortPopUpHeader: XCUIElement { | ||
staticText(with: "SORT REGIONS BY") | ||
} | ||
|
||
func searchRegion(regionName: String) -> XCUIElementQuery { | ||
while(!searchRegionField.isHittable) { | ||
swipeDown() | ||
} | ||
searchRegionField.tap() | ||
searchRegionField.typeText(regionName) | ||
|
||
return getRegionList() | ||
} | ||
|
||
func cancelSearch() { | ||
cancelSearchButton.tap() | ||
WaitHelper.waitForElementToBeVisible(sortButton, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("sortButton is not displayed")}) | ||
} | ||
|
||
func getRegionList() -> XCUIElementQuery { | ||
let query = cells.matching(NSPredicate(format: "identifier == %@", "uitests.regions.region_name")) | ||
return query | ||
} | ||
|
||
func addRegionAsFavourite(regionName: String) { | ||
let region = searchRegion(regionName: regionName).firstMatch | ||
|
||
let regionAddAsAFavouriteButton = region.buttons["Add a favorite region"] | ||
let regionRemoveAsAFavouriteButton = region.buttons["Remove a favorite region"] | ||
|
||
if(regionRemoveAsAFavouriteButton.exists) { | ||
regionRemoveAsAFavouriteButton.tap() | ||
} | ||
WaitHelper.waitForElementToBeVisible(regionAddAsAFavouriteButton, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("regionRemoveAsAFavouriteButton is not visible")}) | ||
WaitHelper.waitForElementToNotBeVisible(regionRemoveAsAFavouriteButton, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("regionAddAsAFavouriteButton is not visible")}) | ||
|
||
} | ||
|
||
func removeRegionAsFavourite(regionName: String) { | ||
|
||
} | ||
|
||
func isRegionFavourite(regionName: String) -> Bool { | ||
var isFavourite: Bool = false | ||
|
||
let region = getRegionList().firstMatch | ||
|
||
let regionAddAsAFavouriteButton = region.buttons["Add a favorite region"] | ||
let regionRemoveAsAFavouriteButton = region.buttons["Remove a favorite region"] | ||
|
||
if(regionAddAsAFavouriteButton.exists && !regionRemoveAsAFavouriteButton.exists) { | ||
isFavourite = true | ||
} | ||
|
||
return isFavourite | ||
} | ||
|
||
func sortRegionsBy(sortType: String) { | ||
guard sortButton.exists else {return} | ||
sortButton.tap() | ||
WaitHelper.waitForElementToBeVisible(sortPopUpHeader, timeout: defaultTimeout, onSuccess: {}, onFailure: {error in print("sortPopUpHeader is not visible")}) | ||
button(with: sortType).tap() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
// | ||
|
||
import Nimble | ||
import Foundation | ||
|
||
class QuickSettingsTests : BaseTest { | ||
override class func spec() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// VPNServerListTests.swift | ||
// PIA-VPN_E2E_Tests | ||
// | ||
// Created by Geneva Parayno on 20/11/23. | ||
// Copyright © 2023 Private Internet Access Inc. All rights reserved. | ||
// | ||
|
||
import Nimble | ||
|
||
class VPNServerListTests : BaseTest { | ||
override class func spec() { | ||
let regionKeyword = "australia" | ||
let characterKey = "au" | ||
let favouriteRegionKeyword = "Philippines" | ||
|
||
super.spec() | ||
|
||
describe("vpn server list tests") { | ||
context("when the user navigates to region selection screen") { | ||
it("should show the search region field when the user scrolls down") { | ||
app.navigateToRegionSelection() | ||
while(!app.searchRegionField.isHittable) { | ||
app.swipeDown() | ||
} | ||
|
||
expect(app.searchRegionField.isHittable).to(beTrue()) | ||
} | ||
} | ||
|
||
context("when the user performs search") { | ||
it("should return results based on searched keyword \(regionKeyword)") { | ||
app.navigateToRegionSelection() | ||
let cellsQuery = app.searchRegion(regionName: regionKeyword) | ||
|
||
for cell in cellsQuery.allElementsBoundByIndex { | ||
expect(cell.label.lowercased().contains(regionKeyword)).to(beTrue()) | ||
} | ||
} | ||
it("should return results based on searched \(characterKey)") { | ||
app.navigateToRegionSelection() | ||
let cellsQuery = app.searchRegion(regionName: characterKey) | ||
|
||
for cell in cellsQuery.allElementsBoundByIndex { | ||
expect(cell.label.lowercased().contains(characterKey)).to(beTrue()) | ||
} | ||
} | ||
} | ||
|
||
context("when the user selects a region as a favorite") { | ||
it("should be displayed as a favourite region") { | ||
app.navigateToRegionSelection() | ||
app.addRegionAsFavourite(regionName: favouriteRegionKeyword) | ||
expect(app.isRegionFavourite(regionName: favouriteRegionKeyword)).to(beTrue()) | ||
} | ||
} | ||
|
||
context("when the user sorts the region selection") { | ||
it("should sort the regions by name, when 'name' is selected") { | ||
app.navigateToRegionSelection() | ||
app.sortRegionsBy(sortType: "NAME") | ||
let regionList = app.getRegionList().allElementsBoundByIndex.prefix(21).map{$0.label}.filter{$0 != "Automatic"} | ||
expect(regionList).to(equal(regionList.sorted(by: <))) | ||
} | ||
|
||
it("should sort the regions by latency, when 'latency' is selected") { | ||
app.navigateToRegionSelection() | ||
app.sortRegionsBy(sortType: "LATENCY") | ||
let regionList = app.getRegionList().allElementsBoundByIndex.prefix(21).map{$0.label}.filter{$0 != "Automatic"} | ||
expect(regionList) == regionList.sorted { | ||
let latency01 = Int($0.components(separatedBy: ", ").last?.dropLast(2) ?? "") ?? 0 | ||
let latency02 = Int($1.components(separatedBy: ", ").last?.dropLast(2) ?? "") ?? 0 | ||
return latency01<latency02 | ||
} | ||
} | ||
|
||
it("should sort the regions by favourites, when 'favourites' is selected") { | ||
app.navigateToRegionSelection() | ||
app.addRegionAsFavourite(regionName: favouriteRegionKeyword) | ||
app.cancelSearch() | ||
app.sortRegionsBy(sortType: "FAVORITES") | ||
let firstRegion = app.getRegionList().allElementsBoundByIndex.prefix(2).filter({$0.label != "Automatic"}).first | ||
expect(firstRegion?.label).to(contain(favouriteRegionKeyword)) | ||
} | ||
} | ||
} | ||
} | ||
} |