* refactor: move Discord channel implementation to extensions/discord/src/ Move all Discord source files from src/discord/ to extensions/discord/src/, following the extension migration pattern. Source files in src/discord/ are replaced with re-export shims. Channel-plugin files from src/channels/plugins/*/discord* are similarly moved and shimmed. - Copy all .ts source files preserving subdirectory structure (monitor/, voice/) - Move channel-plugin files (actions, normalize, onboarding, outbound, status-issues) - Fix all relative imports to use correct paths from new location - Create re-export shims at original locations for backward compatibility - Delete test files from shim locations (tests live in extension now) - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." to accommodate extension files outside src/ - Update write-plugin-sdk-entry-dts.ts to match new declaration output paths * fix: add importOriginal to thread-bindings session-meta mock for extensions test * style: fix formatting in thread-bindings lifecycle test
118 lines
3.0 KiB
TypeScript
118 lines
3.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { resolveDiscordAccount, resolveDiscordMaxLinesPerMessage } from "./accounts.js";
|
|
|
|
describe("resolveDiscordAccount allowFrom precedence", () => {
|
|
it("prefers accounts.default.allowFrom over top-level for default account", () => {
|
|
const resolved = resolveDiscordAccount({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
allowFrom: ["top"],
|
|
accounts: {
|
|
default: { allowFrom: ["default"], token: "token-default" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
accountId: "default",
|
|
});
|
|
|
|
expect(resolved.config.allowFrom).toEqual(["default"]);
|
|
});
|
|
|
|
it("falls back to top-level allowFrom for named account without override", () => {
|
|
const resolved = resolveDiscordAccount({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
allowFrom: ["top"],
|
|
accounts: {
|
|
work: { token: "token-work" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
accountId: "work",
|
|
});
|
|
|
|
expect(resolved.config.allowFrom).toEqual(["top"]);
|
|
});
|
|
|
|
it("does not inherit default account allowFrom for named account when top-level is absent", () => {
|
|
const resolved = resolveDiscordAccount({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
accounts: {
|
|
default: { allowFrom: ["default"], token: "token-default" },
|
|
work: { token: "token-work" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
accountId: "work",
|
|
});
|
|
|
|
expect(resolved.config.allowFrom).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("resolveDiscordMaxLinesPerMessage", () => {
|
|
it("falls back to merged root discord maxLinesPerMessage when runtime config omits it", () => {
|
|
const resolved = resolveDiscordMaxLinesPerMessage({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
maxLinesPerMessage: 120,
|
|
accounts: {
|
|
default: { token: "token-default" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
discordConfig: {},
|
|
accountId: "default",
|
|
});
|
|
|
|
expect(resolved).toBe(120);
|
|
});
|
|
|
|
it("prefers explicit runtime discord maxLinesPerMessage over merged config", () => {
|
|
const resolved = resolveDiscordMaxLinesPerMessage({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
maxLinesPerMessage: 120,
|
|
accounts: {
|
|
default: { token: "token-default", maxLinesPerMessage: 80 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
discordConfig: { maxLinesPerMessage: 55 },
|
|
accountId: "default",
|
|
});
|
|
|
|
expect(resolved).toBe(55);
|
|
});
|
|
|
|
it("uses per-account discord maxLinesPerMessage over the root value when runtime config omits it", () => {
|
|
const resolved = resolveDiscordMaxLinesPerMessage({
|
|
cfg: {
|
|
channels: {
|
|
discord: {
|
|
maxLinesPerMessage: 120,
|
|
accounts: {
|
|
work: { token: "token-work", maxLinesPerMessage: 80 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
discordConfig: {},
|
|
accountId: "work",
|
|
});
|
|
|
|
expect(resolved).toBe(80);
|
|
});
|
|
});
|