From d8447ddb3888988d6eb8de952ec5fc229a418c75 Mon Sep 17 00:00:00 2001 From: Davide Date: Tue, 10 Dec 2024 18:20:12 +0100 Subject: [PATCH] Fix a few things about screenshots - Postpone "Connected" screenshot - Disable "Only favorites" to avoid iOS failure - Prefix screenshot filename with device name and "0" --- .../Views/VPN/VPNFiltersView+Model.swift | 5 ++++- .../Extensions/XCTestCase+Extensions.swift | 2 +- .../Main/Screens/VPNServersScreen.swift | 2 ++ .../UITests/Main/ScreenshotTests.swift | 18 ++++++++++-------- Passepartout/UITests/TV/ScreenshotTests.swift | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView+Model.swift b/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView+Model.swift index 6cd00623..32637b9c 100644 --- a/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView+Model.swift +++ b/Library/Sources/AppUIMain/Views/VPN/VPNFiltersView+Model.swift @@ -27,6 +27,7 @@ import Combine import CommonLibrary import Foundation import PassepartoutKit +import UIAccessibility extension VPNFiltersView { @@ -65,7 +66,9 @@ extension VPNFiltersView { onlyShowsFavorites = false subscriptions = [] - observeObjects() + if !AppCommandLine.contains(.uiTesting) { + observeObjects() + } } func load(options: VPNFilterOptions, initialFilters: VPNFilters?) { diff --git a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift index c0e63894..6a047e9a 100644 --- a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift +++ b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift @@ -84,7 +84,7 @@ extension XCUIApplicationProviding where Self: XCTestCase { #elseif os(tvOS) let device = "AppleTV" #endif - return "\(name)_\(device).png" + return "\(device)_\(name).png" } private func container(for target: ScreenshotTarget) -> XCUIElement { diff --git a/Passepartout/UITests/Main/Screens/VPNServersScreen.swift b/Passepartout/UITests/Main/Screens/VPNServersScreen.swift index b991d23f..438a19bb 100644 --- a/Passepartout/UITests/Main/Screens/VPNServersScreen.swift +++ b/Passepartout/UITests/Main/Screens/VPNServersScreen.swift @@ -31,10 +31,12 @@ import XCTest struct VPNServersScreen { let app: XCUIApplication +#if os(iOS) @discardableResult func discloseCountry(at index: Int) -> Self { let group = app.get(.VPNServers.countryGroup, at: index) group.tap() return self } +#endif } diff --git a/Passepartout/UITests/Main/ScreenshotTests.swift b/Passepartout/UITests/Main/ScreenshotTests.swift index 7c6a1df2..0fcb9682 100644 --- a/Passepartout/UITests/Main/ScreenshotTests.swift +++ b/Passepartout/UITests/Main/ScreenshotTests.swift @@ -50,32 +50,34 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding { .waitForProfiles() .enableProfile(at: 0) - try await Task.sleep(for: .seconds(2)) - try snapshot("1_Connected") - let profile = root .openProfileMenu(at: 2) .editProfile() try await Task.sleep(for: .seconds(2)) - try snapshot("2_ProfileEditor", target: .sheet) + try snapshot("02_ProfileEditor", target: .sheet) profile .enterModule(at: 1) try await Task.sleep(for: .seconds(2)) - try snapshot("3_OnDemand", target: .sheet) + try snapshot("03_OnDemand", target: .sheet) profile .leaveModule() .enterModule(at: 2) try await Task.sleep(for: .seconds(2)) - try snapshot("4_DNS", target: .sheet) + try snapshot("04_DNS", target: .sheet) - profile + let app = profile .leaveModule() .closeProfile() + + try await Task.sleep(for: .seconds(2)) + try snapshot("01_Connected") + + app .openProfileMenu(at: 2) .connectToProfile() #if os(iOS) @@ -83,7 +85,7 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding { #endif try await Task.sleep(for: .seconds(2)) - try snapshot("5_ProviderServers", target: .sheet) + try snapshot("05_ProviderServers", target: .sheet) print("Saved to: \(ScreenshotDestination.temporary.url)") } diff --git a/Passepartout/UITests/TV/ScreenshotTests.swift b/Passepartout/UITests/TV/ScreenshotTests.swift index a6bd9e8b..116f421f 100644 --- a/Passepartout/UITests/TV/ScreenshotTests.swift +++ b/Passepartout/UITests/TV/ScreenshotTests.swift @@ -47,19 +47,19 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding { .enableProfile(up: 1) try await Task.sleep(for: .seconds(2)) - try snapshot("1_Connected") + try snapshot("01_Connected") root .presentProfilesWhileConnected() try await Task.sleep(for: .seconds(2)) - try snapshot("2_ConnectedWithProfileList") + try snapshot("02_ConnectedWithProfileList") root .enableProfile(up: 0) try await Task.sleep(for: .seconds(2)) - try snapshot("3_OnDemand") + try snapshot("03_OnDemand") print("Saved to: \(ScreenshotDestination.temporary.url)") }