mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 05:30:35 +00:00
test(perf): dedupe isolated-agent delivery announce cases
This commit is contained in:
@@ -133,16 +133,18 @@ 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,
|
home: params.home,
|
||||||
storePath,
|
storePath: params.storePath,
|
||||||
deps,
|
deps: params.deps,
|
||||||
});
|
});
|
||||||
|
|
||||||
expectDeliveredOk(res);
|
expectDeliveredOk(res);
|
||||||
@@ -161,8 +163,7 @@ async function expectExplicitTelegramTargetAnnounce(params: {
|
|||||||
expect((announceArgs as { expectsCompletionMessage?: boolean })?.expectsCompletionMessage).toBe(
|
expect((announceArgs as { expectsCompletionMessage?: boolean })?.expectsCompletionMessage).toBe(
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
expect(deps.sendMessageTelegram).not.toHaveBeenCalled();
|
expect(params.deps.sendMessageTelegram).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("runCronIsolatedAgentTurn", () => {
|
describe("runCronIsolatedAgentTurn", () => {
|
||||||
@@ -170,19 +171,25 @@ 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 }) => {
|
||||||
|
await assertExplicitTelegramTargetAnnounce({
|
||||||
|
home,
|
||||||
|
storePath,
|
||||||
|
deps,
|
||||||
payloads: [{ text: "hello from cron" }],
|
payloads: [{ text: "hello from cron" }],
|
||||||
expectedText: "hello from cron",
|
expectedText: "hello from cron",
|
||||||
});
|
});
|
||||||
});
|
vi.clearAllMocks();
|
||||||
|
await assertExplicitTelegramTargetAnnounce({
|
||||||
it("announces the final payload text when delivery has an explicit target", async () => {
|
home,
|
||||||
await expectExplicitTelegramTargetAnnounce({
|
storePath,
|
||||||
|
deps,
|
||||||
payloads: [{ text: "Working on it..." }, { text: "Final weather summary" }],
|
payloads: [{ text: "Working on it..." }, { text: "Final weather summary" }],
|
||||||
expectedText: "Final weather summary",
|
expectedText: "Final weather summary",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("routes announce injection to the delivery-target session key", async () => {
|
it("routes announce injection to the delivery-target session key", async () => {
|
||||||
await withTelegramAnnounceFixture(async ({ home, storePath, deps }) => {
|
await withTelegramAnnounceFixture(async ({ home, storePath, deps }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user