refactor!: rename chat providers to channels

This commit is contained in:
Peter Steinberger
2026-01-13 06:16:43 +00:00
parent 0cd632ba84
commit 90342a4f3a
393 changed files with 8004 additions and 6737 deletions

View File

@@ -0,0 +1,70 @@
import { describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import type { RuntimeEnv } from "../runtime.js";
import type { WizardPrompter } from "../wizard/prompts.js";
import { setupChannels } from "./onboard-channels.js";
vi.mock("node:fs/promises", () => ({
default: {
access: vi.fn(async () => {
throw new Error("ENOENT");
}),
},
}));
vi.mock("../channel-web.js", () => ({
loginWeb: vi.fn(async () => {}),
}));
vi.mock("./onboard-helpers.js", () => ({
detectBinary: vi.fn(async () => false),
}));
describe("setupChannels", () => {
it("QuickStart uses single-select (no multiselect) and doesn't prompt for Telegram token when WhatsApp is chosen", async () => {
const select = vi.fn(async () => "whatsapp");
const multiselect = vi.fn(async () => {
throw new Error("unexpected multiselect");
});
const text = vi.fn(async ({ message }: { message: string }) => {
if (message.includes("Enter Telegram bot token")) {
throw new Error("unexpected Telegram token prompt");
}
if (message.includes("Your personal WhatsApp number")) {
return "+15555550123";
}
throw new Error(`unexpected text prompt: ${message}`);
});
const prompter: WizardPrompter = {
intro: vi.fn(async () => {}),
outro: vi.fn(async () => {}),
note: vi.fn(async () => {}),
select,
multiselect,
text: text as unknown as WizardPrompter["text"],
confirm: vi.fn(async () => false),
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
};
const runtime: RuntimeEnv = {
log: vi.fn(),
error: vi.fn(),
exit: vi.fn((code: number) => {
throw new Error(`exit:${code}`);
}),
};
await setupChannels({} as ClawdbotConfig, runtime, prompter, {
skipConfirm: true,
quickstartDefaults: true,
forceAllowFromChannels: ["whatsapp"],
});
expect(select).toHaveBeenCalledWith(
expect.objectContaining({ message: "Select channel (QuickStart)" }),
);
expect(multiselect).not.toHaveBeenCalled();
});
});