mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 14:21:34 +00:00
Co-authored-by: chengzhichao-xydt <chengzhichao-xydt@users.noreply.github.com> Co-authored-by: wangmiao0668000666 <wang.miao86@xydigit.com> Co-authored-by: 黄剑雄0668001315 <huang.jianxiong@xydigit.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
// Plugin list format tests cover installed plugin table and JSON formatting.
|
|
import { describe, expect, it } from "vitest";
|
|
import { createPluginRecord } from "../plugins/status.test-helpers.js";
|
|
import { formatPluginLine } from "./plugins-list-format.js";
|
|
|
|
describe("formatPluginLine", () => {
|
|
it("labels active registry entries as enabled rather than loaded", () => {
|
|
const output = formatPluginLine(createPluginRecord({ id: "demo", enabled: true }));
|
|
|
|
expect(output).toContain("enabled");
|
|
expect(output).not.toContain("loaded");
|
|
});
|
|
|
|
it("shows imported state in verbose output", () => {
|
|
const output = formatPluginLine(
|
|
createPluginRecord({
|
|
id: "demo",
|
|
name: "Demo Plugin",
|
|
imported: false,
|
|
activated: true,
|
|
explicitlyEnabled: false,
|
|
}),
|
|
true,
|
|
);
|
|
|
|
expect(output).toContain("activated: yes");
|
|
expect(output).toContain("imported: no");
|
|
expect(output).toContain("explicitly enabled: no");
|
|
});
|
|
|
|
it("sanitizes activation reasons in verbose output", () => {
|
|
const output = formatPluginLine(
|
|
createPluginRecord({
|
|
id: "demo",
|
|
name: "Demo Plugin",
|
|
activated: true,
|
|
activationSource: "auto",
|
|
activationReason: "\u001B[31mconfigured\nnext\tstep",
|
|
}),
|
|
true,
|
|
);
|
|
|
|
expect(output).toContain("activation reason: configured\\nnext\\tstep");
|
|
expect(output).not.toContain("\u001B[31m");
|
|
expect(output.match(/activation reason:/g)).toHaveLength(1);
|
|
});
|
|
|
|
it("keeps truncated descriptions free of lone surrogates", () => {
|
|
const output = formatPluginLine(
|
|
createPluginRecord({ id: "demo", description: `${"a".repeat(56)}😀tail` }),
|
|
);
|
|
expect(Buffer.from(output).toString()).toBe(output);
|
|
});
|
|
});
|