mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
fix(conversion): improve stream failures and diagnostic exports
This commit is contained in:
@@ -4,6 +4,7 @@ const { getMock } = vi.hoisted(() => ({ getMock: vi.fn() }))
|
||||
vi.mock('@/api/client', () => ({ default: { get: getMock } }))
|
||||
|
||||
import { dashboardApi } from '@/api/dashboard'
|
||||
import { requestTraceApi } from '@/api/requestTrace'
|
||||
import { cache } from '@/utils/cache'
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -13,6 +14,20 @@ beforeEach(() => {
|
||||
})
|
||||
|
||||
describe('dashboard body loading', () => {
|
||||
it('reports download progress so diagnostic exports can abort oversized bodies', async () => {
|
||||
const onProgress = vi.fn()
|
||||
getMock.mockResolvedValue({ data: new ArrayBuffer(0), headers: { 'x-aether-body-encoding': 'json', 'x-aether-usage-id': 'usage-1', 'x-aether-body-field': 'response_body' } })
|
||||
await dashboardApi.getRequestBody('usage-1', 'response_body', undefined, onProgress)
|
||||
getMock.mock.calls[0][1].onDownloadProgress({ loaded: 2 * 1024 * 1024 })
|
||||
expect(onProgress).toHaveBeenCalledWith(2 * 1024 * 1024)
|
||||
})
|
||||
|
||||
it('records the gateway version at export without confusing it with failure-time metadata', async () => {
|
||||
getMock.mockResolvedValue({ data: { request_id: 'request-1', candidates: [] }, headers: { 'x-aether-build-version': 'test-build' } })
|
||||
expect(await requestTraceApi.getRequestTrace('request-1')).toMatchObject({ gateway_version: 'test-build' })
|
||||
getMock.mockResolvedValue({ data: { request_id: 'request-1', candidates: [] } })
|
||||
expect(await requestTraceApi.getRequestTrace('request-1')).toMatchObject({ gateway_version: null })
|
||||
})
|
||||
it('requests opaque body bytes, outside the JSON detail cache', async () => {
|
||||
const bytes = new ArrayBuffer(20)
|
||||
const controller = new AbortController()
|
||||
|
||||
Reference in New Issue
Block a user