import Testing

@testable import NucleicCore

/// `ProviderStatus` drives the Settings → Agents → Backend list: the green/red dot and the
/// "Connected"/"Not Connected" label both key off `isConnected`, and the hover `detail`
/// distinguishes the two not-connected modes. Lock that pure mapping (the install/auth probes
/// themselves are host-environment dependent and exercised manually).
@Suite struct ProviderAvailabilityTests {
    private func status(installed: Bool, authenticated: Bool) -> ProviderStatus {
        ProviderStatus(
            backend: .claudeCode, name: "Claude Code", executable: "claude",
            installed: installed, authenticated: authenticated)
    }

    @Test func connectedOnlyWhenInstalledAndAuthenticated() {
        #expect(status(installed: true, authenticated: true).isConnected)
        #expect(!status(installed: true, authenticated: false).isConnected)
        #expect(!status(installed: false, authenticated: true).isConnected)
        #expect(!status(installed: false, authenticated: false).isConnected)
    }

    @Test func detailDistinguishesNotConnectedModes() {
        #expect(status(installed: true, authenticated: true).detail == "Installed and authenticated")
        #expect(status(installed: true, authenticated: false).detail == "Installed, but not signed in")
        #expect(status(installed: false, authenticated: true).detail == "Not installed")
        #expect(status(installed: false, authenticated: false).detail == "Not installed")
    }
}
