mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 19:22:56 +00:00
test(perf): dedupe isolated-agent delivery announce cases
This commit is contained in:
@@ -133,36 +133,37 @@ async function runAnnounceFlowResult(bestEffort: boolean) {
|
|||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function expectExplicitTelegramTargetAnnounce(params: {
|
async function assertExplicitTelegramTargetAnnounce(params: {
|
||||||
|
home: string;
|
||||||
|
storePath: string;
|
||||||
|
deps: CliDeps;
|
||||||
payloads: Array<Record<string, unknown>>;
|
payloads: Array<Record<string, unknown>>;
|
||||||
expectedText: string;
|
expectedText: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
await withTelegramAnnounceFixture(async ({ home, storePath, deps }) => {
|
mockAgentPayloads(params.payloads);
|
||||||
mockAgentPayloads(params.payloads);
|
const res = await runExplicitTelegramAnnounceTurn({
|
||||||
const res = await runExplicitTelegramAnnounceTurn({
|
home: params.home,
|
||||||
home,
|
storePath: params.storePath,
|
||||||
storePath,
|
deps: params.deps,
|
||||||
deps,
|
|
||||||
});
|
|
||||||
|
|
||||||
expectDeliveredOk(res);
|
|
||||||
expect(runSubagentAnnounceFlow).toHaveBeenCalledTimes(1);
|
|
||||||
const announceArgs = vi.mocked(runSubagentAnnounceFlow).mock.calls[0]?.[0] as
|
|
||||||
| {
|
|
||||||
requesterOrigin?: { channel?: string; to?: string };
|
|
||||||
roundOneReply?: string;
|
|
||||||
bestEffortDeliver?: boolean;
|
|
||||||
}
|
|
||||||
| undefined;
|
|
||||||
expect(announceArgs?.requesterOrigin?.channel).toBe("telegram");
|
|
||||||
expect(announceArgs?.requesterOrigin?.to).toBe("123");
|
|
||||||
expect(announceArgs?.roundOneReply).toBe(params.expectedText);
|
|
||||||
expect(announceArgs?.bestEffortDeliver).toBe(false);
|
|
||||||
expect((announceArgs as { expectsCompletionMessage?: boolean })?.expectsCompletionMessage).toBe(
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
expect(deps.sendMessageTelegram).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expectDeliveredOk(res);
|
||||||
|
expect(runSubagentAnnounceFlow).toHaveBeenCalledTimes(1);
|
||||||
|
const announceArgs = vi.mocked(runSubagentAnnounceFlow).mock.calls[0]?.[0] as
|
||||||
|
| {
|
||||||
|
requesterOrigin?: { channel?: string; to?: string };
|
||||||
|
roundOneReply?: string;
|
||||||
|
bestEffortDeliver?: boolean;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
expect(announceArgs?.requesterOrigin?.channel).toBe("telegram");
|
||||||
|
expect(announceArgs?.requesterOrigin?.to).toBe("123");
|
||||||
|
expect(announceArgs?.roundOneReply).toBe(params.expectedText);
|
||||||
|
expect(announceArgs?.bestEffortDeliver).toBe(false);
|
||||||
|
expect((announceArgs as { expectsCompletionMessage?: boolean })?.expectsCompletionMessage).toBe(
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
expect(params.deps.sendMessageTelegram).not.toHaveBeenCalled();
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("runCronIsolatedAgentTurn", () => {
|
describe("runCronIsolatedAgentTurn", () => {
|
||||||
@@ -170,17 +171,23 @@ describe("runCronIsolatedAgentTurn", () => {
|
|||||||
setupIsolatedAgentTurnMocks();
|
setupIsolatedAgentTurnMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("routes text-only explicit target delivery through announce flow", async () => {
|
it("announces explicit targets with direct and final-payload text", async () => {
|
||||||
await expectExplicitTelegramTargetAnnounce({
|
await withTelegramAnnounceFixture(async ({ home, storePath, deps }) => {
|
||||||
payloads: [{ text: "hello from cron" }],
|
await assertExplicitTelegramTargetAnnounce({
|
||||||
expectedText: "hello from cron",
|
home,
|
||||||
});
|
storePath,
|
||||||
});
|
deps,
|
||||||
|
payloads: [{ text: "hello from cron" }],
|
||||||
it("announces the final payload text when delivery has an explicit target", async () => {
|
expectedText: "hello from cron",
|
||||||
await expectExplicitTelegramTargetAnnounce({
|
});
|
||||||
payloads: [{ text: "Working on it..." }, { text: "Final weather summary" }],
|
vi.clearAllMocks();
|
||||||
expectedText: "Final weather summary",
|
await assertExplicitTelegramTargetAnnounce({
|
||||||
|
home,
|
||||||
|
storePath,
|
||||||
|
deps,
|
||||||
|
payloads: [{ text: "Working on it..." }, { text: "Final weather summary" }],
|
||||||
|
expectedText: "Final weather summary",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user