test(perf): dedupe isolated-agent delivery announce cases

This commit is contained in:
Peter Steinberger
2026-03-02 14:24:19 +00:00
parent c2d41dc473
commit 5561a6b659

View File

@@ -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 }) => {