import { describe, expect, it } from "vitest"; import { deriveWsUrl } from "@/lib/bootstrap"; describe("bootstrap helpers", () => { it("prefers the server-provided websocket URL over the current dev host", () => { expect(deriveWsUrl("/", "tok en", "ws://127.0.0.1:8765/")).toBe( "ws://127.0.0.1:8765/?token=tok%20en", ); }); it("preserves the host socket bridge URL", () => { expect(deriveWsUrl("/", "tok en", "nanobot-host://engine/")).toBe( "nanobot-host://engine/?token=tok%20en", ); }); it("falls back to the current window host for legacy bootstrap payloads", () => { expect(deriveWsUrl("/", "tok")).toBe( "ws://localhost:3000/?token=tok", ); }); });