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 @MainActor
extension XCUIApplicationProviding where Self: XCTestCase { extension XCUIApplicationProviding where Self: XCTestCase {
func pause() async {
try? await Task.sleep(for: .seconds(2))
}
func snapshot( func snapshot(
_ name: String, _ name: String,
destination: ScreenshotDestination = .temporary, destination: ScreenshotDestination = .temporary,

View File

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

View File

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

View File

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

View File

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