import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("../services/runtime-binding.js", () => ({
    clearRuntimeBinding: vi.fn(),
    getRuntimeBindingPublicState: vi.fn(() => ({ paired: true })),
    getRuntimePairingCode: vi.fn(() => "000-000"),
    hasRuntimeBinding: vi.fn(() => true),
    saveRuntimeBinding: vi.fn(),
    validateRuntimeBindingToken: vi.fn(() => true),
    validateRuntimePairingCode: vi.fn(() => true),
}));
vi.mock("../services/mcp-launch-binding-queue.js", () => ({
    claimMcpLaunchBinding: vi.fn(),
    getMcpLaunchQueueSize: vi.fn(() => 0),
}));
afterEach(() => {
    vi.clearAllMocks();
});
describe("runtime binding token request", () => {
    it("rejects bridge-scoped token refresh for MCP nodes", async () => {
        const { resolveRuntimeTokenRequest } = await import("./runtime-binding.js");
        const result = resolveRuntimeTokenRequest({
            userId: "user-1",
            serverUrl: "ws://localhost:7380/ws/agent",
            forceRefresh: true,
            rejectedRuntimeAccessToken: "stale-token",
        });
        expect(result).toEqual({
            success: false,
            error: "MCP runtime token must be claimed from launch binding; bridge-scoped token refresh is disabled",
        });
    });
});
