mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-17 02:37:33 +00:00
test: dedupe qa channel inbound mock reads
This commit is contained in:
@@ -46,6 +46,14 @@ function createQaInboundParams(
|
||||
};
|
||||
}
|
||||
|
||||
function firstRunAssembledParams(runtime: ReturnType<typeof createPluginRuntimeMock>) {
|
||||
const call = vi.mocked(runtime.channel.turn.runAssembled).mock.calls[0];
|
||||
if (!call) {
|
||||
throw new Error("expected assembled turn call");
|
||||
}
|
||||
return call[0];
|
||||
}
|
||||
|
||||
describe("isHttpMediaUrl", () => {
|
||||
it("accepts only http and https urls", () => {
|
||||
expect(isHttpMediaUrl("https://example.com/image.png")).toBe(true);
|
||||
@@ -78,12 +86,9 @@ describe("handleQaInbound", () => {
|
||||
);
|
||||
|
||||
expect(runtime.channel.turn.runAssembled).toHaveBeenCalledTimes(1);
|
||||
expect(
|
||||
vi.mocked(runtime.channel.turn.runAssembled).mock.calls.at(0)?.[0].replyPipeline,
|
||||
).toEqual({});
|
||||
expect(
|
||||
vi.mocked(runtime.channel.turn.runAssembled).mock.calls.at(0)?.[0].ctxPayload.WasMentioned,
|
||||
).toBe(true);
|
||||
const assembled = firstRunAssembledParams(runtime);
|
||||
expect(assembled.replyPipeline).toEqual({});
|
||||
expect(assembled.ctxPayload.WasMentioned).toBe(true);
|
||||
});
|
||||
|
||||
it("drops direct messages outside the configured sender allowlist", async () => {
|
||||
@@ -114,9 +119,7 @@ describe("handleQaInbound", () => {
|
||||
);
|
||||
|
||||
expect(runtime.channel.turn.runAssembled).toHaveBeenCalledTimes(1);
|
||||
const ctxPayload = vi
|
||||
.mocked(runtime.channel.turn.runAssembled)
|
||||
.mock.calls.at(0)?.[0].ctxPayload;
|
||||
const ctxPayload = firstRunAssembledParams(runtime).ctxPayload;
|
||||
expect(ctxPayload?.CommandAuthorized).toBe(true);
|
||||
expect(ctxPayload?.SenderId).toBe("alice");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user