Compare commits

...

1 Commits

Author SHA1 Message Date
aks07
886e1dde9d feat(traces): show columns scope in traces list export 2026-10-21 11:35:39 +05:30
2 changed files with 18 additions and 35 deletions

View File

@@ -3,6 +3,7 @@ import { Provider } from 'react-redux';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { message } from 'antd';
import configureStore from 'redux-mock-store';
import { PANEL_TYPES } from 'constants/queryBuilder';
import store from 'store';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
import { EQueryType } from 'types/common/dashboard';
@@ -78,11 +79,14 @@ const createMockStagedQuery = (dataSource: DataSource): Query => ({
clickhouse_sql: [],
});
const renderWithStore = (dataSource: DataSource): void => {
const renderWithStore = (
dataSource: DataSource,
panelType?: PANEL_TYPES,
): void => {
const mockReduxStore = createMockReduxStore();
render(
<Provider store={mockReduxStore}>
<DownloadOptionsMenu dataSource={dataSource} />
<DownloadOptionsMenu dataSource={dataSource} panelType={panelType} />
</Provider>,
);
};
@@ -117,11 +121,14 @@ describe.each([
expect(screen.getByText('FORMAT')).toBeInTheDocument();
expect(screen.getByText('Number of Rows')).toBeInTheDocument();
if (dataSource === DataSource.TRACES) {
expect(screen.queryByText('Columns')).not.toBeInTheDocument();
} else {
expect(screen.getByText('Columns')).toBeInTheDocument();
}
expect(screen.getByText('Columns')).toBeInTheDocument();
});
it('hides columns scope in the trace view', () => {
renderWithStore(dataSource, PANEL_TYPES.TRACE);
fireEvent.click(screen.getByTestId(testId));
expect(screen.queryByText('Columns')).not.toBeInTheDocument();
});
it('allows changing export format', () => {
@@ -151,17 +158,6 @@ describe.each([
});
it('allows changing columns scope', () => {
if (dataSource === DataSource.TRACES) {
renderWithStore(dataSource);
fireEvent.click(screen.getByTestId(testId));
expect(screen.queryByRole('radio', { name: 'All' })).not.toBeInTheDocument();
expect(
screen.queryByRole('radio', { name: 'Selected' }),
).not.toBeInTheDocument();
return;
}
renderWithStore(dataSource);
fireEvent.click(screen.getByTestId(testId));
@@ -228,12 +224,7 @@ describe.each([
mockUseQueryBuilder.mockReturnValue({ stagedQuery: mockQuery });
renderWithStore(dataSource);
fireEvent.click(screen.getByTestId(testId));
// For traces, column scope is always Selected and the radio is hidden
if (dataSource !== DataSource.TRACES) {
fireEvent.click(screen.getByRole('radio', { name: 'Selected' }));
}
fireEvent.click(screen.getByRole('radio', { name: 'Selected' }));
fireEvent.click(screen.getByText('Export'));
await waitFor(() => {
@@ -250,11 +241,6 @@ describe.each([
});
it('sends no selectFields when column scope is All', async () => {
// For traces, column scope is always Selected — this test only applies to other sources
if (dataSource === DataSource.TRACES) {
return;
}
renderWithStore(dataSource);
fireEvent.click(screen.getByTestId(testId));
fireEvent.click(screen.getByRole('radio', { name: 'All' }));

View File

@@ -45,9 +45,7 @@ export default function DownloadOptionsMenu({
await handleExportRawData({
format: exportFormat,
rowLimit,
clearSelectColumns:
dataSource !== DataSource.TRACES &&
columnsScope === DownloadColumnsScopes.ALL,
clearSelectColumns: columnsScope === DownloadColumnsScopes.ALL,
selectedColumns,
});
}, [
@@ -56,7 +54,6 @@ export default function DownloadOptionsMenu({
columnsScope,
selectedColumns,
handleExportRawData,
dataSource,
]);
const popoverContent = useMemo(
@@ -96,7 +93,7 @@ export default function DownloadOptionsMenu({
/>
</div>
{dataSource !== DataSource.TRACES && (
{panelType !== PANEL_TYPES.TRACE && (
<>
<div className="horizontal-line" />
@@ -134,7 +131,7 @@ export default function DownloadOptionsMenu({
columnsScope,
isDownloading,
handleExport,
dataSource,
panelType,
],
);