mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 22:50:22 +00:00
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { collectStatusIssuesFromLastError } from "../plugin-sdk/status-helpers.js";
|
|
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
|
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
|
|
import { createIMessageTestPlugin } from "../test-utils/imessage-test-plugin.js";
|
|
import { formatGatewayChannelsStatusLines } from "./channels/status.js";
|
|
|
|
const signalPlugin = {
|
|
...createChannelTestPluginBase({ id: "signal" }),
|
|
status: {
|
|
collectStatusIssues: (accounts: Parameters<typeof collectStatusIssuesFromLastError>[1]) =>
|
|
collectStatusIssuesFromLastError("signal", accounts),
|
|
},
|
|
};
|
|
|
|
describe("channels command", () => {
|
|
beforeEach(() => {
|
|
setActivePluginRegistry(
|
|
createTestRegistry([{ pluginId: "signal", source: "test", plugin: signalPlugin }]),
|
|
);
|
|
});
|
|
|
|
afterEach(() => {
|
|
setActivePluginRegistry(createTestRegistry([]));
|
|
});
|
|
|
|
it("surfaces Signal runtime errors in channels status output", () => {
|
|
const lines = formatGatewayChannelsStatusLines({
|
|
channelAccounts: {
|
|
signal: [
|
|
{
|
|
accountId: "default",
|
|
enabled: true,
|
|
configured: true,
|
|
running: false,
|
|
lastError: "signal-cli unreachable",
|
|
},
|
|
],
|
|
},
|
|
});
|
|
expect(lines.join("\n")).toMatch(/Warnings:/);
|
|
expect(lines.join("\n")).toMatch(/signal/i);
|
|
expect(lines.join("\n")).toMatch(/Channel error/i);
|
|
});
|
|
|
|
it("surfaces iMessage runtime errors in channels status output", () => {
|
|
setActivePluginRegistry(
|
|
createTestRegistry([
|
|
{
|
|
pluginId: "imessage",
|
|
source: "test",
|
|
plugin: createIMessageTestPlugin(),
|
|
},
|
|
]),
|
|
);
|
|
const lines = formatGatewayChannelsStatusLines({
|
|
channelAccounts: {
|
|
imessage: [
|
|
{
|
|
accountId: "default",
|
|
enabled: true,
|
|
configured: true,
|
|
running: false,
|
|
lastError: "imsg permission denied",
|
|
},
|
|
],
|
|
},
|
|
});
|
|
expect(lines.join("\n")).toMatch(/Warnings:/);
|
|
expect(lines.join("\n")).toMatch(/imessage/i);
|
|
expect(lines.join("\n")).toMatch(/Channel error/i);
|
|
});
|
|
});
|