From 09ea81ce3f059fb926c435b604c366d427fac6c9 Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Mon, 12 Aug 2024 17:29:38 -0600 Subject: [PATCH 1/2] -fix race condition in e2e tests --- .../E2EFunctionalTests.swift | 20 ++++++++++++------- .../E2EFunctionalTests/Environment.swift | 6 +++--- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift b/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift index a55fc1b8..c34206b3 100644 --- a/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift +++ b/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift @@ -59,19 +59,25 @@ class E2EFunctionalTests: XCTestCase, AnyCodableAsserts { MobileCore.clearUpdatedConfiguration() let environment = Environment.get() - MobileCore.configureWith(appId: environment.appId) - if let configUpdates = environment.configurationUpdates { - MobileCore.updateConfigurationWith(configDict: configUpdates) - } - + MobileCore.updateConfigurationWith(configDict: environment.configurationUpdates) + let extensions = [ Consent.self, AEPEdgeIdentity.Identity.self, Messaging.self, Edge.self ] - - MobileCore.registerExtensions(extensions) + + MobileCore.registerExtensions(extensions) { + MobileCore.configureWith(appId: environment.appId) + } + + // wait 5 seconds to allow configuration to download + let semaphore = DispatchSemaphore(value: 0) + DispatchQueue.global().asyncAfter(deadline: .now() + .seconds(2)) { + semaphore.signal() + } + semaphore.wait() } func registerMessagingRequestContentListener(_ listener: @escaping EventListener) { diff --git a/AEPMessaging/Tests/E2EFunctionalTests/Environment.swift b/AEPMessaging/Tests/E2EFunctionalTests/Environment.swift index b4a356e8..e6011dd4 100644 --- a/AEPMessaging/Tests/E2EFunctionalTests/Environment.swift +++ b/AEPMessaging/Tests/E2EFunctionalTests/Environment.swift @@ -83,12 +83,12 @@ extension Environment { } } - var configurationUpdates: [String: Any]? { + var configurationUpdates: [String: Any] { guard isStaging else { - return nil + return [ "edge.environment": "" ] } - return ["edge.environment": "int"] + return [ "edge.environment": "int" ] } private var isStaging: Bool { From 37a166733427a6b4b63c999f5407c9589a626cff Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Mon, 12 Aug 2024 17:30:43 -0600 Subject: [PATCH 2/2] -typo --- AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift b/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift index c34206b3..265ec15a 100644 --- a/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift +++ b/AEPMessaging/Tests/E2EFunctionalTests/E2EFunctionalTests.swift @@ -72,7 +72,7 @@ class E2EFunctionalTests: XCTestCase, AnyCodableAsserts { MobileCore.configureWith(appId: environment.appId) } - // wait 5 seconds to allow configuration to download + // wait 2 seconds to allow configuration to download let semaphore = DispatchSemaphore(value: 0) DispatchQueue.global().asyncAfter(deadline: .now() + .seconds(2)) { semaphore.signal()