feat(platform): refine history query customer workflow

This commit is contained in:
lingniu
2026-07-05 12:26:46 +08:00
parent a7e10f0983
commit 993b1adb00
2 changed files with 144 additions and 143 deletions

View File

@@ -208,8 +208,8 @@ 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(screen.getByText('默认查询最近一天,不预置任何车辆;输入 VIN、车牌或手机号后进入单车证据交付。')).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '历史查询导出' })).toBeInTheDocument();
expect(screen.getByText('默认查询最近一天,不预置任何车辆;输入 VIN、车牌或手机号后进入单车查询导出。')).toBeInTheDocument();
expect(screen.queryByDisplayValue('LB9A32A24R0LS1426')).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '顶部里程统计' }));
expect(window.location.hash.startsWith('#/mileage')).toBe(true);
@@ -4962,7 +4962,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 () => {
@@ -5319,7 +5319,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 () => {
@@ -5421,17 +5421,17 @@ test('copies trajectory playback summary from history page', async () => {
expect((await screen.findAllByText('VIN-HISTORY-SUMMARY')).length).toBeGreaterThan(0);
expect(screen.getByText('客户轨迹决策台')).toBeInTheDocument();
expect(screen.getByText('先判断轨迹能否复盘,再进入原始、字段和里程证据')).toBeInTheDocument();
expect(screen.getByText('先判断轨迹能否复盘,再进入明细、字段和里程复核')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 复盘结论 复制决策' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 定位覆盖 播放轨迹' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 时间断点 复盘包' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 里程速度 里程复核' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 证据交付 原始证据' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 明细复核 历史明细' })).toBeInTheDocument();
fireEvent.click(screen.getAllByRole('button', { name: /复制决策说明/ })[0]);
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【客户轨迹决策说明】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('决策结论:可复盘,需附异常说明'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('客户复盘路径:'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('4. 最后回到据:异常点必须打开原始记录、字段明细和里程统计复核。'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('4. 最后回到据:异常点必须打开历史明细、字段明细和里程统计复核。'));
fireEvent.click(screen.getByRole('button', { name: /复制轨迹摘要/ }));
@@ -5450,11 +5450,11 @@ test('copies trajectory playback summary from history page', async () => {
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('原始记录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('原始记录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=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'));
@@ -5465,25 +5465,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 / 原始记录 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('原始记录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 / 原始记录 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('下一步:建议核对原始记录、字段明细、当日里程统计,并确认平台是否存在断链或补发。'));
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('下一步:建议核对历史明细、字段明细、当日里程统计,并确认平台是否存在断链或补发。'));
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 () => {
@@ -6325,7 +6325,7 @@ test('applies protocol from shareable history hash to API requests', async () =>
body: expect.stringContaining('"protocol":"JT808"')
}));
expect(screen.getByText('当前车辆粤AG18312')).toBeInTheDocument();
expect(screen.getByText('当前来源JT808')).toBeInTheDocument();
expect(screen.getAllByText('数据通道JT808').length).toBeGreaterThan(0);
});
test('shows and clears current history filters while keeping vehicle scope', async () => {
@@ -6458,32 +6458,32 @@ test('shows parsed field history as a flattened evidence table', async () => {
render(<App />);
expect(await screen.findByRole('heading', { name: '数据导出' })).toBeInTheDocument();
expect(screen.getByText('客户数据导出')).toBeInTheDocument();
expect(await screen.findByRole('heading', { name: '历史查询导出' })).toBeInTheDocument();
expect(screen.getByText('客户历史查询导出')).toBeInTheDocument();
expect(screen.getByText('先锁定车辆和时间窗,再选择交付物并导出')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据导出 选择范围 调整筛选' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据导出 位置历史 导出位置' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据导出 原始证据 导出原始' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据导出 字段明细 字段明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据导出 交付说明 复制交付' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户历史查询导出 选择范围 调整筛选' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户历史查询导出 位置历史 导出位置' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户历史查询导出 历史明细 导出明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户历史查询导出 字段明细 字段明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户历史查询导出 交付说明 复制交付' })).toBeInTheDocument();
expect(screen.getByText('客户轨迹决策台')).toBeInTheDocument();
expect(screen.getAllByRole('button', { name: /复制决策说明/ }).length).toBeGreaterThanOrEqual(1);
expect(screen.getByRole('button', { name: '客户轨迹决策 证据交付 原始证据' })).toBeInTheDocument();
expect(screen.getByText('客户数据交付包')).toBeInTheDocument();
expect(screen.getByText('面向客户交付时,先确认车辆、时间、交付物和质量提示,再导出位置、原始记录或字段明细,避免把内部排查过程直接暴露给客户。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据交付 原始证据 导出原始' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据交付 字段明细 字段明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户数据交付 质量提示 复制说明' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户轨迹决策 明细复核 历史明细' })).toBeInTheDocument();
expect(screen.getByText('客户查询导出包')).toBeInTheDocument();
expect(screen.getByText('面向客户交付时,先确认车辆、时间、交付物和质量提示,再导出位置、历史明细或字段明细,避免把内部排查过程直接暴露给客户。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户查询导出 历史明细 导出明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户查询导出 字段明细 字段明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户查询导出 质量提示 复制说明' })).toBeInTheDocument();
expect(screen.getByText('客户交付物清单')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 位置历史 导出位置' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 轨迹回放 查看轨迹' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 里程复核 里程复核' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 原始证据 导出原始' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 历史明细 导出明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 字段明细 字段明细' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '客户交付清单 质量提示 复制清单' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /复制交付清单/ }));
await waitFor(() => {
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('交付物:位置历史 / 轨迹回放 / 里程复核 / 原始证据 / 字段明细 / 质量提示'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('交付物:位置历史 / 轨迹回放 / 里程复核 / 历史明细 / 字段明细 / 质量提示'));
});
expect(await screen.findByRole('tab', { name: '字段明细' })).toHaveAttribute('aria-selected', 'true');
expect(fetchMock).toHaveBeenCalledWith('/api/history/raw-frames/query', expect.objectContaining({
@@ -6525,7 +6525,7 @@ test('updates history hash when vehicle history filters are submitted', async ()
await screen.findByRole('heading', { name: '轨迹回放' });
fireEvent.change(screen.getByPlaceholderText('VIN / 车牌 / 手机号'), { target: { value: '粤AG18312' } });
fireEvent.click(screen.getAllByText('全部来源')[0]);
fireEvent.click(screen.getAllByText('全部数据通道')[0]);
fireEvent.click(await screen.findByText('JT808'));
fireEvent.change(screen.getByPlaceholderText('2026-07-03 00:00:00'), { target: { value: '2026-07-01 00:00:00' } });
fireEvent.change(screen.getByPlaceholderText('2026-07-03 23:59:59'), { target: { value: '2026-07-01 23:59:59' } });
@@ -6638,17 +6638,17 @@ test('shows trajectory playback workspace from history locations', async () => {
render(<App />);
expect(await screen.findByRole('heading', { name: '轨迹回放' })).toBeInTheDocument();
expect(screen.getByText('历史数据交付任务板')).toBeInTheDocument();
expect(screen.getByText('历史查询导出任务板')).toBeInTheDocument();
expect(screen.getByText('2 个有效点')).toBeInTheDocument();
expect(screen.getByText('围绕当前车辆生成可播放轨迹,用于定位复盘和客户问询。')).toBeInTheDocument();
expect(screen.getByText('位置导出')).toBeInTheDocument();
expect(screen.getByText('原始证据')).toBeInTheDocument();
expect(screen.getAllByText('历史明细').length).toBeGreaterThan(0);
expect(screen.getAllByText('字段裁剪').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('轨迹运营影响')).toBeInTheDocument();
expect(screen.getByText('轨迹范围')).toBeInTheDocument();
expect(screen.getByText('定位覆盖')).toBeInTheDocument();
expect(screen.getAllByText('定位覆盖').length).toBeGreaterThan(0);
expect(screen.getByText('异常影响')).toBeInTheDocument();
expect(screen.getAllByText('原始记录').length).toBeGreaterThanOrEqual(1);
expect(screen.getAllByText('历史明细').length).toBeGreaterThanOrEqual(1);
expect(screen.getByText('地图能力')).toBeInTheDocument();
expect(screen.getByText('轨迹回放作业台')).toBeInTheDocument();
expect(screen.getByText('2 个有效轨迹点')).toBeInTheDocument();
@@ -6697,7 +6697,7 @@ test('shows trajectory evidence quality on history playback workspace', async ()
render(<App />);
expect(await screen.findByText('轨迹证据质量')).toBeInTheDocument();
expect(await screen.findByText('轨迹复盘质量')).toBeInTheDocument();
expect(screen.getByText('定位覆盖率')).toBeInTheDocument();
expect(screen.getAllByText('100%').length).toBeGreaterThan(0);
expect(screen.getByText('回放跨度')).toBeInTheDocument();
@@ -6751,7 +6751,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('建议核对原始记录和当日里程统计')).toBeInTheDocument();
expect(screen.getByText('建议核对历史明细和当日里程统计')).toBeInTheDocument();
});
test('opens amap route from trajectory playback workspace', async () => {
@@ -7062,7 +7062,8 @@ test('auto plays trajectory playback points with selectable speed', async () =>
expect(await screen.findByText('播放速度')).toBeInTheDocument();
vi.useFakeTimers();
expect(screen.getByText('点 1 / 3')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '播放轨迹' }));
const playTrajectoryButtons = screen.getAllByRole('button', { name: '播放轨迹' });
fireEvent.click(playTrajectoryButtons[playTrajectoryButtons.length - 1]);
expect(screen.getByRole('button', { name: '暂停轨迹' })).toBeInTheDocument();
await vi.advanceTimersByTimeAsync(1200);
@@ -7070,7 +7071,7 @@ test('auto plays trajectory playback points with selectable speed', async () =>
await vi.advanceTimersByTimeAsync(2400);
expect(screen.getByText('点 3 / 3')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '播放轨迹' })).toBeInTheDocument();
expect(screen.getAllByRole('button', { name: '播放轨迹' }).length).toBeGreaterThan(0);
vi.useRealTimers();
});
@@ -7206,7 +7207,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: '导出原始记录当前页 CSV' }));
fireEvent.click(screen.getByRole('button', { name: '导出历史明细当前页 CSV' }));
expect(createObjectURL).toHaveBeenCalled();
expect(revokeObjectURL).toHaveBeenCalledWith('blob:history-raw');
@@ -7700,7 +7701,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 () => {
@@ -8508,7 +8509,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: '核对原始记录' }));
fireEvent.click(screen.getByRole('button', { name: '核对历史明细' }));
await waitFor(() => {
expect(window.location.hash.startsWith('#/history-query?')).toBe(true);
@@ -8520,7 +8521,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: '原始记录' })).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);
});
@@ -8605,7 +8606,7 @@ test('opens vehicle service from raw history rows with row source evidence', asy
render(<App />);
fireEvent.click(await screen.findByRole('tab', { name: '原始记录' }));
fireEvent.click(await screen.findByRole('tab', { name: '历史明细' }));
expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument();
fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);