fix: add dmScope route guard regression tests (#24949) (thanks @kevinWangSheng)

This commit is contained in:
Peter Steinberger
2026-02-24 03:55:10 +00:00
parent 57783680ad
commit ebde897bb8
2 changed files with 56 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ Docs: https://docs.openclaw.ai
### Fixes
- WhatsApp/DM routing: only update main-session last-route state when DM traffic is bound to the main session, preserving isolated `dmScope` routing. (#24949) Thanks @kevinWangSheng.
- Providers/OpenRouter: when thinking is explicitly off, avoid injecting `reasoning.effort` so reasoning-required models can use provider defaults instead of failing request validation. (#24863) Thanks @DevSecTim.
- Status/Pairing recovery: show explicit pairing-approval command hints (including requestId when safe) when gateway probe failures report pairing-required closures. (#24771) Thanks @markmusson.
- Discord/Threading: recover missing thread parent IDs by refetching thread metadata before resolving parent channel context. (#24897) Thanks @z-x-yang.

View File

@@ -84,6 +84,7 @@ vi.mock("../deliver-reply.js", () => ({
deliverWebReply: deliverWebReplyMock,
}));
import { updateLastRouteInBackground } from "./last-route.js";
import { processMessage } from "./process-message.js";
describe("web processMessage inbound contract", () => {
@@ -302,4 +303,58 @@ describe("web processMessage inbound contract", () => {
const replyOptions = (capturedDispatchParams as any)?.replyOptions;
expect(replyOptions?.disableBlockStreaming).toBe(true);
});
it("updates main last route for DM when session key matches main session key", async () => {
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
updateLastRouteMock.mockClear();
const args = makeProcessMessageArgs({
routeSessionKey: "agent:main:whatsapp:direct:+1000",
groupHistoryKey: "+1000",
msg: {
id: "msg-last-route-1",
from: "+1000",
to: "+2000",
chatType: "direct",
body: "hello",
senderE164: "+1000",
},
});
args.route = {
...args.route,
sessionKey: "agent:main:whatsapp:direct:+1000",
mainSessionKey: "agent:main:whatsapp:direct:+1000",
};
await processMessage(args);
expect(updateLastRouteMock).toHaveBeenCalledTimes(1);
});
it("does not update main last route for isolated DM scope sessions", async () => {
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
updateLastRouteMock.mockClear();
const args = makeProcessMessageArgs({
routeSessionKey: "agent:main:whatsapp:dm:+1000:peer:+3000",
groupHistoryKey: "+3000",
msg: {
id: "msg-last-route-2",
from: "+3000",
to: "+2000",
chatType: "direct",
body: "hello",
senderE164: "+3000",
},
});
args.route = {
...args.route,
sessionKey: "agent:main:whatsapp:dm:+1000:peer:+3000",
mainSessionKey: "agent:main:whatsapp:direct:+1000",
};
await processMessage(args);
expect(updateLastRouteMock).not.toHaveBeenCalled();
});
});