Reuse .pause() in screenshots

This commit is contained in:
Davide 2024-12-10 18:58:41 +01:00
parent 7d327b21d7
commit 16a59c6de1
No known key found for this signature in database
GPG Key ID: A48836171C759F5E
5 changed files with 12 additions and 16 deletions

View File

@ -54,6 +54,10 @@ extension XCTestCase.ScreenshotDestination {
@MainActor
extension XCUIApplicationProviding where Self: XCTestCase {
func pause() async {
try? await Task.sleep(for: .seconds(2))
}
func snapshot(
_ name: String,
destination: ScreenshotDestination = .temporary,

View File

@ -38,10 +38,6 @@ final class FlowTests: XCTestCase {
app.launch()
}
override func tearDown() async throws {
try await Task.sleep(for: .seconds(2))
}
func testConnect() {
AppScreen(app: app)
.waitForProfiles()

View File

@ -54,27 +54,27 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding {
.openProfileMenu(at: 2)
.editProfile()
try await Task.sleep(for: .seconds(2))
await pause()
try snapshot("02_ProfileEditor", target: .sheet)
profile
.enterModule(at: 1)
try await Task.sleep(for: .seconds(2))
await pause()
try snapshot("03_OnDemand", target: .sheet)
profile
.leaveModule()
.enterModule(at: 2)
try await Task.sleep(for: .seconds(2))
await pause()
try snapshot("04_DNS", target: .sheet)
let app = profile
.leaveModule()
.closeProfile()
try await Task.sleep(for: .seconds(2))
await pause()
try snapshot("01_Connected")
app
@ -84,7 +84,7 @@ final class ScreenshotTests: XCTestCase, XCUIApplicationProviding {
.discloseCountry(at: 2)
#endif
try await Task.sleep(for: .seconds(2))
await pause()
try snapshot("05_ProviderServers", target: .sheet)
print("Saved to: \(ScreenshotDestination.temporary.url)")

View File

@ -38,10 +38,6 @@ final class FlowTests: XCTestCase {
app.launch()
}
override func tearDown() async throws {
try await Task.sleep(for: .seconds(2))
}
func testShow() {
AppScreen(app: app)
.waitForProfiles()

View File

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