Skip to content

Commit 3c6e4e2

Browse files
committed
test(channels): cover adapter env setup
1 parent 5f4d58e commit 3c6e4e2

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎extensions/buzz/src/setup-core.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ describe("buzzSetupContract", () => {
77
vi.unstubAllEnvs();
88
});
99

10-
it("removes a stored private key when switching to BUZZ_PRIVATE_KEY", () => {
10+
it("validates and applies BUZZ_PRIVATE_KEY setup without storing the key", () => {
1111
expect(buzzSetupContract.metadata.fields.find((field) => field.key === "useEnv")).toMatchObject(
1212
{
1313
kind: "boolean",
1414
envVars: ["BUZZ_PRIVATE_KEY"],
1515
},
1616
);
17+
expect(
18+
buzzSetupContract.validateInput?.({
19+
cfg: {},
20+
accountId: "default",
21+
input: { relayUrl: "wss://buzz.example.com", useEnv: true },
22+
}),
23+
).toBeNull();
1724
vi.stubEnv("BUZZ_PRIVATE_KEY", "22".repeat(32));
1825
const cfg = {
1926
channels: {

‎extensions/telegram/src/setup-surface.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@ import {
1313
import { telegramSetupWizard } from "./setup-surface.js";
1414

1515
describe("Telegram setup promotion contract", () => {
16-
it("exposes webhookSecret without widening named-account promotion", () => {
16+
it("covers named-account promotion and environment setup", () => {
17+
const input = {
18+
cfg: {},
19+
accountId: DEFAULT_ACCOUNT_ID,
20+
input: { useEnv: true },
21+
};
1722
expect(telegramSetupAdapter.singleAccountKeysToMove).toEqual(["streaming", "webhookSecret"]);
1823
expect(telegramSetupAdapter.namedAccountPromotionKeys).toEqual(["botToken", "tokenFile"]);
1924
expect(
2025
telegramSetupContract.metadata.fields.find((field) => field.key === "useEnv"),
2126
).toMatchObject({ kind: "boolean", envVars: ["TELEGRAM_BOT_TOKEN"] });
27+
expect(telegramSetupContract.validateInput?.(input)).toBeNull();
28+
const cfg = telegramSetupContract.applyAccountConfig(input);
29+
expect(cfg.channels?.telegram).toEqual({ enabled: true });
30+
expect(cfg.channels?.telegram?.botToken).toBeUndefined();
31+
expect(cfg.channels?.telegram?.tokenFile).toBeUndefined();
2232
});
2333
});
2434

0 commit comments

Comments
 (0)