Daemon CLI: type-safe install plan assertions

This commit is contained in:
Vincent Koc
2026-03-07 16:02:27 -08:00
parent c5fb661742
commit 029fdd4208

View File

@@ -118,6 +118,13 @@ vi.mock("../../runtime.js", () => ({
},
}));
function expectFirstInstallPlanCallOmitsToken() {
const [firstArg] =
(buildGatewayInstallPlanMock.mock.calls.at(0) as [Record<string, unknown>] | undefined) ?? [];
expect(firstArg).toBeDefined();
expect(firstArg && "token" in firstArg).toBe(false);
}
const { runDaemonInstall } = await import("./install.js");
const envSnapshot = captureFullEnv();
@@ -198,7 +205,7 @@ describe("runDaemonInstall", () => {
expect(actionState.failed).toEqual([]);
expect(buildGatewayInstallPlanMock).toHaveBeenCalledTimes(1);
expect("token" in buildGatewayInstallPlanMock.mock.calls[0][0]).toBe(false);
expectFirstInstallPlanCallOmitsToken();
expect(writeConfigFileMock).not.toHaveBeenCalled();
expect(
actionState.warnings.some((warning) =>
@@ -223,7 +230,7 @@ describe("runDaemonInstall", () => {
expect(actionState.failed).toEqual([]);
expect(resolveSecretRefValuesMock).toHaveBeenCalledTimes(1);
expect(buildGatewayInstallPlanMock).toHaveBeenCalledTimes(1);
expect("token" in buildGatewayInstallPlanMock.mock.calls[0][0]).toBe(false);
expectFirstInstallPlanCallOmitsToken();
});
it("auto-mints and persists token when no source exists", async () => {
@@ -245,7 +252,7 @@ describe("runDaemonInstall", () => {
expect(buildGatewayInstallPlanMock).toHaveBeenCalledWith(
expect.objectContaining({ port: 18789 }),
);
expect("token" in buildGatewayInstallPlanMock.mock.calls[0][0]).toBe(false);
expectFirstInstallPlanCallOmitsToken();
expect(installDaemonServiceAndEmitMock).toHaveBeenCalledTimes(1);
expect(actionState.warnings.some((warning) => warning.includes("Auto-generated"))).toBe(true);
});