diff --git a/superset-frontend/spec/helpers/theming.ts b/superset-frontend/spec/helpers/theming.ts
new file mode 100644
index 0000000000..cf1b4626f2
--- /dev/null
+++ b/superset-frontend/spec/helpers/theming.ts
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { shallow as enzymeShallow, mount as enzymeMount } from 'enzyme';
+import { supersetTheme, ThemeProvider } from '@superset-ui/style';
+import { ReactElement } from 'react';
+
+type optionsType = {
+ wrappingComponentProps?: any;
+ wrappingComponent?: ReactElement;
+ context?: any;
+};
+
+export function styledMount(
+ component: ReactElement,
+ options: optionsType = {},
+) {
+ return enzymeMount(component, {
+ ...options,
+ wrappingComponent: ThemeProvider,
+ wrappingComponentProps: {
+ theme: supersetTheme,
+ ...options?.wrappingComponentProps,
+ },
+ });
+}
+
+export function styledShallow(
+ component: ReactElement,
+ options: optionsType = {},
+) {
+ return enzymeShallow(component, {
+ ...options,
+ wrappingComponent: ThemeProvider,
+ wrappingComponentProps: {
+ theme: supersetTheme,
+ ...options?.wrappingComponentProps,
+ },
+ });
+}
diff --git a/superset-frontend/spec/javascripts/components/CachedLabel_spec.jsx b/superset-frontend/spec/javascripts/components/CachedLabel_spec.jsx
index 41b182a440..7e1ecf7738 100644
--- a/superset-frontend/spec/javascripts/components/CachedLabel_spec.jsx
+++ b/superset-frontend/spec/javascripts/components/CachedLabel_spec.jsx
@@ -18,8 +18,8 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
-import { Label } from 'react-bootstrap';
+import Label from 'src/components/Label';
import CachedLabel from 'src/components/CachedLabel';
describe('CachedLabel', () => {
diff --git a/superset-frontend/spec/javascripts/explore/components/AdhocFilterOption_spec.jsx b/superset-frontend/spec/javascripts/explore/components/AdhocFilterOption_spec.jsx
index caff8aa61d..f2e9ffe434 100644
--- a/superset-frontend/spec/javascripts/explore/components/AdhocFilterOption_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/AdhocFilterOption_spec.jsx
@@ -20,8 +20,9 @@
import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
-import { Label, OverlayTrigger } from 'react-bootstrap';
+import { OverlayTrigger } from 'react-bootstrap';
+import Label from 'src/components/Label';
import AdhocFilter, {
EXPRESSION_TYPES,
CLAUSES,
diff --git a/superset-frontend/spec/javascripts/explore/components/AdhocMetricOption_spec.jsx b/superset-frontend/spec/javascripts/explore/components/AdhocMetricOption_spec.jsx
index bea3432beb..0612f6cbfd 100644
--- a/superset-frontend/spec/javascripts/explore/components/AdhocMetricOption_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/AdhocMetricOption_spec.jsx
@@ -20,8 +20,9 @@
import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';
-import { Label, OverlayTrigger } from 'react-bootstrap';
+import { OverlayTrigger } from 'react-bootstrap';
+import Label from 'src/components/Label';
import AdhocMetric from 'src/explore/AdhocMetric';
import AdhocMetricOption from 'src/explore/components/AdhocMetricOption';
import { AGGREGATES } from 'src/explore/constants';
diff --git a/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx b/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
index 1c3b0904e6..5a93af1ac6 100644
--- a/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
@@ -19,9 +19,10 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import sinon from 'sinon';
-import { mount } from 'enzyme';
-import { Button, Label } from 'react-bootstrap';
+import { styledMount as mount } from 'spec/helpers/theming';
+import { Button } from 'react-bootstrap';
+import Label from 'src/components/Label';
import DateFilterControl from 'src/explore/components/controls/DateFilterControl';
import ControlHeader from 'src/explore/components/ControlHeader';
diff --git a/superset-frontend/spec/javascripts/explore/components/RowCountLabel_spec.jsx b/superset-frontend/spec/javascripts/explore/components/RowCountLabel_spec.jsx
index 38641d2782..7776788cb1 100644
--- a/superset-frontend/spec/javascripts/explore/components/RowCountLabel_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/RowCountLabel_spec.jsx
@@ -18,8 +18,8 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
-import { Label } from 'react-bootstrap';
+import Label from 'src/components/Label';
import TooltipWrapper from 'src/components/TooltipWrapper';
import RowCountLabel from 'src/explore/components/RowCountLabel';
diff --git a/superset-frontend/spec/javascripts/explore/components/ViewportControl_spec.jsx b/superset-frontend/spec/javascripts/explore/components/ViewportControl_spec.jsx
index 87828c99e9..720e5db4ce 100644
--- a/superset-frontend/spec/javascripts/explore/components/ViewportControl_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/ViewportControl_spec.jsx
@@ -18,9 +18,10 @@
*/
/* eslint-disable no-unused-expressions */
import React from 'react';
-import { shallow } from 'enzyme';
-import { OverlayTrigger, Label } from 'react-bootstrap';
+import { styledMount as mount } from 'spec/helpers/theming';
+import { OverlayTrigger } from 'react-bootstrap';
+import Label from 'src/components/Label';
import ViewportControl from 'src/explore/components/controls/ViewportControl';
import TextControl from 'src/explore/components/controls/TextControl';
import ControlHeader from 'src/explore/components/ControlHeader';
@@ -33,13 +34,14 @@ const defaultProps = {
bearing: 0,
pitch: 0,
},
+ name: 'foo',
};
describe('ViewportControl', () => {
let wrapper;
let inst;
beforeEach(() => {
- wrapper = shallow();
+ wrapper = mount();
inst = wrapper.instance();
});
@@ -50,13 +52,12 @@ describe('ViewportControl', () => {
});
it('renders a Popover with 5 TextControl', () => {
- const popOver = shallow(inst.renderPopover());
+ const popOver = mount(inst.renderPopover());
expect(popOver.find(TextControl)).toHaveLength(5);
});
it('renders a summary in the label', () => {
- expect(wrapper.find(Label).first().render().text()).toBe(
- '6° 51\' 8.50" | 31° 13\' 21.56"',
- );
+ const label = wrapper.find(Label).first();
+ expect(label.render().text()).toBe('6° 51\' 8.50" | 31° 13\' 21.56"');
});
});
diff --git a/superset-frontend/spec/javascripts/profile/Security_spec.tsx b/superset-frontend/spec/javascripts/profile/Security_spec.tsx
index dc493d1148..6732e7b2a8 100644
--- a/superset-frontend/spec/javascripts/profile/Security_spec.tsx
+++ b/superset-frontend/spec/javascripts/profile/Security_spec.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { mount } from 'enzyme';
+import { styledMount as mount } from 'spec/helpers/theming';
import Security from 'src/profile/components/Security';
import { user, userNoPerms } from './fixtures';
diff --git a/superset-frontend/spec/javascripts/sqllab/LimitControl_spec.jsx b/superset-frontend/spec/javascripts/sqllab/LimitControl_spec.jsx
index ed3a9ba2ef..ec7ce9e2d6 100644
--- a/superset-frontend/spec/javascripts/sqllab/LimitControl_spec.jsx
+++ b/superset-frontend/spec/javascripts/sqllab/LimitControl_spec.jsx
@@ -19,7 +19,7 @@
import React from 'react';
import { shallow } from 'enzyme';
-import { Label } from 'react-bootstrap';
+import Label from 'src/components/Label';
import LimitControl from 'src/SqlLab/components/LimitControl';
import ControlHeader from 'src/explore/components/ControlHeader';
diff --git a/superset-frontend/spec/javascripts/sqllab/QueryStateLabel_spec.jsx b/superset-frontend/spec/javascripts/sqllab/QueryStateLabel_spec.jsx
index 01fc48e809..a53225d96a 100644
--- a/superset-frontend/spec/javascripts/sqllab/QueryStateLabel_spec.jsx
+++ b/superset-frontend/spec/javascripts/sqllab/QueryStateLabel_spec.jsx
@@ -17,9 +17,9 @@
* under the License.
*/
import React from 'react';
-import { Label } from 'react-bootstrap';
import { shallow } from 'enzyme';
+import Label from 'src/components/Label';
import QueryStateLabel from 'src/SqlLab/components/QueryStateLabel';
describe('SavedQuery', () => {
diff --git a/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx b/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx
index 35beab77d0..64f0164295 100644
--- a/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx
+++ b/superset-frontend/spec/javascripts/sqllab/SouthPane_spec.jsx
@@ -19,7 +19,7 @@
import React from 'react';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
-import { shallow } from 'enzyme';
+import { styledShallow as shallow } from 'spec/helpers/theming';
import SouthPaneContainer, { SouthPane } from 'src/SqlLab/components/SouthPane';
import ResultSet from 'src/SqlLab/components/ResultSet';
import { STATUS_OPTIONS } from 'src/SqlLab/constants';
@@ -70,6 +70,7 @@ describe('SouthPane', () => {
actions: {},
activeSouthPaneTab: '',
height: 1,
+ displayLimit: 1,
databases: {},
offline: false,
};
@@ -90,7 +91,7 @@ describe('SouthPane', () => {
it('should render offline when the state is offline', () => {
wrapper = getWrapper();
wrapper.setProps({ offline: true });
- expect(wrapper.find('.m-r-3').render().text()).toBe(STATUS_OPTIONS.offline);
+ expect(wrapper.childAt(0).text()).toBe(STATUS_OPTIONS.offline);
});
it('should pass latest query down to ResultSet component', () => {
wrapper = getWrapper();
diff --git a/superset-frontend/spec/javascripts/sqllab/Timer_spec.jsx b/superset-frontend/spec/javascripts/sqllab/Timer_spec.jsx
index ecd619324f..49efac73d8 100644
--- a/superset-frontend/spec/javascripts/sqllab/Timer_spec.jsx
+++ b/superset-frontend/spec/javascripts/sqllab/Timer_spec.jsx
@@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
-import { mount } from 'enzyme';
+import { styledMount as mount } from 'spec/helpers/theming';
import sinon from 'sinon';
import Timer from 'src/components/Timer';
diff --git a/superset-frontend/src/SqlLab/components/LimitControl.jsx b/superset-frontend/src/SqlLab/components/LimitControl.jsx
index c5ec5ba951..e26bb639b8 100644
--- a/superset-frontend/src/SqlLab/components/LimitControl.jsx
+++ b/superset-frontend/src/SqlLab/components/LimitControl.jsx
@@ -20,7 +20,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import {
Button,
- Label,
FormGroup,
FormControl,
Overlay,
@@ -28,6 +27,7 @@ import {
} from 'react-bootstrap';
import { t } from '@superset-ui/translation';
+import Label from 'src/components/Label';
import ControlHeader from '../../explore/components/ControlHeader';
const propTypes = {
@@ -131,7 +131,7 @@ export default class LimitControl extends React.PureComponent {
render() {
return (
-
);
diff --git a/superset-frontend/src/profile/components/Security.tsx b/superset-frontend/src/profile/components/Security.tsx
index 9646fa1e8a..d80662ee87 100644
--- a/superset-frontend/src/profile/components/Security.tsx
+++ b/superset-frontend/src/profile/components/Security.tsx
@@ -17,8 +17,10 @@
* under the License.
*/
import React from 'react';
-import { Badge, Label } from 'react-bootstrap';
+import { Badge } from 'react-bootstrap';
import { t } from '@superset-ui/translation';
+
+import Label from 'src/components/Label';
import { UserWithPermissionsAndRoles } from '../../types/bootstrapTypes';
interface SecurityProps {