mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:14:34 +00:00
refactor(commands): dedupe config-only channel status fixtures
This commit is contained in:
@@ -4,17 +4,34 @@ import { setActivePluginRegistry } from "../plugins/runtime.js";
|
|||||||
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||||
import { formatConfigChannelsStatusLines } from "./channels/status.js";
|
import { formatConfigChannelsStatusLines } from "./channels/status.js";
|
||||||
|
|
||||||
function makeUnavailableTokenPlugin(): ChannelPlugin {
|
function makeDirectPlugin(params: {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
docsPath: string;
|
||||||
|
config: ChannelPlugin["config"];
|
||||||
|
}): ChannelPlugin {
|
||||||
return {
|
return {
|
||||||
id: "token-only",
|
id: params.id,
|
||||||
meta: {
|
meta: {
|
||||||
id: "token-only",
|
id: params.id,
|
||||||
label: "TokenOnly",
|
label: params.label,
|
||||||
selectionLabel: "TokenOnly",
|
selectionLabel: params.label,
|
||||||
docsPath: "/channels/token-only",
|
docsPath: params.docsPath,
|
||||||
blurb: "test",
|
blurb: "test",
|
||||||
},
|
},
|
||||||
capabilities: { chatTypes: ["direct"] },
|
capabilities: { chatTypes: ["direct"] },
|
||||||
|
config: params.config,
|
||||||
|
actions: {
|
||||||
|
listActions: () => ["send"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeUnavailableTokenPlugin(): ChannelPlugin {
|
||||||
|
return makeDirectPlugin({
|
||||||
|
id: "token-only",
|
||||||
|
label: "TokenOnly",
|
||||||
|
docsPath: "/channels/token-only",
|
||||||
config: {
|
config: {
|
||||||
listAccountIds: () => ["primary"],
|
listAccountIds: () => ["primary"],
|
||||||
defaultAccountId: () => "primary",
|
defaultAccountId: () => "primary",
|
||||||
@@ -29,23 +46,14 @@ function makeUnavailableTokenPlugin(): ChannelPlugin {
|
|||||||
isConfigured: () => true,
|
isConfigured: () => true,
|
||||||
isEnabled: () => true,
|
isEnabled: () => true,
|
||||||
},
|
},
|
||||||
actions: {
|
});
|
||||||
listActions: () => ["send"],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeResolvedTokenPlugin(): ChannelPlugin {
|
function makeResolvedTokenPlugin(): ChannelPlugin {
|
||||||
return {
|
return makeDirectPlugin({
|
||||||
id: "token-only",
|
|
||||||
meta: {
|
|
||||||
id: "token-only",
|
id: "token-only",
|
||||||
label: "TokenOnly",
|
label: "TokenOnly",
|
||||||
selectionLabel: "TokenOnly",
|
|
||||||
docsPath: "/channels/token-only",
|
docsPath: "/channels/token-only",
|
||||||
blurb: "test",
|
|
||||||
},
|
|
||||||
capabilities: { chatTypes: ["direct"] },
|
|
||||||
config: {
|
config: {
|
||||||
listAccountIds: () => ["primary"],
|
listAccountIds: () => ["primary"],
|
||||||
defaultAccountId: () => "primary",
|
defaultAccountId: () => "primary",
|
||||||
@@ -80,10 +88,7 @@ function makeResolvedTokenPlugin(): ChannelPlugin {
|
|||||||
isConfigured: () => true,
|
isConfigured: () => true,
|
||||||
isEnabled: () => true,
|
isEnabled: () => true,
|
||||||
},
|
},
|
||||||
actions: {
|
});
|
||||||
listActions: () => ["send"],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeResolvedTokenPluginWithoutInspectAccount(): ChannelPlugin {
|
function makeResolvedTokenPluginWithoutInspectAccount(): ChannelPlugin {
|
||||||
@@ -123,16 +128,10 @@ function makeResolvedTokenPluginWithoutInspectAccount(): ChannelPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeUnavailableHttpSlackPlugin(): ChannelPlugin {
|
function makeUnavailableHttpSlackPlugin(): ChannelPlugin {
|
||||||
return {
|
return makeDirectPlugin({
|
||||||
id: "slack",
|
|
||||||
meta: {
|
|
||||||
id: "slack",
|
id: "slack",
|
||||||
label: "Slack",
|
label: "Slack",
|
||||||
selectionLabel: "Slack",
|
|
||||||
docsPath: "/channels/slack",
|
docsPath: "/channels/slack",
|
||||||
blurb: "test",
|
|
||||||
},
|
|
||||||
capabilities: { chatTypes: ["direct"] },
|
|
||||||
config: {
|
config: {
|
||||||
listAccountIds: () => ["primary"],
|
listAccountIds: () => ["primary"],
|
||||||
defaultAccountId: () => "primary",
|
defaultAccountId: () => "primary",
|
||||||
@@ -157,10 +156,20 @@ function makeUnavailableHttpSlackPlugin(): ChannelPlugin {
|
|||||||
isConfigured: () => true,
|
isConfigured: () => true,
|
||||||
isEnabled: () => true,
|
isEnabled: () => true,
|
||||||
},
|
},
|
||||||
actions: {
|
});
|
||||||
listActions: () => ["send"],
|
}
|
||||||
},
|
|
||||||
};
|
function expectResolvedTokenStatusSummary(
|
||||||
|
summary: string,
|
||||||
|
options?: { includeUnavailableTokenLine?: boolean },
|
||||||
|
) {
|
||||||
|
expect(summary).toContain("TokenOnly");
|
||||||
|
expect(summary).toContain("configured");
|
||||||
|
expect(summary).toContain("token:config");
|
||||||
|
expect(summary).not.toContain("secret unavailable in this command path");
|
||||||
|
if (options?.includeUnavailableTokenLine === false) {
|
||||||
|
expect(summary).not.toContain("token:config (unavailable)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("config-only channels status output", () => {
|
describe("config-only channels status output", () => {
|
||||||
@@ -211,11 +220,7 @@ describe("config-only channels status output", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const joined = lines.join("\n");
|
const joined = lines.join("\n");
|
||||||
expect(joined).toContain("TokenOnly");
|
expectResolvedTokenStatusSummary(joined, { includeUnavailableTokenLine: false });
|
||||||
expect(joined).toContain("configured");
|
|
||||||
expect(joined).toContain("token:config");
|
|
||||||
expect(joined).not.toContain("secret unavailable in this command path");
|
|
||||||
expect(joined).not.toContain("token:config (unavailable)");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not resolve raw source config for extension channels without inspectAccount", async () => {
|
it("does not resolve raw source config for extension channels without inspectAccount", async () => {
|
||||||
@@ -240,10 +245,7 @@ describe("config-only channels status output", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const joined = lines.join("\n");
|
const joined = lines.join("\n");
|
||||||
expect(joined).toContain("TokenOnly");
|
expectResolvedTokenStatusSummary(joined);
|
||||||
expect(joined).toContain("configured");
|
|
||||||
expect(joined).toContain("token:config");
|
|
||||||
expect(joined).not.toContain("secret unavailable in this command path");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders Slack HTTP signing-secret availability in config-only status", async () => {
|
it("renders Slack HTTP signing-secret availability in config-only status", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user