feat(platform-web): query raw frames with post body
This commit is contained in:
39
vehicle-data-platform/apps/web/src/api/client.test.ts
Normal file
39
vehicle-data-platform/apps/web/src/api/client.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { afterEach, expect, test, vi } from 'vitest';
|
||||
import { api } from './client';
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
test('rawFramesQuery posts structured JSON instead of URL query strings', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 20, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response);
|
||||
|
||||
await api.rawFramesQuery({
|
||||
keyword: '粤AG18312',
|
||||
protocol: 'GB32960',
|
||||
fields: ['gb32960.vehicle.speed_kmh'],
|
||||
includeFields: true,
|
||||
limit: 20,
|
||||
offset: 0
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
keyword: '粤AG18312',
|
||||
protocol: 'GB32960',
|
||||
fields: ['gb32960.vehicle.speed_kmh'],
|
||||
includeFields: true,
|
||||
limit: 20,
|
||||
offset: 0
|
||||
})
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user