Files
openclaw-zero-token/shared/chat-envelope.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

31 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { stripEnvelope, stripMessageIdHints } from "./chat-envelope.js";
describe("shared/chat-envelope", () => {
it("strips recognized channel and timestamp envelope prefixes only", () => {
expect(stripEnvelope("[WhatsApp 2026-01-24 13:36] hello")).toBe("hello");
expect(stripEnvelope("[Google Chat room] hello")).toBe("hello");
expect(stripEnvelope("[2026-01-24T13:36Z] hello")).toBe("hello");
expect(stripEnvelope("[2026-01-24 13:36] hello")).toBe("hello");
expect(stripEnvelope("[Custom Sender] hello")).toBe("[Custom Sender] hello");
});
it("keeps non-envelope headers and preserves unmatched text", () => {
expect(stripEnvelope("hello")).toBe("hello");
expect(stripEnvelope("[note] hello")).toBe("[note] hello");
expect(stripEnvelope("[2026/01/24 13:36] hello")).toBe("[2026/01/24 13:36] hello");
expect(stripEnvelope("[Teams] hello")).toBe("[Teams] hello");
});
it("removes standalone message id hint lines but keeps inline mentions", () => {
expect(stripMessageIdHints("hello\n[message_id: abc123]")).toBe("hello");
expect(stripMessageIdHints("hello\n [message_id: abc123] \nworld")).toBe("hello\nworld");
expect(stripMessageIdHints("[message_id: abc123]\nhello")).toBe("hello");
expect(stripMessageIdHints("[message_id: abc123]")).toBe("");
expect(stripMessageIdHints("hello\r\n[MESSAGE_ID: abc123]\r\nworld")).toBe("hello\nworld");
expect(stripMessageIdHints("I typed [message_id: abc123] inline")).toBe(
"I typed [message_id: abc123] inline",
);
});
});