mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 19:44:44 +00:00
test: clear irc broad matchers
This commit is contained in:
@@ -129,7 +129,8 @@ describe("irc inbound behavior", () => {
|
||||
expect.stringContaining("Your IRC id: alice!ident@example.com"),
|
||||
undefined,
|
||||
);
|
||||
expect(sendReply).toHaveBeenCalledWith("alice", expect.stringContaining("CODE"), undefined);
|
||||
const replyMessages = sendReply.mock.calls.map((call) => String(call[1]));
|
||||
expect(replyMessages.some((message) => message.includes("CODE"))).toBe(true);
|
||||
});
|
||||
|
||||
it("drops unauthorized group control commands before dispatch", async () => {
|
||||
@@ -184,10 +185,7 @@ describe("irc inbound behavior", () => {
|
||||
sendReply: vi.fn(async () => {}),
|
||||
});
|
||||
|
||||
expect(coreRuntime.channel.turn.runAssembled).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
replyPipeline: {},
|
||||
}),
|
||||
);
|
||||
const assembledRequest = coreRuntime.channel.turn.runAssembled.mock.calls[0]?.[0];
|
||||
expect(assembledRequest?.replyPipeline).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,13 +56,14 @@ describe("probeIrc", () => {
|
||||
});
|
||||
|
||||
it("returns latency and quits the probe client on success", async () => {
|
||||
resolveIrcAccountMock.mockReturnValue({
|
||||
const account = {
|
||||
configured: true,
|
||||
host: "irc.libera.chat",
|
||||
port: 6697,
|
||||
tls: true,
|
||||
nick: "openclaw",
|
||||
});
|
||||
};
|
||||
resolveIrcAccountMock.mockReturnValue(account);
|
||||
buildIrcConnectOptionsMock.mockReturnValue({ host: "irc.libera.chat" });
|
||||
const quit = vi.fn();
|
||||
connectIrcClientMock.mockResolvedValue({ quit });
|
||||
@@ -71,10 +72,7 @@ describe("probeIrc", () => {
|
||||
try {
|
||||
const result = await probeIrc({} as never, { timeoutMs: 5000 });
|
||||
|
||||
expect(buildIrcConnectOptionsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ host: "irc.libera.chat" }),
|
||||
{ connectTimeoutMs: 5000 },
|
||||
);
|
||||
expect(buildIrcConnectOptionsMock).toHaveBeenCalledWith(account, { connectTimeoutMs: 5000 });
|
||||
expect(result).toEqual({
|
||||
ok: true,
|
||||
host: "irc.libera.chat",
|
||||
|
||||
@@ -243,54 +243,47 @@ describe("sendMessageIrc cfg threading", () => {
|
||||
} as unknown as IrcClient & { quit: ReturnType<typeof vi.fn> };
|
||||
hoisted.connectIrcClient.mockResolvedValue(client);
|
||||
|
||||
await expect(
|
||||
verifyChannelMessageAdapterCapabilityProofs({
|
||||
adapterName: "irc",
|
||||
adapter: ircMessageAdapter,
|
||||
proofs: {
|
||||
text: async () => {
|
||||
const result = await ircMessageAdapter.send?.text?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "hello",
|
||||
});
|
||||
expect(result?.receipt.platformMessageIds).toEqual(["irc-msg-1"]);
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith("#room", "hello");
|
||||
},
|
||||
media: async () => {
|
||||
const result = await ircMessageAdapter.send?.media?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "image",
|
||||
mediaUrl: "https://example.com/image.png",
|
||||
});
|
||||
expect(result?.receipt.platformMessageIds).toEqual(["irc-msg-1"]);
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith(
|
||||
"#room",
|
||||
"image\n\nAttachment: https://example.com/image.png",
|
||||
);
|
||||
},
|
||||
replyTo: async () => {
|
||||
const result = await ircMessageAdapter.send?.text?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "threaded",
|
||||
replyToId: "parent-1",
|
||||
});
|
||||
expect(result?.receipt.replyToId).toBe("parent-1");
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith(
|
||||
"#room",
|
||||
"threaded\n\n[reply:parent-1]",
|
||||
);
|
||||
},
|
||||
const proofResults = await verifyChannelMessageAdapterCapabilityProofs({
|
||||
adapterName: "irc",
|
||||
adapter: ircMessageAdapter,
|
||||
proofs: {
|
||||
text: async () => {
|
||||
const result = await ircMessageAdapter.send?.text?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "hello",
|
||||
});
|
||||
expect(result?.receipt.platformMessageIds).toEqual(["irc-msg-1"]);
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith("#room", "hello");
|
||||
},
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.arrayContaining([
|
||||
{ capability: "text", status: "verified" },
|
||||
{ capability: "media", status: "verified" },
|
||||
{ capability: "replyTo", status: "verified" },
|
||||
]),
|
||||
);
|
||||
media: async () => {
|
||||
const result = await ircMessageAdapter.send?.media?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "image",
|
||||
mediaUrl: "https://example.com/image.png",
|
||||
});
|
||||
expect(result?.receipt.platformMessageIds).toEqual(["irc-msg-1"]);
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith(
|
||||
"#room",
|
||||
"image\n\nAttachment: https://example.com/image.png",
|
||||
);
|
||||
},
|
||||
replyTo: async () => {
|
||||
const result = await ircMessageAdapter.send?.text?.({
|
||||
cfg: providedCfg,
|
||||
to: "#room",
|
||||
text: "threaded",
|
||||
replyToId: "parent-1",
|
||||
});
|
||||
expect(result?.receipt.replyToId).toBe("parent-1");
|
||||
expect(client.sendPrivmsg).toHaveBeenCalledWith("#room", "threaded\n\n[reply:parent-1]");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(proofResults.find((result) => result.capability === "text")?.status).toBe("verified");
|
||||
expect(proofResults.find((result) => result.capability === "media")?.status).toBe("verified");
|
||||
expect(proofResults.find((result) => result.capability === "replyTo")?.status).toBe("verified");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user