test: dedupe model fallback mock reads

This commit is contained in:
Peter Steinberger
2026-05-13 03:01:37 +01:00
parent b8bbe0e1e4
commit 7cb596c807

View File

@@ -328,12 +328,10 @@ function mockPrimaryRunLoopRateLimitThenFallbackSuccess(errorMessage: string) {
function expectOpenAiThenGroqAttemptOrder(params?: { expectOpenAiAuthProfileId?: string }) {
expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(2);
const firstCall = runEmbeddedAttemptMock.mock.calls.at(0)?.[0] as
const firstCall = runEmbeddedAttemptMock.mock.calls[0]?.[0] as
| { provider?: string; authProfileId?: string }
| undefined;
const secondCall = runEmbeddedAttemptMock.mock.calls.at(1)?.[0] as
| { provider?: string }
| undefined;
const secondCall = runEmbeddedAttemptMock.mock.calls[1]?.[0] as { provider?: string } | undefined;
if (!firstCall || !secondCall) {
throw new Error("expected primary and fallback embedded run attempts");
}
@@ -704,7 +702,7 @@ describe("runWithModelFallback + runEmbeddedPiAgent failover behavior", () => {
expect((thrown as Error).message).toBe("Operation aborted");
expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(1);
const firstCall = runEmbeddedAttemptMock.mock.calls.at(0)?.[0] as
const firstCall = runEmbeddedAttemptMock.mock.calls[0]?.[0] as
| { provider?: string }
| undefined;
expect(firstCall?.provider).toBe("openai");