Files
openclaw-zero-token/channels/conversation-label.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

71 lines
2.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { MsgContext } from "../auto-reply/templating.js";
import { resolveConversationLabel } from "./conversation-label.js";
describe("resolveConversationLabel", () => {
it.each([
{
name: "prefers ConversationLabel when present",
ctx: { ConversationLabel: "Pinned Label", ChatType: "group" },
expected: "Pinned Label",
},
{
name: "prefers ThreadLabel over derived chat labels",
ctx: {
ThreadLabel: "Thread Alpha",
ChatType: "group",
GroupSubject: "Ops",
From: "demo-channel:group:42",
},
expected: "Thread Alpha",
},
{
name: "uses SenderName for direct chats when available",
ctx: { ChatType: "direct", SenderName: "Ada", From: "demo-channel:99" },
expected: "Ada",
},
{
name: "falls back to From for direct chats when SenderName is missing",
ctx: { ChatType: "direct", From: "demo-channel:99" },
expected: "demo-channel:99",
},
{
name: "derives numeric-id group labels",
ctx: { ChatType: "group", GroupSubject: "Ops", From: "demo-channel:group:42" },
expected: "Ops id:42",
},
{
name: "does not append ids for #rooms/channels",
ctx: {
ChatType: "channel",
GroupSubject: "#general",
From: "slack:channel:C123",
},
expected: "#general",
},
{
name: "does not append ids when the base already contains the id",
ctx: {
ChatType: "group",
GroupSubject: "Family id:123@g.us",
From: "whatsapp:group:123@g.us",
},
expected: "Family id:123@g.us",
},
{
name: "appends ids for WhatsApp-like group ids when a subject exists",
ctx: {
ChatType: "group",
GroupSubject: "Family",
From: "whatsapp:group:123@g.us",
},
expected: "Family id:123@g.us",
},
] satisfies Array<{ name: string; ctx: MsgContext; expected: string }>)(
"$name",
({ ctx, expected }) => {
expect(resolveConversationLabel(ctx)).toBe(expected);
},
);
});