feat(platform-web): surface backend api errors
This commit is contained in:
@@ -37,3 +37,21 @@ test('rawFramesQuery posts structured JSON instead of URL query strings', async
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
test('api errors include backend message and detail', async () => {
|
||||
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: false,
|
||||
status: 500,
|
||||
json: async () => ({
|
||||
error: {
|
||||
code: 'INTERNAL',
|
||||
message: '服务处理失败',
|
||||
detail: 'TDengine timeout'
|
||||
},
|
||||
traceId: 'trace-error',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response);
|
||||
|
||||
await expect(api.opsHealth()).rejects.toThrow('服务处理失败: TDengine timeout');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user