fix(channels): add optional defaultAccount routing

This commit is contained in:
Peter Steinberger
2026-03-02 04:03:13 +00:00
parent 0437ac1a89
commit 41537e9303
45 changed files with 461 additions and 35 deletions

View File

@@ -100,6 +100,39 @@ describe("LINE accounts", () => {
});
describe("resolveDefaultLineAccountId", () => {
it("prefers channels.line.defaultAccount when configured", () => {
const cfg: OpenClawConfig = {
channels: {
line: {
defaultAccount: "business",
accounts: {
business: { enabled: true },
support: { enabled: true },
},
},
},
};
const id = resolveDefaultLineAccountId(cfg);
expect(id).toBe("business");
});
it("normalizes channels.line.defaultAccount before lookup", () => {
const cfg: OpenClawConfig = {
channels: {
line: {
defaultAccount: "Business Ops",
accounts: {
"business-ops": { enabled: true },
},
},
},
};
const id = resolveDefaultLineAccountId(cfg);
expect(id).toBe("business-ops");
});
it("returns first named account when default not configured", () => {
const cfg: OpenClawConfig = {
channels: {
@@ -115,6 +148,22 @@ describe("LINE accounts", () => {
expect(id).toBe("business");
});
it("falls back when channels.line.defaultAccount is missing", () => {
const cfg: OpenClawConfig = {
channels: {
line: {
defaultAccount: "missing",
accounts: {
business: { enabled: true },
},
},
},
};
const id = resolveDefaultLineAccountId(cfg);
expect(id).toBe("business");
});
});
describe("normalizeAccountId", () => {