Skip to content

Commit 6f27176

Browse files
committed
Change test to not fail in dev
1 parent 371ca3c commit 6f27176

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,17 @@ describe('/api/v1/chat/completions POST endpoint', () => {
624624
})
625625

626626
it('rejects free-mode requests when location is unknown', async () => {
627+
// Use a TEST-NET-1 IP (RFC 5737) that geoip-lite cannot resolve, with
628+
// no cf-ipcountry header. This avoids the dev-only localhost bypass
629+
// (which kicks in when there is no cf-ipcountry AND no/loopback IP).
627630
const req = new NextRequest(
628631
'http://localhost:3000/api/v1/chat/completions',
629632
{
630633
method: 'POST',
631-
headers: { Authorization: 'Bearer test-api-key-new-free' },
634+
headers: {
635+
Authorization: 'Bearer test-api-key-new-free',
636+
'cf-connecting-ip': '192.0.2.1',
637+
},
632638
body: JSON.stringify({
633639
model: 'minimax/minimax-m2.7',
634640
stream: false,
@@ -658,7 +664,7 @@ describe('/api/v1/chat/completions POST endpoint', () => {
658664
const body = await response.json()
659665
expect(body.error).toBe('free_mode_unavailable')
660666
expect(body.countryCode).toBe('UNKNOWN')
661-
expect(body.countryBlockReason).toBe('missing_client_ip')
667+
expect(body.countryBlockReason).toBe('unresolved_client_ip')
662668
})
663669

664670
it('rejects free-mode requests from anonymized Cloudflare country codes', async () => {

0 commit comments

Comments
 (0)