summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-09-04 11:33:55 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-09-04 11:33:55 +0200
commit6cba30d237587f74436ffa0cc1cb0f8d01a7e141 (patch)
tree2eb23a8e4bc4700414b9fa451c5329ea39691f5f
parenteb94e6d067d93270919b5bebaf616da4c447a9b7 (diff)
parent096271e27e79f9e5e759b4c0ce5cdbae600e8f58 (diff)
downloadmullvadvpn-6cba30d237587f74436ffa0cc1cb0f8d01a7e141.tar.xz
mullvadvpn-6cba30d237587f74436ffa0cc1cb0f8d01a7e141.zip
Merge branch 'fix-settings-migration-tests'
-rw-r--r--ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift13
-rw-r--r--ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift7
-rw-r--r--ios/MullvadVPNUITests/XCUIElement+Extensions.swift21
3 files changed, 38 insertions, 3 deletions
diff --git a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift
index 228ff6bfcb..41433770b0 100644
--- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift
+++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift
@@ -457,6 +457,7 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
header.accessibilityIdentifier = .wireGuardPortsCell
header.titleLabel.text = title
header.accessibilityCustomActionName = title
+ header.isExpanded = isExpanded(.wireGuardPorts)
header.infoButtonHandler = { [weak self] in
if let self {
self.delegate?.showInfo(for: .wireGuardPorts)
@@ -500,6 +501,7 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
header.accessibilityIdentifier = .wireGuardObfuscationCell
header.titleLabel.text = title
header.accessibilityCustomActionName = title
+ header.isExpanded = isExpanded(.wireGuardObfuscation)
header.didCollapseHandler = { [weak self] header in
guard let self else { return }
@@ -529,6 +531,7 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
header.accessibilityIdentifier = .udpOverTCPPortCell
header.titleLabel.text = title
header.accessibilityCustomActionName = title
+ header.isExpanded = isExpanded(.wireGuardObfuscationPort)
header.didCollapseHandler = { [weak self] header in
guard let self else { return }
@@ -558,6 +561,7 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
header.accessibilityIdentifier = .quantumResistantTunnelCell
header.titleLabel.text = title
header.accessibilityCustomActionName = title
+ header.isExpanded = isExpanded(.quantumResistance)
header.didCollapseHandler = { [weak self] header in
guard let self else { return }
@@ -593,6 +597,15 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
return nil
}
+
+ /*
+ Since we are dequeuing headers, it's crucial to maintain the state of expansion.
+ Using screenshots as a single source of truth to capture the state allows us to determine whether headers are expanded or not.
+ */
+ private func isExpanded(_ section: Section) -> Bool {
+ let snapshot = snapshot()
+ return snapshot.numberOfItems(inSection: section) != 0
+ }
}
extension VPNSettingsDataSource: VPNSettingsCellEventHandler {
diff --git a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
index cc4d6e74d7..9b77ec4ded 100644
--- a/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
+++ b/ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
@@ -15,10 +15,11 @@ class VPNSettingsPage: Page {
}
private func cellExpandButton(_ cellAccessiblityIdentifier: AccessibilityIdentifier) -> XCUIElement {
- let table = app.tables[AccessibilityIdentifier.vpnSettingsTableView]
- let matchingCells = table.otherElements.containing(.any, identifier: cellAccessiblityIdentifier.rawValue)
+ let tableView = app.tables[AccessibilityIdentifier.vpnSettingsTableView]
+ let matchingCells = tableView.otherElements[cellAccessiblityIdentifier.rawValue]
let expandButton = matchingCells.buttons[AccessibilityIdentifier.expandButton]
-
+ let lastCell = tableView.cells.allElementsBoundByIndex.last!
+ tableView.scrollDownToElement(element: lastCell)
return expandButton
}
diff --git a/ios/MullvadVPNUITests/XCUIElement+Extensions.swift b/ios/MullvadVPNUITests/XCUIElement+Extensions.swift
index 271d5a767c..e4292efd23 100644
--- a/ios/MullvadVPNUITests/XCUIElement+Extensions.swift
+++ b/ios/MullvadVPNUITests/XCUIElement+Extensions.swift
@@ -16,4 +16,25 @@ extension XCUIElement {
_ = XCTWaiter().wait(for: [expectation], timeout: timeout)
return !exists
}
+
+ func scrollDownToElement(element: XCUIElement, maxScrolls: UInt = 5) {
+ var count = 0
+ while !element.isVisible && count < maxScrolls {
+ swipeUp(velocity: .slow)
+ count += 1
+ }
+ }
+
+ func scrollUpToElement(element: XCUIElement, maxScrolls: UInt = 5) {
+ var count = 0
+ while !element.isVisible && count < maxScrolls {
+ swipeDown(velocity: .slow)
+ count += 1
+ }
+ }
+
+ var isVisible: Bool {
+ guard self.exists && !self.frame.isEmpty else { return false }
+ return XCUIApplication().windows.element(boundBy: 0).frame.contains(self.frame)
+ }
}