Files
openclaw-zero-token/config/issue-format.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

95 lines
2.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import {
formatConfigIssueLine,
formatConfigIssueLines,
normalizeConfigIssue,
normalizeConfigIssuePath,
normalizeConfigIssues,
} from "./issue-format.js";
describe("config issue format", () => {
it("normalizes empty paths to <root>", () => {
expect(normalizeConfigIssuePath("")).toBe("<root>");
expect(normalizeConfigIssuePath(" ")).toBe("<root>");
expect(normalizeConfigIssuePath(null)).toBe("<root>");
expect(normalizeConfigIssuePath(undefined)).toBe("<root>");
});
it("formats issue lines with and without markers", () => {
expect(formatConfigIssueLine({ path: "", message: "broken" }, "-")).toBe("- : broken");
expect(
formatConfigIssueLine({ path: "", message: "broken" }, "-", { normalizeRoot: true }),
).toBe("- <root>: broken");
expect(formatConfigIssueLine({ path: "gateway.bind", message: "invalid" }, "")).toBe(
"gateway.bind: invalid",
);
expect(
formatConfigIssueLines(
[
{ path: "", message: "first" },
{ path: "channels.signal.dmPolicy", message: "second" },
],
"×",
{ normalizeRoot: true },
),
).toEqual(["× <root>: first", "× channels.signal.dmPolicy: second"]);
});
it("sanitizes control characters and ANSI sequences in formatted lines", () => {
expect(
formatConfigIssueLine(
{
path: "gateway.\nbind\x1b[31m",
message: "bad\r\n\tvalue\x1b[0m\u0007",
},
"-",
),
).toBe("- gateway.\\nbind: bad\\r\\n\\tvalue");
});
it("normalizes issue metadata for machine output", () => {
expect(
normalizeConfigIssue({
path: "",
message: "invalid",
allowedValues: ["stable", "beta"],
allowedValuesHiddenCount: 0,
}),
).toEqual({
path: "<root>",
message: "invalid",
allowedValues: ["stable", "beta"],
});
expect(
normalizeConfigIssues([
{
path: "update.channel",
message: "invalid",
allowedValues: [],
allowedValuesHiddenCount: 2,
},
]),
).toEqual([
{
path: "update.channel",
message: "invalid",
},
]);
expect(
normalizeConfigIssue({
path: "update.channel",
message: "invalid",
allowedValues: ["stable"],
allowedValuesHiddenCount: 2,
}),
).toEqual({
path: "update.channel",
message: "invalid",
allowedValues: ["stable"],
allowedValuesHiddenCount: 2,
});
});
});