Files
open-design/apps/daemon/tests/daemon-url.test.ts
PerishFireandGitHub 1ff25e5b2b fix(packaged): preserve MCP runtime integrity and sidecar delivery (#8027)
* fix(daemon): keep packaged MCP discovery out of package managers

* fix(packaged): preserve MCP payload identity and require sidecar supervisor

* fix(pack): finalize runtime manifests and report entry recovery

* ci: allow isolated full Windows smoke on dispatched revisions

* test(packaged): derive recovery versions from the release channel

* test(win): read portable installer logs and retain rollback diagnostics

* test(win): distinguish portable startup reconciliation from installer sync
2026-09-14 08:13:45 +00:00

68 lines
2.0 KiB
TypeScript

import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { resolveDaemonUrl, DEFAULT_DAEMON_URL } from "../src/daemon-url.js";
// Verifies the resolution chain: --daemon-url > OD_DAEMON_URL > sidecar
// IPC status discovery > legacy default. Each layer must short-circuit the next
// so `od` clients follow the live daemon across ephemeral-port restarts.
describe("resolveDaemonUrl", () => {
let emptyBinDir: string;
beforeAll(() => {
emptyBinDir = fs.mkdtempSync(path.join(os.tmpdir(), "od-tools-dev-empty-"));
});
afterAll(() => {
fs.rmSync(emptyBinDir, { recursive: true, force: true });
});
it("prefers the explicit --daemon-url flag", async () => {
const url = await resolveDaemonUrl({
flagUrl: "http://flag.example:1111",
env: {
OD_DAEMON_URL: "http://env.example:2222",
},
});
expect(url).toBe("http://flag.example:1111");
});
it("falls back to OD_DAEMON_URL when no flag given", async () => {
const url = await resolveDaemonUrl({
env: {
OD_DAEMON_URL: "http://env.example:2222",
},
});
expect(url).toBe("http://env.example:2222");
});
it("returns the legacy default when no flag/env/socket is available", async () => {
const url = await resolveDaemonUrl({
env: {
PATH: emptyBinDir,
},
timeoutMs: 200,
});
expect(url).toBe(DEFAULT_DAEMON_URL);
});
it("discovers the live daemon URL through an inherited sidecar client", async () => {
const url = await resolveDaemonUrl({
connectInherited: (() => ({
invoke: async () => { throw new Error("unexpected invoke"); },
status: async () => ({
pid: 4242,
state: "running",
updatedAt: new Date().toISOString(),
url: "http://127.0.0.1:54321",
}),
})) as never,
env: {},
timeoutMs: 1000,
});
expect(url).toBe("http://127.0.0.1:54321");
});
});