fix: restore coding history and quota feedback
This commit is contained in:
1 parent
38f85f6b5e
commit
d523b72cf8
14 files changed
+480
-49
No files matched your search
@@ -274,6 +274,40 @@ describe('ai proxy routes', () => {
|
||||
expect(response.body()).toBe(JSON.stringify({ error: 'user quota is not enough' }));
|
||||
});
|
||||
|
||||
it('maps the observed token-point balance 403 to a non-retryable quota response', async () => {
|
||||
seedWorksSquareAIGatewayCredential({
|
||||
accessToken: 'ws-ai-token',
|
||||
expiresIn: 3600,
|
||||
oneApiBaseUrl: 'https://one-api.example.com/v1',
|
||||
});
|
||||
const body = JSON.stringify({
|
||||
error: {
|
||||
message: '词元点数余额不足',
|
||||
code: 'token_point_balance_exhausted',
|
||||
type: 'one_api_error',
|
||||
},
|
||||
});
|
||||
const fetchMock = vi.fn().mockResolvedValueOnce(
|
||||
new Response(body, {
|
||||
status: 403,
|
||||
headers: { 'content-type': 'application/json' },
|
||||
}),
|
||||
);
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const response = createResponse();
|
||||
|
||||
await handleAiProxyRoutes(
|
||||
createRequest('POST', { model: 'deepseek-v4-flash', messages: [] }),
|
||||
response.res,
|
||||
new URL('http://127.0.0.1:13210/api/ai-proxy/v1/chat/completions'),
|
||||
{} as never,
|
||||
);
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledOnce();
|
||||
expect(response.statusCode).toBe(402);
|
||||
expect(response.body()).toBe(body);
|
||||
});
|
||||
|
||||
it('maps rolling-window quota exhaustion to a non-retryable response status', async () => {
|
||||
seedWorksSquareAIGatewayCredential({
|
||||
accessToken: 'ws-ai-token',
|
||||
|
||||
Reference in new issue
Block a user