feat(platform): clarify missing source role

This commit is contained in:
lingniu
2026-07-04 05:24:25 +08:00
parent d51c83db2a
commit ef35137236
2 changed files with 4 additions and 1 deletions

View File

@@ -49,6 +49,9 @@ function formatSeconds(value?: number) {
function sourceServiceRole(source: VehicleSourceStatus, primaryProtocol?: string) { function sourceServiceRole(source: VehicleSourceStatus, primaryProtocol?: string) {
if (source.protocol === primaryProtocol) return { label: '主来源', color: 'blue' as const }; if (source.protocol === primaryProtocol) return { label: '主来源', color: 'blue' as const };
if (source.online) return { label: '在线证据', color: 'green' as const }; if (source.online) return { label: '在线证据', color: 'green' as const };
if (!source.lastSeen && !source.hasRealtime && !source.hasHistory && !source.hasRaw && !source.hasMileage) {
return { label: '暂无来源', color: 'grey' as const };
}
return { label: '离线证据', color: 'grey' as const }; return { label: '离线证据', color: 'grey' as const };
} }

View File

@@ -1868,7 +1868,7 @@ test('switches vehicle detail to a source from the source matrix', async () => {
expect(screen.getByText('车辆服务角色')).toBeInTheDocument(); expect(screen.getByText('车辆服务角色')).toBeInTheDocument();
expect(screen.getByText('主来源')).toBeInTheDocument(); expect(screen.getByText('主来源')).toBeInTheDocument();
expect(screen.getByText('在线证据')).toBeInTheDocument(); expect(screen.getByText('在线证据')).toBeInTheDocument();
expect(screen.getByText('离线证据')).toBeInTheDocument(); expect(screen.getByText('暂无来源')).toBeInTheDocument();
expect(screen.getAllByText('YUTONG_MQTT').length).toBeGreaterThan(0); expect(screen.getAllByText('YUTONG_MQTT').length).toBeGreaterThan(0);
expect(screen.getAllByText('无上报').length).toBeGreaterThan(0); expect(screen.getAllByText('无上报').length).toBeGreaterThan(0);
fireEvent.click(screen.getByRole('button', { name: '仅看 JT808' })); fireEvent.click(screen.getByRole('button', { name: '仅看 JT808' }));