Files
openclaw/src/commands/doctor-config-flow.missing-default-account-bindings.test.ts
Gustavo Madeira Santana dfa0b5b4fc Channels: move single-account config into accounts.default (#27334)
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 50b5771808
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-02-26 04:06:03 -05:00

90 lines
2.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { collectMissingDefaultAccountBindingWarnings } from "./doctor-config-flow.js";
describe("collectMissingDefaultAccountBindingWarnings", () => {
it("warns when named accounts exist without default and no valid binding exists", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
accounts: {
alerts: { botToken: "a" },
work: { botToken: "w" },
},
},
},
bindings: [{ agentId: "ops", match: { channel: "telegram" } }],
};
const warnings = collectMissingDefaultAccountBindingWarnings(cfg);
expect(warnings).toHaveLength(1);
expect(warnings[0]).toContain("channels.telegram");
expect(warnings[0]).toContain("alerts, work");
});
it("does not warn when an explicit account binding exists", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
accounts: {
alerts: { botToken: "a" },
},
},
},
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "alerts" } }],
};
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
});
it("warns when bindings cover only a subset of configured accounts", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
accounts: {
alerts: { botToken: "a" },
work: { botToken: "w" },
},
},
},
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "alerts" } }],
};
const warnings = collectMissingDefaultAccountBindingWarnings(cfg);
expect(warnings).toHaveLength(1);
expect(warnings[0]).toContain("subset");
expect(warnings[0]).toContain("Uncovered accounts: work");
});
it("does not warn when wildcard account binding exists", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
accounts: {
alerts: { botToken: "a" },
},
},
},
bindings: [{ agentId: "ops", match: { channel: "telegram", accountId: "*" } }],
};
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
});
it("does not warn when default account is present", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
accounts: {
default: { botToken: "d" },
alerts: { botToken: "a" },
},
},
},
bindings: [{ agentId: "ops", match: { channel: "telegram" } }],
};
expect(collectMissingDefaultAccountBindingWarnings(cfg)).toEqual([]);
});
});