feat(platform-web): support shareable vehicle routes

This commit is contained in:
lingniu
2026-07-04 01:13:07 +08:00
parent beb5034b9b
commit 8e5cb5b8c7
4 changed files with 154 additions and 6 deletions

View File

@@ -1,9 +1,53 @@
import { render, screen } from '@testing-library/react';
import { expect, test } from 'vitest';
import { afterEach, expect, test, vi } from 'vitest';
import App from '../App';
afterEach(() => {
window.history.replaceState(null, '', '/');
vi.restoreAllMocks();
});
test('renders vehicle platform shell', () => {
render(<App />);
expect(screen.getByText('车辆服务中台')).toBeInTheDocument();
expect(screen.getAllByText('总览工作台').length).toBeGreaterThanOrEqual(1);
});
test('opens vehicle detail from shareable hash', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=%E7%B2%A4AG18312');
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
ok: true,
json: async () => ({
data: {
vin: 'LB9A32A24R0LS1426',
lookupKey: '粤AG18312',
lookupResolved: true,
resolution: {
lookupKey: '粤AG18312',
resolved: true,
vin: 'LB9A32A24R0LS1426',
plate: '粤AG18312',
phone: '13307795425',
oem: 'G7s',
protocols: ['GB32960', 'JT808'],
online: true,
lastSeen: '2026-07-03 20:12:10'
},
sources: ['GB32960', 'JT808'],
sourceStatus: [],
realtime: [],
history: { items: [], total: 0, limit: 20, offset: 0 },
raw: { items: [], total: 0, limit: 10, offset: 0 },
mileage: { items: [], total: 0, limit: 20, offset: 0 },
quality: { items: [], total: 0, limit: 20, offset: 0 }
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response);
render(<App />);
expect(await screen.findByDisplayValue('粤AG18312')).toBeInTheDocument();
expect(screen.getAllByText('车辆服务').length).toBeGreaterThanOrEqual(1);
});