Fix a few things about screenshots

- Postpone "Connected" screenshot
- Disable "Only favorites" to avoid iOS failure
- Prefix screenshot filename with device name and "0"
This commit is contained in:
Davide 2024-12-10 18:20:12 +01:00
parent f441a2eed0
commit d8447ddb38
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
5 changed files with 20 additions and 13 deletions

View File

@ -27,6 +27,7 @@ import Combine
import CommonLibrary import CommonLibrary
import Foundation import Foundation
import PassepartoutKit import PassepartoutKit
import UIAccessibility
extension VPNFiltersView { extension VPNFiltersView {
@ -65,8 +66,10 @@ extension VPNFiltersView {
onlyShowsFavorites = false onlyShowsFavorites = false
subscriptions = [] subscriptions = []
if !AppCommandLine.contains(.uiTesting) {
observeObjects() observeObjects()
} }
}
func load(options: VPNFilterOptions, initialFilters: VPNFilters?) { func load(options: VPNFilterOptions, initialFilters: VPNFilters?) {
self.options = options self.options = options

View File

@ -84,7 +84,7 @@ extension XCUIApplicationProviding where Self: XCTestCase {
#elseif os(tvOS) #elseif os(tvOS)
let device = "AppleTV" let device = "AppleTV"
#endif #endif
return "\(name)_\(device).png" return "\(device)_\(name).png"
} }
private func container(for target: ScreenshotTarget) -> XCUIElement { private func container(for target: ScreenshotTarget) -> XCUIElement {

View File

@ -31,10 +31,12 @@ import XCTest
struct VPNServersScreen { struct VPNServersScreen {
let app: XCUIApplication let app: XCUIApplication
#if os(iOS)
@discardableResult @discardableResult
func discloseCountry(at index: Int) -> Self { func discloseCountry(at index: Int) -> Self {
let group = app.get(.VPNServers.countryGroup, at: index) let group = app.get(.VPNServers.countryGroup, at: index)
group.tap() group.tap()
return self return self
} }
#endif
} }

View File

@ -50,32 +50,34 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding {
.waitForProfiles() .waitForProfiles()
.enableProfile(at: 0) .enableProfile(at: 0)
try await Task.sleep(for: .seconds(2))
try snapshot("1_Connected")
let profile = root let profile = root
.openProfileMenu(at: 2) .openProfileMenu(at: 2)
.editProfile() .editProfile()
try await Task.sleep(for: .seconds(2)) try await Task.sleep(for: .seconds(2))
try snapshot("2_ProfileEditor", target: .sheet) try snapshot("02_ProfileEditor", target: .sheet)
profile profile
.enterModule(at: 1) .enterModule(at: 1)
try await Task.sleep(for: .seconds(2)) try await Task.sleep(for: .seconds(2))
try snapshot("3_OnDemand", target: .sheet) try snapshot("03_OnDemand", target: .sheet)
profile profile
.leaveModule() .leaveModule()
.enterModule(at: 2) .enterModule(at: 2)
try await Task.sleep(for: .seconds(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() .leaveModule()
.closeProfile() .closeProfile()
try await Task.sleep(for: .seconds(2))
try snapshot("01_Connected")
app
.openProfileMenu(at: 2) .openProfileMenu(at: 2)
.connectToProfile() .connectToProfile()
#if os(iOS) #if os(iOS)
@ -83,7 +85,7 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding {
#endif #endif
try await Task.sleep(for: .seconds(2)) 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)") print("Saved to: \(ScreenshotDestination.temporary.url)")
} }

View File

@ -47,19 +47,19 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding {
.enableProfile(up: 1) .enableProfile(up: 1)
try await Task.sleep(for: .seconds(2)) try await Task.sleep(for: .seconds(2))
try snapshot("1_Connected") try snapshot("01_Connected")
root root
.presentProfilesWhileConnected() .presentProfilesWhileConnected()
try await Task.sleep(for: .seconds(2)) try await Task.sleep(for: .seconds(2))
try snapshot("2_ConnectedWithProfileList") try snapshot("02_ConnectedWithProfileList")
root root
.enableProfile(up: 0) .enableProfile(up: 0)
try await Task.sleep(for: .seconds(2)) try await Task.sleep(for: .seconds(2))
try snapshot("3_OnDemand") try snapshot("03_OnDemand")
print("Saved to: \(ScreenshotDestination.temporary.url)") print("Saved to: \(ScreenshotDestination.temporary.url)")
} }