test: debrand helper fixture ids

This commit is contained in:
Peter Steinberger 2026-03-27 22:01:15 +00:00
parent be67c0de1d
commit d27b99c6af
3 changed files with 32 additions and 32 deletions

View File

@ -18,8 +18,8 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
it("builds top-level dm policy paths when no account config exists", () => {
expect(
buildAccountScopedDmSecurityPolicy({
cfg: cfgWithChannel("telegram"),
channelKey: "telegram",
cfg: cfgWithChannel("demo-root"),
channelKey: "demo-root",
fallbackAccountId: "default",
policy: "pairing",
allowFrom: ["123"],
@ -28,9 +28,9 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
).toEqual({
policy: "pairing",
allowFrom: ["123"],
policyPath: "channels.telegram.dmPolicy",
allowFromPath: "channels.telegram.",
approveHint: formatPairingApproveHint("telegram"),
policyPath: "channels.demo-root.dmPolicy",
allowFromPath: "channels.demo-root.",
approveHint: formatPairingApproveHint("demo-root"),
normalizeEntry: undefined,
});
});
@ -38,8 +38,8 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
it("uses account-scoped paths when account config exists", () => {
expect(
buildAccountScopedDmSecurityPolicy({
cfg: cfgWithChannel("signal", { work: {} }),
channelKey: "signal",
cfg: cfgWithChannel("demo-account", { work: {} }),
channelKey: "demo-account",
accountId: "work",
fallbackAccountId: "default",
policy: "allowlist",
@ -49,9 +49,9 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
).toEqual({
policy: "allowlist",
allowFrom: ["+12125551212"],
policyPath: "channels.signal.accounts.work.dmPolicy",
allowFromPath: "channels.signal.accounts.work.",
approveHint: formatPairingApproveHint("signal"),
policyPath: "channels.demo-account.accounts.work.dmPolicy",
allowFromPath: "channels.demo-account.accounts.work.",
approveHint: formatPairingApproveHint("demo-account"),
normalizeEntry: undefined,
});
});
@ -59,8 +59,8 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
it("supports nested dm paths without explicit policyPath", () => {
expect(
buildAccountScopedDmSecurityPolicy({
cfg: cfgWithChannel("discord", { work: {} }),
channelKey: "discord",
cfg: cfgWithChannel("demo-nested", { work: {} }),
channelKey: "demo-nested",
accountId: "work",
policy: "pairing",
allowFrom: [],
@ -70,8 +70,8 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
policy: "pairing",
allowFrom: [],
policyPath: undefined,
allowFromPath: "channels.discord.accounts.work.dm.",
approveHint: formatPairingApproveHint("discord"),
allowFromPath: "channels.demo-nested.accounts.work.dm.",
approveHint: formatPairingApproveHint("demo-nested"),
normalizeEntry: undefined,
});
});
@ -79,20 +79,20 @@ describe("buildAccountScopedDmSecurityPolicy", () => {
it("supports custom defaults and approve hints", () => {
expect(
buildAccountScopedDmSecurityPolicy({
cfg: cfgWithChannel("synology-chat"),
channelKey: "synology-chat",
cfg: cfgWithChannel("demo-default"),
channelKey: "demo-default",
fallbackAccountId: "default",
allowFrom: ["user-1"],
defaultPolicy: "allowlist",
policyPathSuffix: "dmPolicy",
approveHint: "openclaw pairing approve synology-chat <code>",
approveHint: "openclaw pairing approve demo-default <code>",
}),
).toEqual({
policy: "allowlist",
allowFrom: ["user-1"],
policyPath: "channels.synology-chat.dmPolicy",
allowFromPath: "channels.synology-chat.",
approveHint: "openclaw pairing approve synology-chat <code>",
policyPath: "channels.demo-default.dmPolicy",
allowFromPath: "channels.demo-default.",
approveHint: "openclaw pairing approve demo-default <code>",
normalizeEntry: undefined,
});
});

View File

@ -15,16 +15,16 @@ describe("createStaticReplyToModeResolver", () => {
describe("createTopLevelChannelReplyToModeResolver", () => {
it("reads the top-level channel config", () => {
const resolver = createTopLevelChannelReplyToModeResolver("discord");
const resolver = createTopLevelChannelReplyToModeResolver("demo-top-level");
expect(
resolver({
cfg: { channels: { discord: { replyToMode: "first" } } } as OpenClawConfig,
cfg: { channels: { "demo-top-level": { replyToMode: "first" } } } as OpenClawConfig,
}),
).toBe("first");
});
it("falls back to off", () => {
const resolver = createTopLevelChannelReplyToModeResolver("discord");
const resolver = createTopLevelChannelReplyToModeResolver("demo-top-level");
expect(resolver({ cfg: {} as OpenClawConfig })).toBe("off");
});
});
@ -35,9 +35,9 @@ describe("createScopedAccountReplyToModeResolver", () => {
resolveAccount: (cfg, accountId) =>
((
cfg.channels as {
matrix?: { accounts?: Record<string, { replyToMode?: "off" | "first" | "all" }> };
demo?: { accounts?: Record<string, { replyToMode?: "off" | "first" | "all" }> };
}
).matrix?.accounts?.[accountId?.toLowerCase() ?? "default"] ?? {}) as {
).demo?.accounts?.[accountId?.toLowerCase() ?? "default"] ?? {}) as {
replyToMode?: "off" | "first" | "all";
},
resolveReplyToMode: (account) => account.replyToMode,
@ -45,7 +45,7 @@ describe("createScopedAccountReplyToModeResolver", () => {
const cfg = {
channels: {
matrix: {
demo: {
accounts: {
assistant: { replyToMode: "all" },
},

View File

@ -28,11 +28,11 @@ describe("formatPluginSourceForTable", () => {
const out = formatPluginSourceForTable(
{
origin: "bundled",
source: path.join(roots.stock, "bluebubbles", "index.ts"),
source: path.join(roots.stock, "demo-stock", "index.ts"),
},
roots,
);
expect(out.value).toBe("stock:bluebubbles/index.ts");
expect(out.value).toBe("stock:demo-stock/index.ts");
expect(out.rootKey).toBe("stock");
});
@ -41,11 +41,11 @@ describe("formatPluginSourceForTable", () => {
const out = formatPluginSourceForTable(
{
origin: "workspace",
source: path.join(roots.workspace, "matrix", "index.ts"),
source: path.join(roots.workspace, "demo-workspace", "index.ts"),
},
roots,
);
expect(out.value).toBe("workspace:matrix/index.ts");
expect(out.value).toBe("workspace:demo-workspace/index.ts");
expect(out.rootKey).toBe("workspace");
});
@ -54,11 +54,11 @@ describe("formatPluginSourceForTable", () => {
const out = formatPluginSourceForTable(
{
origin: "global",
source: path.join(roots.global, "zalo", "index.js"),
source: path.join(roots.global, "demo-global", "index.js"),
},
roots,
);
expect(out.value).toBe("global:zalo/index.js");
expect(out.value).toBe("global:demo-global/index.js");
expect(out.rootKey).toBe("global");
});