diff --git a/desktop/macos/Desktop/Sources/APIClient.swift b/desktop/macos/Desktop/Sources/APIClient.swift index 12d7d351ced..abdb862c9fb 100644 --- a/desktop/macos/Desktop/Sources/APIClient.swift +++ b/desktop/macos/Desktop/Sources/APIClient.swift @@ -3158,7 +3158,10 @@ extension APIClient { /// Checks if an external integration app's setup is complete func isAppSetupCompleted(url: String, uid: String) async -> Bool { - guard !url.isEmpty else { return true } + // An empty/unknown completion URL means setup cannot be verified, so report + // not-completed (consistent with the invalid-URL and network-failure paths + // below). Returning true here would wrongly mark an unconfigured app as set up. + guard !url.isEmpty else { return false } guard let fullUrl = URL(string: "\(url)?uid=\(uid)") else { return false } var request = URLRequest(url: fullUrl) request.httpMethod = "GET" diff --git a/desktop/macos/Desktop/Tests/APIClientSetupCompletedTests.swift b/desktop/macos/Desktop/Tests/APIClientSetupCompletedTests.swift new file mode 100644 index 00000000000..3f2676bbd69 --- /dev/null +++ b/desktop/macos/Desktop/Tests/APIClientSetupCompletedTests.swift @@ -0,0 +1,18 @@ +import XCTest + +@testable import Omi_Computer + +/// Regression coverage for `APIClient.isAppSetupCompleted(url:uid:)`. +/// +/// An empty completion URL means setup cannot be verified, so the method must +/// report `false` (not-completed) — matching its invalid-URL and +/// network-failure paths. A previous `return true` would wrongly mark an +/// unconfigured external integration app as already set up. The empty-URL case +/// short-circuits before any network request, so this needs no HTTP mocking. +final class APIClientSetupCompletedTests: XCTestCase { + + func testEmptyURLReportsNotCompleted() async { + let completed = await APIClient.shared.isAppSetupCompleted(url: "", uid: "test-uid") + XCTAssertFalse(completed, "An empty completion URL must report setup as NOT completed") + } +}