feat(platform): export dashboard snapshot

This commit is contained in:
lingniu
2026-07-04 20:30:47 +08:00
parent fc57dea551
commit e6188e2569
2 changed files with 129 additions and 0 deletions

View File

@@ -1109,6 +1109,8 @@ test('dashboard copies highest priority quality issue notification text', async
configurable: true,
value: { writeText }
});
const createObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:dashboard-snapshot');
const revokeObjectURL = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined);
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/ops/health')) {
@@ -1238,6 +1240,11 @@ test('dashboard copies highest priority quality issue notification text', async
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史RAWhttp://localhost:3000/#/history-query?keyword=%E7%B2%A4A%E5%91%8A%E8%AD%A61&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('告警事件http://localhost:3000/#/alert-events?issueType=VIN_MISSING'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆服务http://localhost:3000/#/detail?keyword=%E7%B2%A4A%E5%91%8A%E8%AD%A61&protocol=JT808'));
fireEvent.click(screen.getByRole('button', { name: '导出驾驶舱 CSV' }));
expect(createObjectURL).toHaveBeenCalled();
expect(revokeObjectURL).toHaveBeenCalledWith('blob:dashboard-snapshot');
});
test('dashboard keeps core vehicle service metrics when preview requests fail', async () => {