diff --git a/superset-frontend/cypress-base/cypress/integration/explore/link.test.js b/superset-frontend/cypress-base/cypress/integration/explore/link.test.js index bbbdfaab02..8b0bbb227e 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/link.test.js +++ b/superset-frontend/cypress-base/cypress/integration/explore/link.test.js @@ -90,7 +90,7 @@ describe('Test explore links', () => { cy.visitChartByParams(JSON.stringify(formData)); cy.verifySliceSuccess({ waitAlias: '@postJson' }); - cy.url().then(url => { + cy.url().then(() => { cy.get('button[data-target="#save_modal"]').click(); cy.get('.modal-content').within(() => { cy.get('#saveas-radio').check(); diff --git a/superset-frontend/spec/javascripts/explore/components/EmbedCodeButton_spec.jsx b/superset-frontend/spec/javascripts/explore/components/EmbedCodeButton_spec.jsx index f91f7c64f0..14169342e0 100644 --- a/superset-frontend/spec/javascripts/explore/components/EmbedCodeButton_spec.jsx +++ b/superset-frontend/spec/javascripts/explore/components/EmbedCodeButton_spec.jsx @@ -20,12 +20,17 @@ import React from 'react'; import { shallow, mount } from 'enzyme'; import { OverlayTrigger } from 'react-bootstrap'; import sinon from 'sinon'; +import { Provider } from 'react-redux'; +import configureStore from 'redux-mock-store'; import EmbedCodeButton from 'src/explore/components/EmbedCodeButton'; import * as exploreUtils from 'src/explore/exploreUtils'; import * as common from 'src/utils/common'; describe('EmbedCodeButton', () => { + const mockStore = configureStore([]); + const store = mockStore({}); + const defaultProps = { latestQueryFormData: { datasource: '107__table' }, }; @@ -41,11 +46,16 @@ describe('EmbedCodeButton', () => { expect(wrapper.find(OverlayTrigger)).toExist(); }); - it('should create shorten, standalone, explore url', () => { + it('should create a short, standalone, explore url', () => { const spy1 = sinon.spy(exploreUtils, 'getExploreLongUrl'); const spy2 = sinon.spy(common, 'getShortUrl'); - const wrapper = mount(); + const wrapper = mount(, { + wrappingComponent: Provider, + wrappingComponentProps: { + store, + }, + }); wrapper.setState({ height: '1000', width: '2000', diff --git a/superset-frontend/spec/javascripts/sqllab/TableElement_spec.jsx b/superset-frontend/spec/javascripts/sqllab/TableElement_spec.jsx index 598c2de34d..a0f242bb1c 100644 --- a/superset-frontend/spec/javascripts/sqllab/TableElement_spec.jsx +++ b/superset-frontend/spec/javascripts/sqllab/TableElement_spec.jsx @@ -18,13 +18,18 @@ */ import React from 'react'; import { mount, shallow } from 'enzyme'; +import { Provider } from 'react-redux'; +import configureStore from 'redux-mock-store'; import Link from 'src/components/Link'; import TableElement from 'src/SqlLab/components/TableElement'; import ColumnElement from 'src/SqlLab/components/ColumnElement'; + import { mockedActions, table } from './fixtures'; describe('TableElement', () => { + const mockStore = configureStore([]); + const store = mockStore({}); const mockedProps = { actions: mockedActions, table, @@ -45,7 +50,11 @@ describe('TableElement', () => { expect(wrapper.find(ColumnElement)).toHaveLength(14); }); it('mounts', () => { - mount(); + mount( + + + , + ); }); it('sorts columns', () => { const wrapper = shallow(); @@ -58,7 +67,11 @@ describe('TableElement', () => { ); }); it('calls the collapseTable action', () => { - const wrapper = mount(); + const wrapper = mount( + + + , + ); expect(mockedActions.collapseTable.called).toBe(false); wrapper.find('.table-name').simulate('click'); expect(mockedActions.collapseTable.called).toBe(true); diff --git a/superset-frontend/src/components/Button/index.tsx b/superset-frontend/src/components/Button/index.tsx index 22b04edbd0..a8854313d1 100644 --- a/superset-frontend/src/components/Button/index.tsx +++ b/superset-frontend/src/components/Button/index.tsx @@ -114,14 +114,12 @@ export default function Button(props: ButtonProps) { {props.children}
    - {dropdownItems.map( - (dropdownItem: DropdownItemProps, index1: number) => ( - - -   {dropdownItem.label} - - ), - )} + {dropdownItems.map((dropdownItem: DropdownItemProps) => ( + + +   {dropdownItem.label} + + ))}
); diff --git a/superset-frontend/src/components/CopyToClipboard.jsx b/superset-frontend/src/components/CopyToClipboard.jsx index f40abf9a97..389991b015 100644 --- a/superset-frontend/src/components/CopyToClipboard.jsx +++ b/superset-frontend/src/components/CopyToClipboard.jsx @@ -20,6 +20,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Tooltip, OverlayTrigger, MenuItem } from 'react-bootstrap'; import { t } from '@superset-ui/translation'; +import withToasts from 'src/messageToasts/enhancers/withToasts'; const propTypes = { copyNode: PropTypes.node, @@ -30,6 +31,7 @@ const propTypes = { inMenu: PropTypes.bool, wrapped: PropTypes.bool, tooltipText: PropTypes.string, + addDangerToast: PropTypes.func.isRequired, }; const defaultProps = { @@ -41,7 +43,7 @@ const defaultProps = { tooltipText: t('Copy to clipboard'), }; -export default class CopyToClipboard extends React.Component { +class CopyToClipboard extends React.Component { constructor(props) { super(props); this.state = { @@ -95,9 +97,9 @@ export default class CopyToClipboard extends React.Component { throw new Error(t('Not successful')); } } catch (err) { - window.alert( + this.props.addDangerToast( t('Sorry, your browser does not support copying. Use Ctrl / Cmd + C!'), - ); // eslint-disable-line + ); } document.body.removeChild(span); @@ -194,5 +196,7 @@ export default class CopyToClipboard extends React.Component { } } +export default withToasts(CopyToClipboard); + CopyToClipboard.propTypes = propTypes; CopyToClipboard.defaultProps = defaultProps; diff --git a/superset-frontend/src/components/ListViewCard/ImageLoader.tsx b/superset-frontend/src/components/ListViewCard/ImageLoader.tsx index a4c859e4f7..a521124434 100644 --- a/superset-frontend/src/components/ListViewCard/ImageLoader.tsx +++ b/superset-frontend/src/components/ListViewCard/ImageLoader.tsx @@ -17,6 +17,7 @@ * under the License. */ import React, { useEffect } from 'react'; +import { logging } from '@superset-ui/core'; interface ImageLoaderProps extends React.DetailedHTMLProps< @@ -48,7 +49,7 @@ export default function ImageLoader({ } }) .catch(e => { - console.error(e); // eslint-disable-line no-console + logging.error(e); setImgSrc(fallback); }); } diff --git a/superset-frontend/src/views/CRUD/utils.tsx b/superset-frontend/src/views/CRUD/utils.tsx index 884a764dfc..5aea548a78 100644 --- a/superset-frontend/src/views/CRUD/utils.tsx +++ b/superset-frontend/src/views/CRUD/utils.tsx @@ -23,6 +23,7 @@ import { import { t } from '@superset-ui/translation'; import rison from 'rison'; import getClientErrorObject from 'src/utils/getClientErrorObject'; +import { logging } from '@superset-ui/core'; export const createFetchRelated = ( resource: string, @@ -56,7 +57,7 @@ export const createFetchRelated = ( export function createErrorHandler(handleErrorFunc: (errMsg?: string) => void) { return async (e: SupersetClientResponse | string) => { const parsedError = await getClientErrorObject(e); - console.error(e); + logging.error(e); handleErrorFunc(parsedError.message); }; }