mirror of
https://github.com/apache/superset.git
synced 2026-08-12 11:11:01 +00:00
fix(table): hide search dropdown when search box is disabled (#41772)
This commit is contained in:
@@ -195,6 +195,119 @@ test('AgGridTableChart renders with search enabled', async () => {
|
||||
expect(searchInput).toHaveAttribute('id', 'filter-text-box');
|
||||
});
|
||||
|
||||
test('AgGridTableChart hides Search by dropdown if includeSearch is false', async () => {
|
||||
const props = transformProps({
|
||||
...testData.basic,
|
||||
rawFormData: {
|
||||
...testData.basic.rawFormData,
|
||||
server_pagination: true,
|
||||
include_search: false,
|
||||
},
|
||||
});
|
||||
props.serverPagination = true;
|
||||
props.includeSearch = false;
|
||||
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart
|
||||
{...props}
|
||||
setDataMask={mockSetDataMask}
|
||||
slice_id={1}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
const grid = document.querySelector('.ag-container');
|
||||
expect(grid).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(screen.queryByText(/Search by/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('AgGridTableChart renders Search by dropdown if includeSearch is true and there are search options', async () => {
|
||||
const props = transformProps({
|
||||
...testData.basic,
|
||||
rawFormData: {
|
||||
...testData.basic.rawFormData,
|
||||
server_pagination: true,
|
||||
include_search: true,
|
||||
},
|
||||
});
|
||||
props.serverPagination = true;
|
||||
props.includeSearch = true;
|
||||
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart
|
||||
{...props}
|
||||
setDataMask={mockSetDataMask}
|
||||
slice_id={1}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
const grid = document.querySelector('.ag-container');
|
||||
expect(grid).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(screen.getByText(/Search by/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('AgGridTableChart does not render Search by dropdown if includeSearch is true but searchOptions is empty', async () => {
|
||||
const noStringColumnsData = {
|
||||
...testData.basic,
|
||||
queriesData: [
|
||||
{
|
||||
...testData.basic.queriesData[0],
|
||||
colnames: ['__timestamp', 'sum__num'],
|
||||
coltypes: [GenericDataType.Temporal, GenericDataType.Numeric],
|
||||
data: [
|
||||
{
|
||||
__timestamp: '2020-01-01T12:34:56',
|
||||
sum__num: 2467063,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const props = transformProps({
|
||||
...noStringColumnsData,
|
||||
rawFormData: {
|
||||
...noStringColumnsData.rawFormData,
|
||||
server_pagination: true,
|
||||
include_search: true,
|
||||
},
|
||||
});
|
||||
props.serverPagination = true;
|
||||
props.includeSearch = true;
|
||||
|
||||
render(
|
||||
ProviderWrapper({
|
||||
children: (
|
||||
<AgGridTableChart
|
||||
{...props}
|
||||
setDataMask={mockSetDataMask}
|
||||
slice_id={1}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
const grid = document.querySelector('.ag-container');
|
||||
expect(grid).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(screen.queryByText(/Search by/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('AgGridTableChart renders with totals', async () => {
|
||||
const props = transformProps({
|
||||
...testData.basic,
|
||||
|
||||
Reference in New Issue
Block a user