mirror of
https://github.com/apache/superset.git
synced 2026-04-26 19:44:58 +00:00
refactor(sqllab): Remove tableOptions from redux state (#23488)
This commit is contained in:
@@ -21,7 +21,6 @@ import React from 'react';
|
||||
import { render, screen, waitFor, within } from 'spec/helpers/testing-library';
|
||||
import { queryClient } from 'src/views/QueryProvider';
|
||||
import fetchMock from 'fetch-mock';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import TableSelector, { TableSelectorMultiple } from '.';
|
||||
|
||||
@@ -36,11 +35,6 @@ const createProps = (props = {}) => ({
|
||||
...props,
|
||||
});
|
||||
|
||||
const getSchemaMockFunction = () =>
|
||||
({
|
||||
result: ['schema_a', 'schema_b'],
|
||||
} as any);
|
||||
|
||||
const getTableMockFunction = () =>
|
||||
({
|
||||
count: 4,
|
||||
@@ -124,47 +118,6 @@ test('renders disabled without schema', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('table options are notified after schema selection', async () => {
|
||||
fetchMock.get(schemaApiRoute, getSchemaMockFunction());
|
||||
|
||||
const callback = jest.fn();
|
||||
const props = createProps({
|
||||
onTablesLoad: callback,
|
||||
schema: undefined,
|
||||
});
|
||||
render(<TableSelector {...props} />, { useRedux: true });
|
||||
|
||||
const schemaSelect = screen.getByRole('combobox', {
|
||||
name: 'Select schema or type to search schemas',
|
||||
});
|
||||
expect(schemaSelect).toBeInTheDocument();
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
|
||||
userEvent.click(schemaSelect);
|
||||
|
||||
expect(
|
||||
await screen.findByRole('option', { name: 'schema_a' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
await screen.findByRole('option', { name: 'schema_b' }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
fetchMock.get(tablesApiRoute, getTableMockFunction());
|
||||
|
||||
act(() => {
|
||||
userEvent.click(screen.getAllByText('schema_a')[1]);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(callback).toHaveBeenCalledWith([
|
||||
{ label: 'table_a', value: 'table_a' },
|
||||
{ label: 'table_b', value: 'table_b' },
|
||||
{ label: 'table_c', value: 'table_c' },
|
||||
{ label: 'table_d', value: 'table_d' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
test('table select retain value if not in SQL Lab mode', async () => {
|
||||
fetchMock.get(schemaApiRoute, { result: ['test_schema'] });
|
||||
fetchMock.get(tablesApiRoute, getTableMockFunction());
|
||||
|
||||
Reference in New Issue
Block a user