Skip to content

Commit f5c2cce

Browse files
test(requesty): make the effort-filter and deadline tests fail when the guard is removed
Negative reasoning-effort test: the fixture declared supportsReasoningEffort without "minimal", so shouldUseReasoningEffort rejected the settings effort before the request reached Requesty's allowedEffort filter - deleting that filter kept the suite green (verified: old fixture + removed filter passes). The fixture now declares ["minimal", "low", "medium", "high"] so "minimal" reaches the filter, and removing the filter now fails with 'expected { ...(10) } to not have property reasoning_effort'. Deadline test: asserts AbortSignal.timeout was called with 10_000 and that the discovery promise is still unsettled at 9,999 ms. Lowering REQUESTY_MODELS_TIMEOUT_MS to 5_000 now fails the test ('expected "timeout" to be called with arguments: [10000], received 5000') instead of silently producing the same fallback and log.
1 parent 0f18f74 commit f5c2cce

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎src/api/providers/__tests__/requesty.spec.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ describe("RequestyHandler", () => {
401401
contextWindow: 200000,
402402
supportsImages: true,
403403
supportsPromptCache: true,
404-
supportsReasoningEffort: ["low", "medium", "high"],
404+
supportsReasoningEffort: ["minimal", "low", "medium", "high"],
405405
inputPrice: 3,
406406
outputPrice: 15,
407407
description: "Claude 4 Sonnet",
@@ -421,7 +421,10 @@ describe("RequestyHandler", () => {
421421
)
422422
expect(chunks).toHaveLength(1)
423423
expect(mockCreate).toHaveBeenCalledTimes(1)
424-
// "minimal" is outside ["low", "medium", "high"], so the key must be absent entirely.
424+
// "minimal" is declared by the model fixture so it survives shouldUseReasoningEffort and
425+
// reaches the handler, where the Requesty allowed-effort filter must drop it. With the
426+
// older ["low", "medium", "high"] fixture the shared gate rejected "minimal" first, so deleting
427+
// that filter left this test green.
425428
expect(mockCreate.mock.calls[0][0]).not.toHaveProperty("reasoning_effort")
426429
})
427430

‎src/api/providers/fetchers/__tests__/requesty.spec.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,19 @@ describe("getRequestyModels", () => {
305305
)
306306

307307
const pending = getRequestyModels()
308-
await vi.advanceTimersByTimeAsync(10_000)
308+
let settled = false
309+
void pending.then(() => {
310+
settled = true
311+
})
312+
// The merged deadline has to be the documented 10 s: any shorter value also produces the
313+
// fallback and the log, so the assertions below are what pin the value.
314+
expect(timeoutSpy).toHaveBeenCalledWith(10_000)
315+
await vi.advanceTimersByTimeAsync(9_999)
316+
// Nothing may settle before the deadline fires.
317+
expect(settled).toBe(false)
318+
await vi.advanceTimersByTimeAsync(1)
309319
const models = await pending
310-
320+
expect(settled).toBe(true)
311321
// The fallback is intentional: callers use the cached/default model info.
312322
expect(models).toEqual({})
313323
expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining("timed out"))

0 commit comments

Comments
 (0)