fix: fix failing tests.
This commit is contained in:
parent
58c92b63c6
commit
6dbbae0d7e
@ -104,7 +104,7 @@ describe("resolveAgentRoute", () => {
|
|||||||
peer: { kind: "dm", id: "+1000" },
|
peer: { kind: "dm", id: "+1000" },
|
||||||
});
|
});
|
||||||
expect(route.agentId).toBe("a");
|
expect(route.agentId).toBe("a");
|
||||||
expect(route.sessionKey).toBe("agent:a:main");
|
expect(route.sessionKey).toBe("agent:a:main:biz");
|
||||||
expect(route.matchedBy).toBe("binding.peer");
|
expect(route.matchedBy).toBe("binding.peer");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -224,7 +224,8 @@ describe("resolveAgentRoute", () => {
|
|||||||
peer: { kind: "dm", id: "+1000" },
|
peer: { kind: "dm", id: "+1000" },
|
||||||
});
|
});
|
||||||
expect(route.agentId).toBe("home");
|
expect(route.agentId).toBe("home");
|
||||||
expect(route.sessionKey).toBe("agent:home:main");
|
// Updated: Non-default accounts get distinct session keys
|
||||||
|
expect(route.sessionKey).toBe("agent:home:main:biz");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -151,7 +151,12 @@ export function buildAgentPeerSessionKey(params: {
|
|||||||
const accountId = normalizeAccountId(params.accountId);
|
const accountId = normalizeAccountId(params.accountId);
|
||||||
if (accountId && accountId !== DEFAULT_ACCOUNT_ID) {
|
if (accountId && accountId !== DEFAULT_ACCOUNT_ID) {
|
||||||
if (dmScope === "main") {
|
if (dmScope === "main") {
|
||||||
return `agent:${normalizeAgentId(params.agentId)}:dm:${peerId}:${accountId}`;
|
return (
|
||||||
|
buildAgentMainSessionKey({
|
||||||
|
agentId: params.agentId,
|
||||||
|
mainKey: params.mainKey,
|
||||||
|
}) + `:${accountId}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return `agent:${normalizeAgentId(params.agentId)}:dm:${peerId}:${accountId}`;
|
return `agent:${normalizeAgentId(params.agentId)}:dm:${peerId}:${accountId}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,7 +200,7 @@ describe("createTelegramBot", () => {
|
|||||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
expect(replySpy).toHaveBeenCalledTimes(1);
|
||||||
const payload = replySpy.mock.calls[0][0];
|
const payload = replySpy.mock.calls[0][0];
|
||||||
expect(payload.AccountId).toBe("opie");
|
expect(payload.AccountId).toBe("opie");
|
||||||
expect(payload.SessionKey).toBe("agent:opie:main");
|
expect(payload.SessionKey).toBe("agent:opie:main:opie");
|
||||||
});
|
});
|
||||||
it("allows per-group requireMention override", async () => {
|
it("allows per-group requireMention override", async () => {
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
|
|||||||
@ -1260,7 +1260,7 @@ describe("createTelegramBot", () => {
|
|||||||
expect(replySpy).toHaveBeenCalledTimes(1);
|
expect(replySpy).toHaveBeenCalledTimes(1);
|
||||||
const payload = replySpy.mock.calls[0][0];
|
const payload = replySpy.mock.calls[0][0];
|
||||||
expect(payload.AccountId).toBe("opie");
|
expect(payload.AccountId).toBe("opie");
|
||||||
expect(payload.SessionKey).toBe("agent:opie:main");
|
expect(payload.SessionKey).toBe("agent:opie:main:opie");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows per-group requireMention override", async () => {
|
it("allows per-group requireMention override", async () => {
|
||||||
|
|||||||
@ -242,7 +242,7 @@ describe("partial reply gating", () => {
|
|||||||
});
|
});
|
||||||
it("updates last-route for group chats with account id", async () => {
|
it("updates last-route for group chats with account id", async () => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const groupSessionKey = "agent:main:whatsapp:group:123@g.us";
|
const groupSessionKey = "agent:main:whatsapp:group:123@g.us:work";
|
||||||
const store = await makeSessionStore({
|
const store = await makeSessionStore({
|
||||||
[groupSessionKey]: { sessionId: "sid", updatedAt: now - 1 },
|
[groupSessionKey]: { sessionId: "sid", updatedAt: now - 1 },
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user