From 720ae64827205aa015ec8142b26c0a301c85a3a7 Mon Sep 17 00:00:00 2001 From: pandeymangg Date: Tue, 23 Sep 2025 11:27:58 +0530 Subject: [PATCH 1/4] bumps sonarscan action version --- .github/workflows/sonarqube.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index c9f08d60..5b9918ec 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -39,7 +39,7 @@ jobs: # Run SonarCloud scan, pointing at the Cobertura report - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@v5.2.0 + uses: SonarSource/sonarqube-scan-action@v6.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 63a272fb3b2505434b2f1fb0a0ed736a0d69c325 Mon Sep 17 00:00:00 2001 From: pandeymangg Date: Tue, 23 Sep 2025 11:54:48 +0530 Subject: [PATCH 2/4] fixes the ios version for the io simulator --- .github/workflows/sonarqube.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 5b9918ec..b46fce50 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -28,7 +28,7 @@ jobs: -scheme 'FormbricksSDK' \ -sdk iphonesimulator \ -config Debug \ - -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation),OS=18.2' \ + -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation),OS=18.4' \ -derivedDataPath build \ -enableCodeCoverage YES @@ -39,7 +39,7 @@ jobs: # Run SonarCloud scan, pointing at the Cobertura report - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@v6.0.0 + uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 6280b9c7f2a5ce355dde00c9760e00af4efa759f Mon Sep 17 00:00:00 2001 From: pandeymangg Date: Tue, 23 Sep 2025 12:16:04 +0530 Subject: [PATCH 3/4] fix: failing test --- Tests/FormbricksSDKTests/FormbricksSDKTests.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/FormbricksSDKTests/FormbricksSDKTests.swift b/Tests/FormbricksSDKTests/FormbricksSDKTests.swift index f0a8b4d7..cba508e3 100644 --- a/Tests/FormbricksSDKTests/FormbricksSDKTests.swift +++ b/Tests/FormbricksSDKTests/FormbricksSDKTests.swift @@ -221,13 +221,13 @@ final class FormbricksSDKTests: XCTestCase { UserDefaults.standard.set(Data([0x00, 0x01]), forKey: "environmentResponseObjectKey") XCTAssertNil(manager.environmentResponse) - // Timer-based refresh (use more generous timeouts) + // Timer-based refresh manager.refreshEnvironmentAfter(timeout: 0.1) let expectation = XCTestExpectation(description: "Timer fired") - DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { + DispatchQueue.global().asyncAfter(deadline: .now() + 0.3) { expectation.fulfill() } - wait(for: [expectation], timeout: 1.0) + wait(for: [expectation], timeout: 2.0) // getLanguageCode coverage let survey = Survey( From 1aa51891f54dab9f2de44e20f94a0e312c7a89af Mon Sep 17 00:00:00 2001 From: pandeymangg Date: Tue, 23 Sep 2025 12:29:24 +0530 Subject: [PATCH 4/4] fix: adds notification for environment refresh --- Sources/FormbricksSDK/Manager/SurveyManager.swift | 6 ++++++ Tests/FormbricksSDKTests/FormbricksSDKTests.swift | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/FormbricksSDK/Manager/SurveyManager.swift b/Sources/FormbricksSDK/Manager/SurveyManager.swift index 21e0bf34..468b3148 100644 --- a/Sources/FormbricksSDK/Manager/SurveyManager.swift +++ b/Sources/FormbricksSDK/Manager/SurveyManager.swift @@ -1,5 +1,9 @@ import SwiftUI +public extension Notification.Name { + static let environmentRefreshed = Notification.Name("Formbricks.environmentRefreshed") +} + /// The SurveyManager is responsible for managing the surveys that are displayed to the user. /// Filtering surveys based on the user's segments, responses, and displays. final class SurveyManager { @@ -127,11 +131,13 @@ extension SurveyManager { self?.environmentResponse = response self?.startRefreshTimer(expiresAt: response.data.expiresAt) self?.filterSurveys() + NotificationCenter.default.post(name: .environmentRefreshed, object: self) case .failure: self?.hasApiError = true let error = FormbricksSDKError(type: .unableToRefreshEnvironment) Formbricks.logger?.error(error.message) self?.startErrorTimer() + NotificationCenter.default.post(name: .environmentRefreshed, object: self) } } } diff --git a/Tests/FormbricksSDKTests/FormbricksSDKTests.swift b/Tests/FormbricksSDKTests/FormbricksSDKTests.swift index cba508e3..2cc803ac 100644 --- a/Tests/FormbricksSDKTests/FormbricksSDKTests.swift +++ b/Tests/FormbricksSDKTests/FormbricksSDKTests.swift @@ -221,13 +221,10 @@ final class FormbricksSDKTests: XCTestCase { UserDefaults.standard.set(Data([0x00, 0x01]), forKey: "environmentResponseObjectKey") XCTAssertNil(manager.environmentResponse) - // Timer-based refresh + // Timer-based refresh: wait deterministically for the environment refresh notification + let notificationExpectation = expectation(forNotification: .environmentRefreshed, object: manager, handler: nil) manager.refreshEnvironmentAfter(timeout: 0.1) - let expectation = XCTestExpectation(description: "Timer fired") - DispatchQueue.global().asyncAfter(deadline: .now() + 0.3) { - expectation.fulfill() - } - wait(for: [expectation], timeout: 2.0) + wait(for: [notificationExpectation], timeout: 2.0) // getLanguageCode coverage let survey = Survey(