fix(history): activate column visibility settings
This commit is contained in:
@@ -22,6 +22,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
const metric = { key: 'speedKmh', label: '速度', unit: 'km/h', category: 'location', valueType: 'number', defaultVisible: true };
|
||||
const optionalMetric = { key: 'socPercent', label: 'SOC', unit: '%', category: 'location', valueType: 'number', defaultVisible: false };
|
||||
|
||||
function historyData(vin: string, plate: string, asOf: string): HistoryDataResponse {
|
||||
return {
|
||||
@@ -91,3 +92,32 @@ test('releases export job state immediately after leaving the history page', asy
|
||||
unmount();
|
||||
await waitFor(() => expect(client.getQueryCache().find({ queryKey: ['history-exports'] })).toBeUndefined());
|
||||
});
|
||||
|
||||
test('opens a working column visibility panel and preserves non-hideable identity columns', async () => {
|
||||
const data = historyData('OLDVIN', '旧车牌', 'old-as-of');
|
||||
data.columns = [metric, optionalMetric];
|
||||
data.rows[0].values.socPercent = 88;
|
||||
mocks.historyMetricCatalog.mockResolvedValue({ categories: [{ key: 'location', label: '位置数据' }], metrics: [metric, optionalMetric] });
|
||||
mocks.historyData.mockResolvedValue(data);
|
||||
mocks.historySeries.mockResolvedValue(historySeries('OLDVIN', '旧车牌', 'old-as-of'));
|
||||
mocks.historyExports.mockResolvedValue([]);
|
||||
renderPage();
|
||||
|
||||
expect(await screen.findByRole('columnheader', { name: '速度 (km/h)' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('columnheader', { name: 'SOC (%)' })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '列设置' }));
|
||||
|
||||
expect(screen.getByRole('dialog', { name: '列显示设置' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('checkbox', { name: /速度/ }));
|
||||
expect(screen.queryByRole('columnheader', { name: '速度 (km/h)' })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('columnheader', { name: 'VIN' })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: '显示全部' }));
|
||||
expect(screen.getByRole('columnheader', { name: '速度 (km/h)' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('columnheader', { name: 'SOC (%)' })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '恢复默认' }));
|
||||
expect(screen.getByRole('columnheader', { name: '速度 (km/h)' })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('columnheader', { name: 'SOC (%)' })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '关闭列显示设置' }));
|
||||
expect(screen.queryByRole('dialog', { name: '列显示设置' })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user