Skip to content

Commit 63e3ded

Browse files
committed
Stabilize Gemini thinker rate limit test
1 parent 49fe268 commit 63e3ded

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

web/src/app/api/v1/chat/completions/__tests__/completions.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ describe('/api/v1/chat/completions POST endpoint', () => {
5353
id: 'user-reviewer-rate-limit',
5454
banned: false,
5555
},
56+
'test-api-key-gemini-rate-limit': {
57+
id: 'user-gemini-rate-limit',
58+
banned: false,
59+
},
5660
}
5761

5862
const mockGetUserInfoFromApiKey: GetUserInfoFromApiKeyFn = async ({
@@ -1100,10 +1104,14 @@ describe('/api/v1/chat/completions POST endpoint', () => {
11001104
it(
11011105
'counts child Gemini thinker requests toward the free-mode request limit',
11021106
async () => {
1107+
expect(checkFreeModeRateLimit('user-gemini-rate-limit').limited).toBe(
1108+
false,
1109+
)
1110+
11031111
const createRequest = () =>
11041112
new NextRequest('http://localhost:3000/api/v1/chat/completions', {
11051113
method: 'POST',
1106-
headers: allowedFreeModeHeaders('test-api-key-new-free-gemini'),
1114+
headers: allowedFreeModeHeaders('test-api-key-gemini-rate-limit'),
11071115
body: JSON.stringify({
11081116
model: FREEBUFF_GEMINI_PRO_MODEL_ID,
11091117
stream: false,
@@ -1130,11 +1138,9 @@ describe('/api/v1/chat/completions POST endpoint', () => {
11301138
})
11311139

11321140
const firstResponse = await postChatCompletions(createPostParams())
1133-
const secondResponse = await postChatCompletions(createPostParams())
11341141
const limitedResponse = await postChatCompletions(createPostParams())
11351142

11361143
expect(firstResponse.status).toBe(200)
1137-
expect(secondResponse.status).toBe(200)
11381144
expect(limitedResponse.status).toBe(429)
11391145
const body = await limitedResponse.json()
11401146
expect(body.error).toBe('free_mode_rate_limited')

0 commit comments

Comments
 (0)