Skip to content

Commit 90a0358

Browse files
committed
test(cron): tighten transcript-mock typings for upstream NormalizedOutboundPayload contract
Upstream change tightened NormalizedOutboundPayload to require mediaUrls and narrowed the implicit `vi.fn()` mock-call tuple to the empty argument list. Add explicit AppendFn / ExactFn signatures to the hoisted transcript mocks so `mock.calls[0]?.[0]` resolves to the param shape used by the test assertions, and supply mediaUrls: [] for the synthetic best-effort onError payload.
1 parent cf8f034 commit 90a0358

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/cron/isolated-agent/delivery-dispatch.mirror-bluebubbles.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@ const sessionMetaMocks = vi.hoisted(() => ({
2424
),
2525
}));
2626

27-
const transcriptMocks = vi.hoisted(() => ({
28-
appendAssistantMessageToSessionTranscript: vi.fn(async () => ({ ok: true, sessionFile: "x" })),
29-
appendExactAssistantMessageToSessionTranscript: vi.fn(async () => ({ ok: true })),
30-
}));
27+
type TranscriptAppendArgs = {
28+
agentId?: string;
29+
sessionKey: string;
30+
text: string;
31+
idempotencyKey?: string;
32+
config?: unknown;
33+
};
34+
const transcriptMocks = vi.hoisted(() => {
35+
type AppendFn = (params: TranscriptAppendArgs) => Promise<{ ok: true; sessionFile: string }>;
36+
type ExactFn = (params: TranscriptAppendArgs) => Promise<{ ok: true }>;
37+
return {
38+
appendAssistantMessageToSessionTranscript: vi.fn<AppendFn>(async () => ({
39+
ok: true,
40+
sessionFile: "x",
41+
})),
42+
appendExactAssistantMessageToSessionTranscript: vi.fn<ExactFn>(async () => ({ ok: true })),
43+
};
44+
});
3145

3246
// --- Module mocks (must be hoisted before imports) ---
3347

@@ -417,7 +431,7 @@ describe("dispatchCronDelivery — BlueBubbles transcript mirror", () => {
417431
// target transcript. The mirror append is gated on cron's all-success
418432
// outcome (delivered === true), which best-effort partial failure breaks.
419433
vi.mocked(deliverOutboundPayloads).mockImplementationOnce(async (callParams) => {
420-
callParams.onError?.(new Error("send failed"), { text: "skipped" });
434+
callParams.onError?.(new Error("send failed"), { text: "skipped", mediaUrls: [] });
421435
return [{ ok: true }] as never;
422436
});
423437
const params = {

0 commit comments

Comments
 (0)