Files
openclaw/extensions/qa-lab/src/qa-bus-protocol.test.ts
Peter Steinberger 154d1277e1 fix(qa): repair package Telegram harness boundaries (#108499)
* fix(qa): keep packaged entry off private transport

* fix(qa): lazy-load private transport runtime

* fix(qa): pass relative package artifact path

* fix(qa): isolate packaged bus protocol

* fix(qa): mount package scenario catalog
2026-07-15 19:24:55 -07:00

61 lines
1.9 KiB
TypeScript

import {
parseQaTarget as parseCanonicalQaTarget,
sanitizeQaBusToolCalls as sanitizeCanonicalQaBusToolCalls,
} from "openclaw/plugin-sdk/qa-channel-protocol";
import { describe, expect, it } from "vitest";
import { parseQaTarget, sanitizeQaBusToolCalls } from "./qa-bus-protocol.js";
describe("QA Lab package bus protocol", () => {
it.each([
"bare-id",
"channel:CaseSensitive",
"group:team-room",
"dm:user-1",
"thread:Room/Topic",
])("matches the canonical target parser for %s", (target) => {
expect(parseQaTarget(target)).toEqual(parseCanonicalQaTarget(target));
});
it.each(["", "CHANNEL:CaseSensitive", "thread:Room/", "dm:"])(
"matches canonical target errors for %j",
(target) => {
expect(() => parseQaTarget(target)).toThrow();
expect(() => parseCanonicalQaTarget(target)).toThrow();
},
);
it("matches canonical bounded redaction", () => {
const toolCalls = [
null,
{ name: 123 },
{
name: " exec ",
arguments: {
command: "cat README.md",
apiToken: "secret-token",
headers: { Authorization: "Bearer secret" },
values: ["ok", { password: "hunter2" }],
nested: { one: { two: { three: { four: "truncated" } } } },
finite: 42,
infinite: Number.POSITIVE_INFINITY,
bigint: 123n,
omitted: undefined,
},
},
];
expect(sanitizeQaBusToolCalls(toolCalls)).toEqual(sanitizeCanonicalQaBusToolCalls(toolCalls));
});
it("matches the canonical count limit without processing the tail", () => {
const toolCalls = Array.from({ length: 50 }, (_, index) => ({ name: `tool-${index}` }));
toolCalls.push({
get name(): string {
throw new Error("tail should not be sanitized");
},
});
expect(sanitizeQaBusToolCalls(toolCalls)).toEqual(sanitizeCanonicalQaBusToolCalls(toolCalls));
});
});