Skip to content

Commit

Permalink
Revert "chore: Changes the DatabaseSelector to use the new Select com…
Browse files Browse the repository at this point in the history
…ponent (apache#16334)" (apache#16478)

This reverts commit c768941.
  • Loading branch information
Erik Ritter authored Aug 27, 2021
1 parent acc903c commit 616e72d
Show file tree
Hide file tree
Showing 16 changed files with 831 additions and 692 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,9 @@ describe('Left Panel Expansion', () => {
</Provider>
</ThemeProvider>,
);
const dbSelect = screen.getByRole('combobox', {
name: 'Select a database',
});
const schemaSelect = screen.getByRole('combobox', {
name: 'Select a schema',
});
const dropdown = screen.getByText(/Select a table/i);
const dbSelect = screen.getByText(/select a database/i);
const schemaSelect = screen.getByText(/select a schema \(0\)/i);
const dropdown = screen.getByText(/Select table/i);
const abUser = screen.getByText(/ab_user/i);
expect(dbSelect).toBeInTheDocument();
expect(schemaSelect).toBeInTheDocument();
Expand Down
9 changes: 5 additions & 4 deletions superset-frontend/src/components/CertifiedIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
*/
import React from 'react';
import { t, supersetTheme } from '@superset-ui/core';
import Icons, { IconType } from 'src/components/Icons';
import Icons from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';

export interface CertifiedIconProps {
certifiedBy?: string;
details?: string;
size?: IconType['iconSize'];
size?: number;
}

function CertifiedIcon({
certifiedBy,
details,
size = 'l',
size = 24,
}: CertifiedIconProps) {
return (
<Tooltip
Expand All @@ -48,7 +48,8 @@ function CertifiedIcon({
>
<Icons.Certified
iconColor={supersetTheme.colors.primary.base}
iconSize={size}
height={size}
width={size}
/>
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import DatabaseSelector from '.';
const SupersetClientGet = jest.spyOn(SupersetClient, 'get');

const createProps = () => ({
db: { id: 1, database_name: 'test', backend: 'postgresql' },
dbId: 1,
formMode: false,
isDatabaseSelectEnabled: true,
readOnly: false,
schema: undefined,
schema: 'public',
sqlLabMode: true,
getDbList: jest.fn(),
getTableList: jest.fn(),
Expand Down Expand Up @@ -129,7 +129,7 @@ beforeEach(() => {
changed_on: '2021-03-09T19:02:07.141095',
changed_on_delta_humanized: 'a day ago',
created_by: null,
database_name: 'test',
database_name: 'examples',
explore_database_id: 1,
expose_in_sqllab: true,
force_ctas_schema: null,
Expand All @@ -153,62 +153,50 @@ test('Refresh should work', async () => {

render(<DatabaseSelector {...props} />);

const select = screen.getByRole('combobox', {
name: 'Select a schema',
});

userEvent.click(select);

await waitFor(() => {
expect(SupersetClientGet).toBeCalledTimes(1);
expect(props.getDbList).toBeCalledTimes(0);
expect(SupersetClientGet).toBeCalledTimes(2);
expect(props.getDbList).toBeCalledTimes(1);
expect(props.getTableList).toBeCalledTimes(0);
expect(props.handleError).toBeCalledTimes(0);
expect(props.onDbChange).toBeCalledTimes(0);
expect(props.onSchemaChange).toBeCalledTimes(0);
expect(props.onSchemasLoad).toBeCalledTimes(0);
expect(props.onSchemasLoad).toBeCalledTimes(1);
expect(props.onUpdate).toBeCalledTimes(0);
});

userEvent.click(screen.getByRole('button', { name: 'refresh' }));
userEvent.click(screen.getByRole('button'));

await waitFor(() => {
expect(SupersetClientGet).toBeCalledTimes(2);
expect(props.getDbList).toBeCalledTimes(0);
expect(SupersetClientGet).toBeCalledTimes(3);
expect(props.getDbList).toBeCalledTimes(1);
expect(props.getTableList).toBeCalledTimes(0);
expect(props.handleError).toBeCalledTimes(0);
expect(props.onDbChange).toBeCalledTimes(0);
expect(props.onSchemaChange).toBeCalledTimes(0);
expect(props.onDbChange).toBeCalledTimes(1);
expect(props.onSchemaChange).toBeCalledTimes(1);
expect(props.onSchemasLoad).toBeCalledTimes(2);
expect(props.onUpdate).toBeCalledTimes(0);
expect(props.onUpdate).toBeCalledTimes(1);
});
});

test('Should database select display options', async () => {
const props = createProps();
render(<DatabaseSelector {...props} />);
const select = screen.getByRole('combobox', {
name: 'Select a database',
});
expect(select).toBeInTheDocument();
userEvent.click(select);
expect(
await screen.findByRole('option', { name: 'postgresql: test' }),
).toBeInTheDocument();
const selector = await screen.findByText('Database:');
expect(selector).toBeInTheDocument();
expect(selector.parentElement).toHaveTextContent(
'Database:postgresql examples',
);
});

test('Should schema select display options', async () => {
const props = createProps();
render(<DatabaseSelector {...props} />);
const select = screen.getByRole('combobox', {
name: 'Select a schema',
});
expect(select).toBeInTheDocument();
userEvent.click(select);
expect(
await screen.findByRole('option', { name: 'public' }),
).toBeInTheDocument();
expect(
await screen.findByRole('option', { name: 'information_schema' }),
).toBeInTheDocument();

const selector = await screen.findByText('Schema:');
expect(selector).toBeInTheDocument();
expect(selector.parentElement).toHaveTextContent('Schema: public');

userEvent.click(screen.getByRole('button'));

expect(await screen.findByText('Select a schema (2)')).toBeInTheDocument();
});
Loading

0 comments on commit 616e72d

Please sign in to comment.