From f0a90160d3be1692e02d61bcc3c0c7e3926ed22b Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Thu, 3 Dec 2026 14:13:01 -0800 Subject: [PATCH] test(stale-fixture): cover the primary models candidate serving a stale fixture Ported from #650. When the first candidate in an OpenRouter models list serves a stale fixture, the journal entry carries staleFixture and the STALE FIXTURE warning is logged. The existing fallback test only covers a later candidate winning. --- src/__tests__/stale-fixture.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/__tests__/stale-fixture.test.ts b/src/__tests__/stale-fixture.test.ts index f1c137d5..601460b1 100644 --- a/src/__tests__/stale-fixture.test.ts +++ b/src/__tests__/stale-fixture.test.ts @@ -281,6 +281,21 @@ describe("stale fixture detection (#638)", () => { }); } + it("flags a stale fixture when the primary OpenRouter candidate wins", async () => { + const fixtures = await record("/v1/chat/completions", openaiBody(RECORDED)); + const r = await replay( + fixtures, + "/api/v1/chat/completions", + JSON.stringify({ ...openaiBody(CHANGED), models: ["gpt-5", "other-model"] }), + ); + expect(r.status).toBe(200); + expect(r.entry.response.staleFixture).toEqual({ + expected: fixtures[0].metadata?.requestHash, + actual: expect.stringMatching(/^[0-9a-f]{16}$/), + }); + expect(staleWarnings(r.warnings)).toHaveLength(1); + }); + it("the issue's hand-written fixtures (no hash) are never flagged", async () => { const fixtures: Fixture[] = [ {