feat(platform): resolve vehicle identity before navigation

This commit is contained in:
lingniu
2026-07-04 01:06:24 +08:00
parent 3e76210d7d
commit 703a7b112f
9 changed files with 189 additions and 8 deletions

View File

@@ -38,6 +38,32 @@ test('rawFramesQuery posts structured JSON instead of URL query strings', async
});
});
test('vehicleResolve sends keyword to the identity resolution endpoint', async () => {
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
lookupKey: '粤AG18312',
resolved: true,
vin: 'LB9A32A24R0LS1426',
plate: '粤AG18312',
phone: '13307795425',
oem: 'G7s',
protocols: ['GB32960', 'JT808'],
online: true,
lastSeen: '2026-07-03 20:12:10'
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
const result = await api.vehicleResolve(new URLSearchParams({ keyword: '粤AG18312' }));
expect(fetchMock).toHaveBeenCalledWith('/api/vehicles/resolve?keyword=%E7%B2%A4AG18312', undefined);
expect(result.vin).toBe('LB9A32A24R0LS1426');
});
test('api errors include backend message, detail, and trace id', async () => {
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: false,