Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion desktop/macos/Desktop/Sources/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 18 additions & 0 deletions desktop/macos/Desktop/Tests/APIClientSetupCompletedTests.swift
Original file line number Diff line number Diff line change
@@ -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")
}
}
Loading