import Foundation
import Testing

@testable import NucleicProtocol

@Suite struct CoreTypesTests {
    @Test func sessionIDRoundTripsAsBareString() throws {
        let id = SessionID(rawValue: "abc-123")
        let data = try JSONEncoder().encode(id)
        #expect(String(data: data, encoding: .utf8) == "\"abc-123\"")
        #expect(try JSONDecoder().decode(SessionID.self, from: data) == id)
    }

    @Test func agentInputIsCodable() throws {
        let input = AgentInput(parts: [
            .text("do the thing"),
            .context(label: "selection", body: "let x = 1"),
        ])
        let data = try JSONEncoder().encode(input)
        let back = try JSONDecoder().decode(AgentInput.self, from: data)
        #expect(back == input)
        #expect(back.plainText == "do the thing\n[selection]\nlet x = 1")
    }

    @Test func sessionStatusTerminalAndDisplay() {
        #expect(SessionStatus.finished.isTerminal)
        #expect(!SessionStatus.running.isTerminal)
        #expect(SessionStatus.awaitingApproval.displayName == "Awaiting approval")
    }
}
