test: dedupe fixtures and test harness setup

This commit is contained in:
Peter Steinberger
2026-02-23 05:43:30 +00:00
parent 8af19ddc5b
commit 1c753ea786
75 changed files with 1886 additions and 2136 deletions

View File

@@ -1,6 +1,8 @@
import { vi } from "vitest";
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
import type { CliDeps } from "../cli/deps.js";
import { runCronIsolatedAgentTurn } from "./isolated-agent.js";
import { makeCfg, makeJob } from "./isolated-agent.test-harness.js";
export function createCliDeps(overrides: Partial<CliDeps> = {}): CliDeps {
return {
@@ -27,3 +29,29 @@ export function mockAgentPayloads(
...extra,
});
}
export async function runTelegramAnnounceTurn(params: {
home: string;
storePath: string;
deps: CliDeps;
delivery: {
mode: "announce";
channel: string;
to?: string;
bestEffort?: boolean;
};
}): Promise<Awaited<ReturnType<typeof runCronIsolatedAgentTurn>>> {
return runCronIsolatedAgentTurn({
cfg: makeCfg(params.home, params.storePath, {
channels: { telegram: { botToken: "t-1" } },
}),
deps: params.deps,
job: {
...makeJob({ kind: "agentTurn", message: "do it" }),
delivery: params.delivery,
},
message: "do it",
sessionKey: "cron:job-1",
lane: "cron",
});
}