feat(platform): customerize history export workflow

This commit is contained in:
lingniu
2026-07-05 00:39:24 +08:00
parent 74ccddb1a7
commit 9a428198b4
2 changed files with 71 additions and 71 deletions

View File

@@ -200,7 +200,7 @@ test('exposes AMap operations shortcuts when map key is configured', async () =>
fireEvent.click(screen.getByRole('button', { name: '顶部数据导出' }));
expect(window.location.hash.startsWith('#/history-query')).toBe(true);
expect(new URLSearchParams(window.location.hash.split('?')[1] ?? '').get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '顶部里程统计' }));
expect(window.location.hash.startsWith('#/mileage')).toBe(true);
fireEvent.click(await screen.findByRole('button', { name: '顶部告警事件正常' }));
@@ -4788,7 +4788,7 @@ test('opens same-day raw evidence from quality priority queue', async () => {
expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
});
test('opens vehicle service from quality issue with issue source evidence', async () => {
@@ -5145,7 +5145,7 @@ test('opens same-day raw evidence from quality issue row', async () => {
expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
});
test('copies trajectory playback summary from history page', async () => {
@@ -5258,17 +5258,17 @@ test('copies trajectory playback summary from history page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('起点2026-07-03 10:00:00'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('终点2026-07-03 11:00:00'));
fireEvent.click(screen.getAllByRole('button', { name: /复制历史证据包/ })[0]);
fireEvent.click(screen.getAllByRole('button', { name: /复制数据复核包/ })[0]);
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【历史证据包】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【数据复核包】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('位置记录2有效定位2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW帧1解析字段2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录1字段明细2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹回放http://localhost:3000/#/history?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史位置http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('解析字段http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=fields&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('字段明细http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=fields&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程复核http://localhost:3000/#/mileage?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆服务http://localhost:3000/#/detail?keyword=VIN-HISTORY-SUMMARY&protocol=JT808'));
@@ -5278,25 +5278,25 @@ test('copies trajectory playback summary from history page', async () => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据来源JT808'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('业务状态:需要复核'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹范围:位置 2 / 有效定位 2 / RAW 1 / 字段 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹范围:位置 2 / 有效定位 2 / 原始记录 1 / 字段明细 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('定位覆盖率100%'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('回放跨度60 分钟采样间隔60 分钟/点'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常影响:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('地图能力:高德 JS API 待配置'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('历史查询http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('数据导出http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=location&dateFrom=2026-07-03&dateTo=2026-07-04'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
fireEvent.click(screen.getByRole('button', { name: /复制轨迹复盘包/ }));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【轨迹复盘交接包】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('车辆VIN-HISTORY-SUMMARY'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹规模:位置 2 / 有效定位 2 / RAW 1 / 解析字段 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹规模:位置 2 / 有效定位 2 / 原始记录 1 / 字段明细 2'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('轨迹质量:定位覆盖率 100% / 回放跨度 60 分钟 / 采样间隔 60 分钟/点'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('里程速度:区间里程 22.6 km / 最高速度 58.8 km/h'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('当前回放点:点 1/22026-07-03 10:00:0012.5 km/h1,000 km'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('异常判读:断点 1 / 里程回退 0 / 超速 0'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('下一步:建议核对 RAW 帧、解析字段、当日里程统计,并确认平台是否存在断链或补发。'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('RAW证据http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('下一步:建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('原始记录http://localhost:3000/#/history-query?keyword=VIN-HISTORY-SUMMARY&protocol=JT808&tab=raw&dateFrom=2026-07-03&dateTo=2026-07-04&includeFields=true'));
});
test('opens same-day mileage statistics from quality issue row', async () => {
@@ -6185,7 +6185,7 @@ test('shows and clears current history filters while keeping vehicle scope', asy
expect(screen.getByText('数据来源JT808')).toBeInTheDocument();
expect(screen.getByText('开始时间2026-07-01 00:00:00')).toBeInTheDocument();
expect(screen.getByText('结束时间2026-07-01 23:59:59')).toBeInTheDocument();
expect(screen.getAllByText('返回解析字段').length).toBeGreaterThanOrEqual(2);
expect(screen.getAllByText('返回字段明细').length).toBeGreaterThanOrEqual(2);
expect(screen.getByText('字段裁剪2 个')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '清空筛选' }));
@@ -6259,8 +6259,8 @@ test('shows parsed field history as a flattened evidence table', async () => {
render(<App />);
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument();
expect(await screen.findByRole('tab', { name: '解析字段' })).toHaveAttribute('aria-selected', 'true');
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
expect(await screen.findByRole('tab', { name: '字段明细' })).toHaveAttribute('aria-selected', 'true');
expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', expect.objectContaining({
method: 'POST',
body: expect.stringContaining('"includeFields":true')
@@ -6357,10 +6357,10 @@ test('prevents unscoped raw parsed-field query from history form', async () => {
await waitFor(() => {
expect(keywordInput).toHaveValue('');
});
fireEvent.click(screen.getByRole('checkbox', { name: '返回解析字段' }));
fireEvent.click(screen.getByRole('checkbox', { name: '返回字段明细' }));
fireEvent.click(screen.getByRole('button', { name: 'search 查询' }));
expect((await screen.findAllByText('RAW 解析字段查询需要车辆、时间范围或字段裁剪')).length).toBeGreaterThanOrEqual(1);
expect((await screen.findAllByText('字段明细查询需要车辆、时间范围或字段裁剪')).length).toBeGreaterThanOrEqual(1);
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/history/locations?'), undefined);
expect(fetchMock).not.toHaveBeenCalledWith('/api/history/raw-frames/query', expect.anything());
});
@@ -6417,7 +6417,7 @@ test('shows trajectory playback workspace from history locations', async () => {
expect(screen.getByText('轨迹范围')).toBeInTheDocument();
expect(screen.getByText('定位覆盖')).toBeInTheDocument();
expect(screen.getByText('异常影响')).toBeInTheDocument();
expect(screen.getByText('RAW证据')).toBeInTheDocument();
expect(screen.getAllByText('原始记录').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('地图能力')).toBeInTheDocument();
expect(screen.getByText('轨迹回放作业台')).toBeInTheDocument();
expect(screen.getByText('2 个有效轨迹点')).toBeInTheDocument();
@@ -6520,7 +6520,7 @@ test('flags trajectory playback anomalies for gap mileage and speed review', asy
expect(screen.getByText('2 km')).toBeInTheDocument();
expect(screen.getByText('速度异常')).toBeInTheDocument();
expect(screen.getAllByText('132 km/h').length).toBeGreaterThan(0);
expect(screen.getByText('建议核对 RAW 帧和当日里程统计')).toBeInTheDocument();
expect(screen.getByText('建议核对原始记录和当日里程统计')).toBeInTheDocument();
});
test('opens amap route from trajectory playback workspace', async () => {
@@ -6975,7 +6975,7 @@ test('exports current raw frame page as csv with parsed fields', async () => {
render(<App />);
expect((await screen.findAllByText('raw-export-001')).length).toBeGreaterThanOrEqual(1);
fireEvent.click(screen.getByRole('button', { name: '导出 RAW 当前页 CSV' }));
fireEvent.click(screen.getByRole('button', { name: '导出原始记录当前页 CSV' }));
expect(createObjectURL).toHaveBeenCalled();
expect(revokeObjectURL).toHaveBeenCalledWith('blob:history-raw');
@@ -7469,7 +7469,7 @@ test('opens same-day raw frame evidence from mileage row', async () => {
expect(params.get('dateFrom')).toBe('2026-07-03');
expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('heading', { name: '历史查询' })).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
});
test('shows mileage anomaly action guidance', async () => {
@@ -8236,7 +8236,7 @@ test('opens same-day raw evidence from history location row', async () => {
render(<App />);
expect((await screen.findAllByText('VIN-HISTORY-RAW')).length).toBeGreaterThan(0);
fireEvent.click(screen.getByRole('button', { name: '核对 RAW' }));
fireEvent.click(screen.getByRole('button', { name: '核对原始记录' }));
await waitFor(() => {
expect(window.location.hash.startsWith('#/history-query?')).toBe(true);
@@ -8248,7 +8248,7 @@ test('opens same-day raw evidence from history location row', async () => {
expect(params.get('dateTo')).toBe('2026-07-04');
expect(params.get('includeFields')).toBe('true');
expect(params.get('tab')).toBe('raw');
expect(await screen.findByRole('tab', { name: 'RAW 帧' })).toHaveAttribute('aria-selected', 'true');
expect(await screen.findByRole('tab', { name: '原始记录' })).toHaveAttribute('aria-selected', 'true');
expect((await screen.findAllByText('raw-from-location-001')).length).toBeGreaterThanOrEqual(1);
});
@@ -8333,7 +8333,7 @@ test('opens vehicle service from raw history rows with row source evidence', asy
render(<App />);
fireEvent.click(await screen.findByRole('tab', { name: 'RAW 帧' }));
fireEvent.click(await screen.findByRole('tab', { name: '原始记录' }));
expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument();
fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);