feat(platform-web): use lightweight overview for vehicle context
This commit is contained in:
@@ -59,7 +59,7 @@ test('shows vehicle service status distribution on dashboard', async () => {
|
||||
|
||||
test('shows resolved vehicle service status after topbar search', async () => {
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/ops/health')) {
|
||||
return {
|
||||
@@ -81,28 +81,26 @@ test('shows resolved vehicle service status after topbar search', async () => {
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/vehicles/resolve')) {
|
||||
if (path.includes('/api/vehicle-service/overview')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
lookupKey: '粤AG18312',
|
||||
resolved: true,
|
||||
vin: 'LB9A32A24R0LS1426',
|
||||
plate: '粤AG18312',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808'],
|
||||
online: true,
|
||||
primaryProtocol: 'JT808',
|
||||
coverageStatus: 'partial',
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
serviceStatus: {
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '部分来源离线',
|
||||
detail: '1/2 个来源在线',
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1
|
||||
}
|
||||
realtimeCount: 2,
|
||||
historyCount: 0,
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
@@ -147,6 +145,8 @@ test('shows resolved vehicle service status after topbar search', async () => {
|
||||
|
||||
expect(await screen.findByText('当前车辆:部分来源离线')).toBeInTheDocument();
|
||||
expect(screen.getByText('粤AG18312 / LB9A32A24R0LS1426')).toBeInTheDocument();
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/vehicle-service/overview?keyword=%E7%B2%A4AG18312'), undefined);
|
||||
expect(fetchMock).not.toHaveBeenCalledWith(expect.stringContaining('/api/vehicles/resolve'), undefined);
|
||||
});
|
||||
|
||||
test('shows row service status in dashboard vehicle previews', async () => {
|
||||
@@ -397,28 +397,26 @@ test('shows vehicle context when opening detail from shareable hash', async () =
|
||||
window.history.replaceState(null, '', '/#/detail?keyword=VIN001');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/vehicles/resolve')) {
|
||||
if (path.includes('/api/vehicle-service/overview')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
lookupKey: 'VIN001',
|
||||
resolved: true,
|
||||
vin: 'VIN001',
|
||||
plate: '粤AG18312',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808'],
|
||||
online: true,
|
||||
primaryProtocol: 'JT808',
|
||||
coverageStatus: 'partial',
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
serviceStatus: {
|
||||
status: 'degraded',
|
||||
severity: 'warning',
|
||||
title: '部分来源离线',
|
||||
detail: '1/2 个来源在线',
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 1
|
||||
}
|
||||
realtimeCount: 2,
|
||||
historyCount: 0,
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
@@ -468,28 +466,26 @@ test('refreshes vehicle context when hash changes to another detail vehicle', as
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/vehicles/resolve')) {
|
||||
if (path.includes('/api/vehicle-service/overview')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
lookupKey: 'VIN002',
|
||||
resolved: true,
|
||||
vin: 'VIN002',
|
||||
plate: '粤B20002',
|
||||
phone: '',
|
||||
oem: 'G7s',
|
||||
protocols: ['JT808'],
|
||||
online: false,
|
||||
primaryProtocol: 'JT808',
|
||||
coverageStatus: 'offline',
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 0,
|
||||
lastSeen: '2026-07-03 20:10:10',
|
||||
serviceStatus: {
|
||||
status: 'offline',
|
||||
severity: 'error',
|
||||
title: '车辆离线',
|
||||
detail: '所有已知数据来源均未在线',
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 0
|
||||
}
|
||||
realtimeCount: 1,
|
||||
historyCount: 0,
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
@@ -552,28 +548,26 @@ test('shows vehicle context when opening detail from sidebar navigation', async
|
||||
window.history.replaceState(null, '', '/#/dashboard');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/vehicles/resolve')) {
|
||||
if (path.includes('/api/vehicle-service/overview')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
lookupKey: 'LB9A32A24R0LS1426',
|
||||
resolved: true,
|
||||
vin: 'LB9A32A24R0LS1426',
|
||||
plate: '粤AGQ8398',
|
||||
phone: '',
|
||||
oem: 'G7s',
|
||||
protocols: ['JT808'],
|
||||
online: false,
|
||||
primaryProtocol: 'JT808',
|
||||
coverageStatus: 'offline',
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 0,
|
||||
lastSeen: '2026-07-03 20:10:10',
|
||||
serviceStatus: {
|
||||
status: 'offline',
|
||||
severity: 'error',
|
||||
title: '车辆离线',
|
||||
detail: '所有已知数据来源均未在线',
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 0
|
||||
}
|
||||
realtimeCount: 1,
|
||||
historyCount: 0,
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
|
||||
Reference in New Issue
Block a user