This commit is contained in:
2026-08-04 14:15:32 +08:00
parent 6b876ed1af
commit d1ac7d7c17
6 changed files with 46 additions and 4 deletions
+17
View File
@@ -63,6 +63,23 @@ describe('API error diagnostics', () => {
})
})
it('explains a proxy 413 response without a JSON error envelope', () => {
const error = new axios.AxiosError('Request failed', 'ERR_BAD_REQUEST', undefined, undefined, {
status: 413,
statusText: 'Payload Too Large',
headers: {},
config: { headers: new AxiosHeaders() },
data: '<html>Request Entity Too Large</html>',
})
expect(getApiErrorDetails(error)).toEqual({
message: '上传文件的请求体过大,服务器已拒绝;请压缩后重试,如文件未超过 5MB,请联系管理员检查网关上传限制',
code: 'HTTP_413',
requestId: undefined,
traceId: undefined,
})
})
it('notifies session expiry once when concurrent 401 requests share a failed refresh', async () => {
const refresh = vi.fn(async () => { throw new Error('refresh token expired') })
const expired = vi.fn()