mirror of https://github.com/openclaw/openclaw.git
test: dedupe inbound main scope fixtures
This commit is contained in:
parent
ccd763aef7
commit
22e976574c
|
|
@ -362,13 +362,14 @@ describe("web processMessage inbound contract", () => {
|
||||||
expect(updateLastRouteMock).not.toHaveBeenCalled();
|
expect(updateLastRouteMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not update main last route for non-owner sender when main DM scope is pinned", async () => {
|
function makePinnedMainScopeArgs(params: {
|
||||||
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
|
groupHistoryKey: string;
|
||||||
updateLastRouteMock.mockClear();
|
messageId: string;
|
||||||
|
from: string;
|
||||||
|
}) {
|
||||||
const args = makeProcessMessageArgs({
|
const args = makeProcessMessageArgs({
|
||||||
routeSessionKey: "agent:main:main",
|
routeSessionKey: "agent:main:main",
|
||||||
groupHistoryKey: "+3000",
|
groupHistoryKey: params.groupHistoryKey,
|
||||||
cfg: {
|
cfg: {
|
||||||
channels: {
|
channels: {
|
||||||
whatsapp: {
|
whatsapp: {
|
||||||
|
|
@ -379,12 +380,12 @@ describe("web processMessage inbound contract", () => {
|
||||||
session: { store: sessionStorePath, dmScope: "main" },
|
session: { store: sessionStorePath, dmScope: "main" },
|
||||||
} as unknown as ReturnType<typeof import("../../../config/config.js").loadConfig>,
|
} as unknown as ReturnType<typeof import("../../../config/config.js").loadConfig>,
|
||||||
msg: {
|
msg: {
|
||||||
id: "msg-last-route-3",
|
id: params.messageId,
|
||||||
from: "+3000",
|
from: params.from,
|
||||||
to: "+2000",
|
to: "+2000",
|
||||||
chatType: "direct",
|
chatType: "direct",
|
||||||
body: "hello",
|
body: "hello",
|
||||||
senderE164: "+3000",
|
senderE164: params.from,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
args.route = {
|
args.route = {
|
||||||
|
|
@ -392,6 +393,18 @@ describe("web processMessage inbound contract", () => {
|
||||||
sessionKey: "agent:main:main",
|
sessionKey: "agent:main:main",
|
||||||
mainSessionKey: "agent:main:main",
|
mainSessionKey: "agent:main:main",
|
||||||
};
|
};
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
it("does not update main last route for non-owner sender when main DM scope is pinned", async () => {
|
||||||
|
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
|
||||||
|
updateLastRouteMock.mockClear();
|
||||||
|
|
||||||
|
const args = makePinnedMainScopeArgs({
|
||||||
|
groupHistoryKey: "+3000",
|
||||||
|
messageId: "msg-last-route-3",
|
||||||
|
from: "+3000",
|
||||||
|
});
|
||||||
|
|
||||||
await processMessage(args);
|
await processMessage(args);
|
||||||
|
|
||||||
|
|
@ -402,32 +415,11 @@ describe("web processMessage inbound contract", () => {
|
||||||
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
|
const updateLastRouteMock = vi.mocked(updateLastRouteInBackground);
|
||||||
updateLastRouteMock.mockClear();
|
updateLastRouteMock.mockClear();
|
||||||
|
|
||||||
const args = makeProcessMessageArgs({
|
const args = makePinnedMainScopeArgs({
|
||||||
routeSessionKey: "agent:main:main",
|
|
||||||
groupHistoryKey: "+1000",
|
groupHistoryKey: "+1000",
|
||||||
cfg: {
|
messageId: "msg-last-route-4",
|
||||||
channels: {
|
|
||||||
whatsapp: {
|
|
||||||
allowFrom: ["+1000"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
messages: {},
|
|
||||||
session: { store: sessionStorePath, dmScope: "main" },
|
|
||||||
} as unknown as ReturnType<typeof import("../../../config/config.js").loadConfig>,
|
|
||||||
msg: {
|
|
||||||
id: "msg-last-route-4",
|
|
||||||
from: "+1000",
|
from: "+1000",
|
||||||
to: "+2000",
|
|
||||||
chatType: "direct",
|
|
||||||
body: "hello",
|
|
||||||
senderE164: "+1000",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
args.route = {
|
|
||||||
...args.route,
|
|
||||||
sessionKey: "agent:main:main",
|
|
||||||
mainSessionKey: "agent:main:main",
|
|
||||||
};
|
|
||||||
|
|
||||||
await processMessage(args);
|
await processMessage(args);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue