Skip to content

Commit

Permalink
chore(ci): fix numpy type errors and revert #22610 (#22782)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored Jan 19, 2023
1 parent 39c96d0 commit 577ac81
Show file tree
Hide file tree
Showing 29 changed files with 372 additions and 195 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
[metadata]
name = Superset
summary = a data exploration platform
description-file = README.md
description_file = README.md
author = Apache Superset Dev
author-email = dev@superset.apache.org
author_email = dev@superset.apache.org
license = Apache License, Version 2.0

[files]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,27 @@ test('should render a create dataset infobox', async () => {
expect(infoboxText).toBeVisible();
});

test('should render a save dataset modal when "Create a dataset" is clicked', async () => {
const newProps = {
...props,
datasource: {
...datasource,
type: DatasourceType.Query,
},
};
render(<DatasourcePanel {...newProps} />, { useRedux: true, useDnd: true });

const createButton = await screen.findByRole('button', {
name: /create a dataset/i,
});

userEvent.click(createButton);

const saveDatasetModalTitle = screen.getByText(/save or overwrite dataset/i);

expect(saveDatasetModalTitle).toBeVisible();
});

test('should not render a save dataset modal when datasource is not query or dataset', async () => {
const newProps = {
...props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ const ColumnSelectPopover = ({
}, []);

const setDatasetAndClose = () => {
if (setDatasetModal) {
setDatasetModal(true);
}
if (setDatasetModal) setDatasetModal(true);
onClose();
};

Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/pages/ChartCreation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ export class ChartCreation extends React.PureComponent<
const isButtonDisabled = this.isBtnDisabled();
const datasetHelpText = this.state.canCreateDataset ? (
<span data-test="dataset-write">
<Link to="/dataset/add/" data-test="add-chart-new-dataset">
<Link
to="/tablemodelview/list/#create"
data-test="add-chart-new-dataset"
>
{t('Add a dataset')}
</Link>
{` ${t('or')} `}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React, { useState, useMemo, useEffect } from 'react';
import rison from 'rison';
import { useSelector } from 'react-redux';
import { useQueryParams, BooleanParam } from 'use-query-params';
import { LocalStorageKeys, setItem } from 'src/utils/localStorageHelpers';

import Loading from 'src/components/Loading';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
Expand Down Expand Up @@ -158,9 +157,6 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
refreshData();
addSuccessToast(t('Deleted: %s', dbName));

// Delete user-selected db from local storage
setItem(LocalStorageKeys.db, null);

// Close delete modal
setDatabaseCurrentlyDeleting(null);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ jest.mock('@superset-ui/core', () => ({
isFeatureEnabled: () => true,
}));

const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

const dbProps = {
show: true,
database_name: 'my database',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import React, {
useReducer,
Reducer,
} from 'react';
import { useHistory } from 'react-router-dom';
import { setItem, LocalStorageKeys } from 'src/utils/localStorageHelpers';
import { UploadChangeParam, UploadFile } from 'antd/lib/upload/interface';
import Tabs from 'src/components/Tabs';
Expand Down Expand Up @@ -519,7 +518,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
t('database'),
addDangerToast,
);
const history = useHistory();

const [tabKey, setTabKey] = useState<string>(DEFAULT_TAB_KEY);
const [availableDbs, getAvailableDbs] = useAvailableDatabases();
Expand Down Expand Up @@ -1297,7 +1295,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onClick={() => {
setLoading(true);
fetchAndSetDB();
history.push('/dataset/add/');
window.location.href = '/tablemodelview/list#create';
}}
>
{t('CREATE DATASET')}
Expand All @@ -1308,7 +1306,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onClick={() => {
setLoading(true);
fetchAndSetDB();
history.push(`/superset/sqllab/?db=true`);
window.location.href = `/superset/sqllab/?db=true`;
}}
>
{t('QUERY DATA IN SQL LAB')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import AddDataset from 'src/views/CRUD/data/dataset/AddDataset';

const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

describe('AddDataset', () => {
it('renders a blank state AddDataset', async () => {
render(<AddDataset />, { useRedux: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const exampleDataset: DatasetObject[] = [
id: 1,
database_name: 'test_database',
owners: [1],
backend: 'test_backend',
},
schema: 'test_schema',
dataset_name: 'example_dataset',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/
import React, { useEffect, useState, useRef } from 'react';
import { SupersetClient, logging, t } from '@superset-ui/core';
import { SupersetClient } from '@superset-ui/core';
import { DatasetObject } from 'src/views/CRUD/data/dataset/AddDataset/types';
import { addDangerToast } from 'src/components/MessageToasts/actions';
import DatasetPanel from './DatasetPanel';
import { ITableColumn, IDatabaseTable, isIDatabaseTable } from './types';

Expand Down Expand Up @@ -95,17 +94,9 @@ const DatasetPanelWrapper = ({
setColumnList([]);
setHasColumns?.(false);
setHasError(true);
addDangerToast(
t(
'The API response from %s does not match the IDatabaseTable interface.',
path,
),
);
logging.error(
t(
'The API response from %s does not match the IDatabaseTable interface.',
path,
),
// eslint-disable-next-line no-console
console.error(
`The API response from ${path} does not match the IDatabaseTable interface.`,
);
}
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import Footer from 'src/views/CRUD/data/dataset/AddDataset/Footer';

const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useHistory: () => ({
push: mockHistoryPush,
}),
}));

const mockedProps = {
url: 'realwebsite.com',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
import React from 'react';
import { useHistory } from 'react-router-dom';
import Button from 'src/components/Button';
import { t } from '@superset-ui/core';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
Expand Down Expand Up @@ -50,12 +49,12 @@ const LOG_ACTIONS = [
];

function Footer({
url,
datasetObject,
addDangerToast,
hasColumns = false,
datasets,
}: FooterProps) {
const history = useHistory();
const { createResource } = useSingleViewResource<Partial<DatasetObject>>(
'dataset',
t('dataset'),
Expand All @@ -73,6 +72,11 @@ function Footer({

return LOG_ACTIONS[value];
};
const goToPreviousUrl = () => {
// this is a placeholder url until the final feature gets implemented
// at that point we will be passing in the url of the previous location.
window.location.href = url;
};

const cancelButtonOnClick = () => {
if (!datasetObject) {
Expand All @@ -81,7 +85,7 @@ function Footer({
const logAction = createLogAction(datasetObject);
logEvent(logAction, datasetObject);
}
history.goBack();
goToPreviousUrl();
};

const tooltipText = t('Select a database table.');
Expand All @@ -100,13 +104,13 @@ function Footer({
if (typeof response === 'number') {
logEvent(LOG_ACTIONS_DATASET_CREATION_SUCCESS, datasetObject);
// When a dataset is created the response we get is its ID number
history.push(`/chart/add/?dataset=${datasetObject.table_name}`);
goToPreviousUrl();
}
});
}
};

const CREATE_DATASET_TEXT = t('Create Dataset and Create Chart');
const CREATE_DATASET_TEXT = t('Create Dataset');
const disabledCheck =
!datasetObject?.table_name ||
!hasColumns ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import fetchMock from 'fetch-mock';
import userEvent from '@testing-library/user-event';
import { render, screen, waitFor } from 'spec/helpers/testing-library';
import LeftPanel from 'src/views/CRUD/data/dataset/AddDataset/LeftPanel';
import { exampleDataset } from 'src/views/CRUD/data/dataset/AddDataset/DatasetPanel/fixtures';

const databasesEndpoint = 'glob:*/api/v1/database/?q*';
const schemasEndpoint = 'glob:*/api/v1/database/*/schemas*';
Expand Down Expand Up @@ -182,29 +181,31 @@ test('does not render blank state if there is nothing selected', async () => {
});

test('renders list of options when user clicks on schema', async () => {
render(<LeftPanel setDataset={mockFun} dataset={exampleDataset[0]} />, {
render(<LeftPanel setDataset={mockFun} schema="schema_a" dbId={1} />, {
useRedux: true,
});

// Click 'test-postgres' database to access schemas
const databaseSelect = screen.getByRole('combobox', {
name: 'Select database or type database name',
});
// Schema select should be disabled until database is selected
const schemaSelect = screen.getByRole('combobox', {
name: /select schema or type schema name/i,
});
userEvent.click(databaseSelect);
expect(await screen.findByText('test-postgres')).toBeInTheDocument();
expect(schemaSelect).toBeDisabled();
userEvent.click(screen.getByText('test-postgres'));

// Schema select will be automatically populated if there is only one schema
const schemaSelect = screen.getByRole('combobox', {
name: /select schema or type schema name/i,
});
// Wait for schema field to be enabled
await waitFor(() => {
expect(schemaSelect).toBeEnabled();
});
});

test('searches for a table name', async () => {
render(<LeftPanel setDataset={mockFun} dataset={exampleDataset[0]} />, {
render(<LeftPanel setDataset={mockFun} schema="schema_a" dbId={1} />, {
useRedux: true,
});

Expand Down Expand Up @@ -244,8 +245,9 @@ test('renders a warning icon when a table name has a pre-existing dataset', asyn
render(
<LeftPanel
setDataset={mockFun}
dataset={exampleDataset[0]}
datasetNames={['Sheet2']}
schema="schema_a"
dbId={1}
datasets={['Sheet2']}
/>,
{
useRedux: true,
Expand Down
Loading

0 comments on commit 577ac81

Please sign in to comment.