refactor: dedupe cli config cron and install flows

This commit is contained in:
Peter Steinberger
2026-03-02 19:48:38 +00:00
parent 9d30159fcd
commit b1c30f0ba9
80 changed files with 1379 additions and 2027 deletions

View File

@@ -42,6 +42,21 @@ function createSelectPrompter(
describe("promptRemoteGatewayConfig", () => {
const envSnapshot = captureEnv(["OPENCLAW_ALLOW_INSECURE_PRIVATE_WS"]);
async function runRemotePrompt(params: {
text: WizardPrompter["text"];
selectResponses: Partial<Record<string, string>>;
confirm: boolean;
}) {
const cfg = {} as OpenClawConfig;
const prompter = createPrompter({
confirm: vi.fn(async () => params.confirm),
select: createSelectPrompter(params.selectResponses),
text: params.text,
});
const next = await promptRemoteGatewayConfig(cfg, prompter);
return { next, prompter };
}
beforeEach(() => {
vi.clearAllMocks();
envSnapshot.restore();
@@ -61,12 +76,6 @@ describe("promptRemoteGatewayConfig", () => {
},
]);
const select = createSelectPrompter({
"Select gateway": "0",
"Connection method": "direct",
"Gateway auth": "token",
});
const text: WizardPrompter["text"] = vi.fn(async (params) => {
if (params.message === "Gateway WebSocket URL") {
expect(params.initialValue).toBe("wss://gateway.tailnet.ts.net:18789");
@@ -79,15 +88,16 @@ describe("promptRemoteGatewayConfig", () => {
return "";
}) as WizardPrompter["text"];
const cfg = {} as OpenClawConfig;
const prompter = createPrompter({
confirm: vi.fn(async () => true),
select,
const { next, prompter } = await runRemotePrompt({
text,
confirm: true,
selectResponses: {
"Select gateway": "0",
"Connection method": "direct",
"Gateway auth": "token",
},
});
const next = await promptRemoteGatewayConfig(cfg, prompter);
expect(next.gateway?.mode).toBe("remote");
expect(next.gateway?.remote?.url).toBe("wss://gateway.tailnet.ts.net:18789");
expect(next.gateway?.remote?.token).toBe("token-123");
@@ -111,17 +121,12 @@ describe("promptRemoteGatewayConfig", () => {
return "";
}) as WizardPrompter["text"];
const select = createSelectPrompter({ "Gateway auth": "off" });
const cfg = {} as OpenClawConfig;
const prompter = createPrompter({
confirm: vi.fn(async () => false),
select,
const { next } = await runRemotePrompt({
text,
confirm: false,
selectResponses: { "Gateway auth": "off" },
});
const next = await promptRemoteGatewayConfig(cfg, prompter);
expect(next.gateway?.mode).toBe("remote");
expect(next.gateway?.remote?.url).toBe("wss://remote.example.com:18789");
expect(next.gateway?.remote?.token).toBeUndefined();
@@ -138,17 +143,12 @@ describe("promptRemoteGatewayConfig", () => {
return "";
}) as WizardPrompter["text"];
const select = createSelectPrompter({ "Gateway auth": "off" });
const cfg = {} as OpenClawConfig;
const prompter = createPrompter({
confirm: vi.fn(async () => false),
select,
const { next } = await runRemotePrompt({
text,
confirm: false,
selectResponses: { "Gateway auth": "off" },
});
const next = await promptRemoteGatewayConfig(cfg, prompter);
expect(next.gateway?.remote?.url).toBe("ws://10.0.0.8:18789");
});
});