




















@@ -107,7 +107,7 @@ describe("sessions", () => {
107107{
108108name: "returns normalized per-sender key",
109109scope: "per-sender" as const,
110-ctx: { From: "whatsapp:+1555" },
110+ctx: { From: "chat:+1555" },
111111expected: "+1555",
112112},
113113{
@@ -125,14 +125,14 @@ describe("sessions", () => {
125125{
126126name: "keeps group chats distinct",
127127scope: "per-sender" as const,
128-ctx: { From: "12345-678@g.us", ChatType: "group", Provider: "whatsapp" },
129-expected: "whatsapp:group:12345-678@g.us",
128+ctx: { From: "room-123", ChatType: "group", Provider: "demo-chat" },
129+expected: "demo-chat:group:room-123",
130130},
131131{
132132name: "prefixes group keys with provider when available",
133133scope: "per-sender" as const,
134-ctx: { From: "12345-678@g.us", ChatType: "group", Provider: "whatsapp" },
135-expected: "whatsapp:group:12345-678@g.us",
134+ctx: { From: "room-456", ChatType: "group", Provider: "demo-chat" },
135+expected: "demo-chat:group:room-456",
136136},
137137] as const;
138138@@ -179,7 +179,7 @@ describe("sessions", () => {
179179{
180180name: "maps direct chats to main key when provided",
181181scope: "per-sender" as const,
182-ctx: { From: "whatsapp:+1555" },
182+ctx: { From: "chat:+1555" },
183183mainKey: "main",
184184expected: "agent:main:main",
185185},
@@ -200,9 +200,9 @@ describe("sessions", () => {
200200{
201201name: "leaves groups untouched even with main key",
202202scope: "per-sender" as const,
203-ctx: { From: "12345-678@g.us", ChatType: "group", Provider: "whatsapp" },
203+ctx: { From: "room-123", ChatType: "group", Provider: "demo-chat" },
204204mainKey: "main",
205-expected: "agent:main:whatsapp:group:12345-678@g.us",
205+expected: "agent:main:demo-chat:group:room-123",
206206},
207207] as const;
208208@@ -268,7 +268,7 @@ describe("sessions", () => {
268268await updateLastRoute({
269269 storePath,
270270sessionKey: mainSessionKey,
271-channel: "whatsapp",
271+channel: "demo-chat",
272272to: "111",
273273accountId: "legacy",
274274deliveryContext: {
@@ -325,7 +325,7 @@ describe("sessions", () => {
325325});
326326327327it("updateLastRoute records origin + group metadata when ctx is provided", async () => {
328-const sessionKey = "agent:main:whatsapp:group:123@g.us";
328+const sessionKey = "agent:main:demo-chat:group:room-123";
329329const { storePath } = await createSessionStoreFixture({
330330prefix: "updateLastRoute",
331331entries: {},
@@ -335,23 +335,23 @@ describe("sessions", () => {
335335 storePath,
336336 sessionKey,
337337deliveryContext: {
338-channel: "whatsapp",
339-to: "123@g.us",
338+channel: "demo-chat",
339+to: "room-123",
340340},
341341ctx: {
342-Provider: "whatsapp",
342+Provider: "demo-chat",
343343ChatType: "group",
344344GroupSubject: "Family",
345-From: "123@g.us",
345+From: "room-123",
346346},
347347});
348348349349const store = loadSessionStore(storePath);
350350expect(store[sessionKey]?.subject).toBe("Family");
351-expect(store[sessionKey]?.channel).toBe("whatsapp");
352-expect(store[sessionKey]?.groupId).toBe("123@g.us");
353-expect(store[sessionKey]?.origin?.label).toBe("Family id:123@g.us");
354-expect(store[sessionKey]?.origin?.provider).toBe("whatsapp");
351+expect(store[sessionKey]?.channel).toBe("demo-chat");
352+expect(store[sessionKey]?.groupId).toBe("room-123");
353+expect(store[sessionKey]?.origin?.label).toBe("Family");
354+expect(store[sessionKey]?.origin?.provider).toBe("demo-chat");
355355expect(store[sessionKey]?.origin?.chatType).toBe("group");
356356});
357357@@ -461,18 +461,18 @@ describe("sessions", () => {
461461store["agent:main:main"] = {
462462sessionId: "sess-normalized",
463463updatedAt: Date.now(),
464-lastChannel: " WhatsApp ",
464+lastChannel: " Demo Chat ",
465465lastTo: " +1555 ",
466466lastAccountId: " acct-1 ",
467467};
468468});
469469470470const store = loadSessionStore(storePath);
471-expect(store["agent:main:main"]?.lastChannel).toBe("whatsapp");
471+expect(store["agent:main:main"]?.lastChannel).toBe("demo chat");
472472expect(store["agent:main:main"]?.lastTo).toBe("+1555");
473473expect(store["agent:main:main"]?.lastAccountId).toBe("acct-1");
474474expect(store["agent:main:main"]?.deliveryContext).toEqual({
475-channel: "whatsapp",
475+channel: "demo chat",
476476to: "+1555",
477477accountId: "acct-1",
478478});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。