mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 02:01:35 +00:00
* fix(imessage): keep CLI stderr tail truncation UTF-16 safe * test(imessage): hit stderr surrogate boundary * fix(imessage): use plugin sdk text helper --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
28 lines
922 B
TypeScript
28 lines
922 B
TypeScript
// Imessage tests cover cli output plugin behavior.
|
|
import { describe, expect, it } from "vitest";
|
|
import { appendIMessageCliStderrTail, appendIMessageCliStdout } from "./cli-output.js";
|
|
|
|
describe("iMessage CLI output bounds", () => {
|
|
it("rejects stdout once the JSON capture exceeds the cap", () => {
|
|
const result = appendIMessageCliStdout("abc", "def", 5);
|
|
|
|
expect(result).toEqual({
|
|
ok: false,
|
|
message: "imsg stdout exceeded 5 characters",
|
|
});
|
|
});
|
|
|
|
it("keeps only recent stderr details", () => {
|
|
const result = appendIMessageCliStderrTail("old-noise:", "recent-error", 12);
|
|
|
|
expect(result).toBe("recent-error");
|
|
});
|
|
|
|
it("does not split a surrogate pair at the tail boundary", () => {
|
|
const input = `x🚀${"y".repeat(10)}`;
|
|
|
|
expect(input.slice(-11)).toBe(`\ude80${"y".repeat(10)}`);
|
|
expect(appendIMessageCliStderrTail("", input, 11)).toBe("y".repeat(10));
|
|
});
|
|
});
|