feat(platform): filter vehicles from missing source tags

This commit is contained in:
lingniu
2026-07-04 06:08:58 +08:00
parent 111154ed39
commit 1c210897bb
2 changed files with 17 additions and 2 deletions

View File

@@ -131,7 +131,17 @@ export function Vehicles({
render: (_: unknown, row: VehicleCoverageRow) => (
<Space spacing={4} wrap>
{(row.missingProtocols ?? []).length > 0
? row.missingProtocols.map((protocol) => <Tag key={protocol} color="orange"> {protocol}</Tag>)
? row.missingProtocols.map((protocol) => (
<Button
key={protocol}
size="small"
theme="light"
type="warning"
onClick={() => applyFilters({ ...filters, missingProtocol: protocol })}
>
{protocol}
</Button>
))
: <Tag color="green"></Tag>}
</Space>
)
@@ -142,7 +152,7 @@ export function Vehicles({
{ title: '绑定', width: 90, render: (_: unknown, row: VehicleCoverageRow) => <Tag color={row.bindingStatus === 'bound' ? 'green' : 'orange'}>{row.bindingStatus === 'bound' ? '已绑定' : '未绑定'}</Tag> },
{ title: '操作', width: 110, render: (_: unknown, row: VehicleCoverageRow) => <Button onClick={() => onOpenVehicle(row.vin)}></Button> }
],
[onOpenVehicle]
[filters, onOpenVehicle]
);
return (

View File

@@ -477,6 +477,11 @@ test('filters vehicle list by missing source evidence', async () => {
expect(screen.getAllByText('缺失来源').length).toBeGreaterThanOrEqual(2);
});
expect(screen.getAllByText('缺 YUTONG_MQTT').length).toBeGreaterThanOrEqual(1);
fireEvent.click(screen.getByRole('button', { name: '缺 YUTONG_MQTT' }));
expect(window.location.hash).toBe('#/vehicles?missingProtocol=YUTONG_MQTT');
await waitFor(() => {
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('missingProtocol=YUTONG_MQTT'), undefined);
});
fireEvent.click(screen.getByTestId('missing-protocol-filter'));
const mqttOptions = await screen.findAllByText('缺 YUTONG_MQTT');
fireEvent.click(mqttOptions[mqttOptions.length - 1]);