From 16a59c6de1ff9f6359aff426a28450b8b7112076 Mon Sep 17 00:00:00 2001 From: Davide Date: Tue, 10 Dec 2024 18:58:41 +0100 Subject: [PATCH] Reuse .pause() in screenshots --- .../UITests/Extensions/XCTestCase+Extensions.swift | 4 ++++ Passepartout/UITests/Main/FlowTests.swift | 4 ---- Passepartout/UITests/Main/ScreenshotTests.swift | 10 +++++----- Passepartout/UITests/TV/FlowTests.swift | 4 ---- Passepartout/UITests/TV/ScreenshotTests.swift | 6 +++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift index 263b62ac..e1df66db 100644 --- a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift +++ b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift @@ -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, diff --git a/Passepartout/UITests/Main/FlowTests.swift b/Passepartout/UITests/Main/FlowTests.swift index 2b613fbd..6ed005c2 100644 --- a/Passepartout/UITests/Main/FlowTests.swift +++ b/Passepartout/UITests/Main/FlowTests.swift @@ -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() diff --git a/Passepartout/UITests/Main/ScreenshotTests.swift b/Passepartout/UITests/Main/ScreenshotTests.swift index 0fcb9682..1932d3a9 100644 --- a/Passepartout/UITests/Main/ScreenshotTests.swift +++ b/Passepartout/UITests/Main/ScreenshotTests.swift @@ -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)") diff --git a/Passepartout/UITests/TV/FlowTests.swift b/Passepartout/UITests/TV/FlowTests.swift index 6972eb82..c12a5899 100644 --- a/Passepartout/UITests/TV/FlowTests.swift +++ b/Passepartout/UITests/TV/FlowTests.swift @@ -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() diff --git a/Passepartout/UITests/TV/ScreenshotTests.swift b/Passepartout/UITests/TV/ScreenshotTests.swift index 116f421f..979c9aea 100644 --- a/Passepartout/UITests/TV/ScreenshotTests.swift +++ b/Passepartout/UITests/TV/ScreenshotTests.swift @@ -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)")