feat(platform-web): query raw frames with post body

This commit is contained in:
lingniu
2026-07-04 00:48:13 +08:00
parent a4ff210c82
commit 894d200a16
3 changed files with 77 additions and 2 deletions

View 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
})
});
});