mirror of https://github.com/openclaw/openclaw.git
test: dedupe thread ownership send checks
This commit is contained in:
parent
8ca510a669
commit
40b0cbd713
|
|
@ -51,6 +51,13 @@ describe("thread-ownership plugin", () => {
|
||||||
register(api as any);
|
register(api as any);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function sendSlackThreadMessage() {
|
||||||
|
return await hooks.message_sending(
|
||||||
|
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
||||||
|
{ channelId: "slack", conversationId: "C123" },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
it("allows non-slack channels", async () => {
|
it("allows non-slack channels", async () => {
|
||||||
const result = await hooks.message_sending(
|
const result = await hooks.message_sending(
|
||||||
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
||||||
|
|
@ -76,10 +83,7 @@ describe("thread-ownership plugin", () => {
|
||||||
new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }),
|
new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await hooks.message_sending(
|
const result = await sendSlackThreadMessage();
|
||||||
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
|
||||||
{ channelId: "slack", conversationId: "C123" },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
expect(globalThis.fetch).toHaveBeenCalledWith(
|
expect(globalThis.fetch).toHaveBeenCalledWith(
|
||||||
|
|
@ -96,10 +100,7 @@ describe("thread-ownership plugin", () => {
|
||||||
new Response(JSON.stringify({ owner: "other-agent" }), { status: 409 }),
|
new Response(JSON.stringify({ owner: "other-agent" }), { status: 409 }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await hooks.message_sending(
|
const result = await sendSlackThreadMessage();
|
||||||
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
|
||||||
{ channelId: "slack", conversationId: "C123" },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result).toEqual({ cancel: true });
|
expect(result).toEqual({ cancel: true });
|
||||||
expect(api.logger.info).toHaveBeenCalledWith(expect.stringContaining("cancelled send"));
|
expect(api.logger.info).toHaveBeenCalledWith(expect.stringContaining("cancelled send"));
|
||||||
|
|
@ -108,10 +109,7 @@ describe("thread-ownership plugin", () => {
|
||||||
it("fails open on network error", async () => {
|
it("fails open on network error", async () => {
|
||||||
vi.mocked(globalThis.fetch).mockRejectedValue(new Error("ECONNREFUSED"));
|
vi.mocked(globalThis.fetch).mockRejectedValue(new Error("ECONNREFUSED"));
|
||||||
|
|
||||||
const result = await hooks.message_sending(
|
const result = await sendSlackThreadMessage();
|
||||||
{ content: "hello", metadata: { threadTs: "1234.5678", channelId: "C123" }, to: "C123" },
|
|
||||||
{ channelId: "slack", conversationId: "C123" },
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result).toBeUndefined();
|
expect(result).toBeUndefined();
|
||||||
expect(api.logger.warn).toHaveBeenCalledWith(
|
expect(api.logger.warn).toHaveBeenCalledWith(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue