mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:17:26 +00:00
test(imessage): fix monitor test harness usage
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
|||||||
flush,
|
flush,
|
||||||
getCloseResolve,
|
getCloseResolve,
|
||||||
getConfigMock,
|
getConfigMock,
|
||||||
|
getReadAllowFromStoreMock,
|
||||||
getNotificationHandler,
|
getNotificationHandler,
|
||||||
getReplyMock,
|
getReplyMock,
|
||||||
getSendMock,
|
getSendMock,
|
||||||
@@ -40,7 +41,7 @@ describe("monitorIMessageProvider", () => {
|
|||||||
const run = monitorIMessageProvider();
|
const run = monitorIMessageProvider();
|
||||||
await waitForSubscribe();
|
await waitForSubscribe();
|
||||||
|
|
||||||
notificationHandler?.({
|
getNotificationHandler()?.({
|
||||||
method: "message",
|
method: "message",
|
||||||
params: {
|
params: {
|
||||||
message: {
|
message: {
|
||||||
@@ -52,7 +53,7 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await flush();
|
await flush();
|
||||||
closeResolve?.();
|
getCloseResolve()?.();
|
||||||
await run;
|
await run;
|
||||||
|
|
||||||
expect(replyMock).not.toHaveBeenCalled();
|
expect(replyMock).not.toHaveBeenCalled();
|
||||||
@@ -396,7 +397,8 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not allow group sender from pairing store when groupPolicy is allowlist", async () => {
|
it("does not allow group sender from pairing store when groupPolicy is allowlist", async () => {
|
||||||
config = {
|
const config = getConfig();
|
||||||
|
setConfigMock({
|
||||||
...config,
|
...config,
|
||||||
channels: {
|
channels: {
|
||||||
...config.channels,
|
...config.channels,
|
||||||
@@ -408,12 +410,12 @@ describe("monitorIMessageProvider", () => {
|
|||||||
groupAllowFrom: [],
|
groupAllowFrom: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
readAllowFromStoreMock.mockResolvedValue(["+15550003333"]);
|
getReadAllowFromStoreMock().mockResolvedValue(["+15550003333"]);
|
||||||
const run = monitorIMessageProvider();
|
const run = monitorIMessageProvider();
|
||||||
await waitForSubscribe();
|
await waitForSubscribe();
|
||||||
|
|
||||||
notificationHandler?.({
|
getNotificationHandler()?.({
|
||||||
method: "message",
|
method: "message",
|
||||||
params: {
|
params: {
|
||||||
message: {
|
message: {
|
||||||
@@ -428,7 +430,7 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await flush();
|
await flush();
|
||||||
closeResolve?.();
|
getCloseResolve()?.();
|
||||||
await run;
|
await run;
|
||||||
|
|
||||||
expect(replyMock).not.toHaveBeenCalled();
|
expect(replyMock).not.toHaveBeenCalled();
|
||||||
@@ -436,7 +438,8 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not allow sender from pairing store when groupAllowFrom is restricted to a different chat_id", async () => {
|
it("does not allow sender from pairing store when groupAllowFrom is restricted to a different chat_id", async () => {
|
||||||
config = {
|
const config = getConfig();
|
||||||
|
setConfigMock({
|
||||||
...config,
|
...config,
|
||||||
channels: {
|
channels: {
|
||||||
...config.channels,
|
...config.channels,
|
||||||
@@ -448,12 +451,12 @@ describe("monitorIMessageProvider", () => {
|
|||||||
groupAllowFrom: ["chat_id:101"],
|
groupAllowFrom: ["chat_id:101"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
readAllowFromStoreMock.mockResolvedValue(["+15550003333"]);
|
getReadAllowFromStoreMock().mockResolvedValue(["+15550003333"]);
|
||||||
const run = monitorIMessageProvider();
|
const run = monitorIMessageProvider();
|
||||||
await waitForSubscribe();
|
await waitForSubscribe();
|
||||||
|
|
||||||
notificationHandler?.({
|
getNotificationHandler()?.({
|
||||||
method: "message",
|
method: "message",
|
||||||
params: {
|
params: {
|
||||||
message: {
|
message: {
|
||||||
@@ -468,7 +471,7 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await flush();
|
await flush();
|
||||||
closeResolve?.();
|
getCloseResolve()?.();
|
||||||
await run;
|
await run;
|
||||||
|
|
||||||
expect(replyMock).not.toHaveBeenCalled();
|
expect(replyMock).not.toHaveBeenCalled();
|
||||||
@@ -476,7 +479,8 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not authorize control command via pairing-store sender in non-allowlisted chat", async () => {
|
it("does not authorize control command via pairing-store sender in non-allowlisted chat", async () => {
|
||||||
config = {
|
const config = getConfig();
|
||||||
|
setConfigMock({
|
||||||
...config,
|
...config,
|
||||||
channels: {
|
channels: {
|
||||||
...config.channels,
|
...config.channels,
|
||||||
@@ -488,12 +492,12 @@ describe("monitorIMessageProvider", () => {
|
|||||||
groupAllowFrom: ["chat_id:101"],
|
groupAllowFrom: ["chat_id:101"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
readAllowFromStoreMock.mockResolvedValue(["+15550003333"]);
|
getReadAllowFromStoreMock().mockResolvedValue(["+15550003333"]);
|
||||||
const run = monitorIMessageProvider();
|
const run = monitorIMessageProvider();
|
||||||
await waitForSubscribe();
|
await waitForSubscribe();
|
||||||
|
|
||||||
notificationHandler?.({
|
getNotificationHandler()?.({
|
||||||
method: "message",
|
method: "message",
|
||||||
params: {
|
params: {
|
||||||
message: {
|
message: {
|
||||||
@@ -508,7 +512,7 @@ describe("monitorIMessageProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await flush();
|
await flush();
|
||||||
closeResolve?.();
|
getCloseResolve()?.();
|
||||||
await run;
|
await run;
|
||||||
|
|
||||||
expect(replyMock).not.toHaveBeenCalled();
|
expect(replyMock).not.toHaveBeenCalled();
|
||||||
|
|||||||
Reference in New Issue
Block a user