From 31a9f2c961a8bbdf0606c7b7053587a5bd1ba161 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Wed, 24 Jun 2026 15:02:35 +0200 Subject: [PATCH] migrating ui tests using swift 6.2 --- ElementX.xcodeproj/project.pbxproj | 4 ++++ ElementX/Sources/UITests/UITestsSignalling.swift | 1 + UITests/Sources/RoomScreenTests.swift | 5 ++++- UITests/SupportingFiles/target.yml | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index b16028be0..e796f3fbd 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -9936,6 +9936,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.ui.tests"; PRODUCT_NAME = UITests; SDKROOT = iphoneos; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_VERSION = 6.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_TARGET_NAME = ElementX; }; @@ -9957,6 +9959,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "${BASE_BUNDLE_IDENTIFIER}.ui.tests"; PRODUCT_NAME = UITests; SDKROOT = iphoneos; + SWIFT_APPROACHABLE_CONCURRENCY = YES; + SWIFT_VERSION = 6.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_TARGET_NAME = ElementX; }; diff --git a/ElementX/Sources/UITests/UITestsSignalling.swift b/ElementX/Sources/UITests/UITestsSignalling.swift index ee82b2436..13de6ae59 100644 --- a/ElementX/Sources/UITests/UITestsSignalling.swift +++ b/ElementX/Sources/UITests/UITestsSignalling.swift @@ -60,6 +60,7 @@ enum UITestsSignalling { /// - Within the app, create a `Client` in `app` mode. This will check that the tests are ready and echo back that the app is too. /// - Call `waitForApp()` in the tests when you need to send the signal. This will suspend execution until the app has signalled it is ready. /// - The two `Client` objects can now be used for two-way signalling. + @MainActor class Client { /// The file watcher responsible for receiving signals. private let fileWatcher: FileWatcher.Local diff --git a/UITests/Sources/RoomScreenTests.swift b/UITests/Sources/RoomScreenTests.swift index 04a0a1ca8..6c185e1aa 100644 --- a/UITests/Sources/RoomScreenTests.swift +++ b/UITests/Sources/RoomScreenTests.swift @@ -156,7 +156,10 @@ class RoomScreenUITests: XCTestCase { private func performOperation(_ operation: UITestsSignal.Timeline, using client: UITestsSignalling.Client) async throws { try client.send(.timeline(operation)) - await _ = client.signals.values.first { $0 == .success } + // The type is not sendable so we can't use the first function directly on the values. + // So we need to make an async iterator which allows us to await a value on the same isolation context. + var iterator = client.signals.values.makeAsyncIterator() + while let signal = await iterator.next(isolation: #isolation), signal != .success { } try await Task.sleep(for: .seconds(2)) // Allow the timeline to update } diff --git a/UITests/SupportingFiles/target.yml b/UITests/SupportingFiles/target.yml index 866b0c216..9186c864c 100644 --- a/UITests/SupportingFiles/target.yml +++ b/UITests/SupportingFiles/target.yml @@ -48,6 +48,8 @@ targets: base: PRODUCT_NAME: UITests PRODUCT_BUNDLE_IDENTIFIER: ${BASE_BUNDLE_IDENTIFIER}.ui.tests + SWIFT_VERSION: 6.2 + SWIFT_APPROACHABLE_CONCURRENCY: YES configs: # This is required to remove the $(inherited) flags # which would prevent SnapshotTesting to be imported in UI Tests