fix(explore): Prevent shared controls from checking feature flags outside React render (#21315)

This commit is contained in:
Cody Leff
2022-09-14 14:41:47 -04:00
committed by GitHub
parent 59ca7861c0
commit 2285ebe72e
21 changed files with 285 additions and 435 deletions

View File

@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { FeatureFlag } from '@superset-ui/core';
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import {
@@ -27,12 +28,18 @@ const defaultProps: DndColumnSelectProps = {
type: 'DndColumnSelect',
name: 'Filter',
onChange: jest.fn(),
options: {
string: { column_name: 'Column A' },
},
options: [{ column_name: 'Column A' }],
actions: { setControlValue: jest.fn() },
};
beforeAll(() => {
window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true };
});
afterAll(() => {
window.featureFlags = {};
});
test('renders with default props', async () => {
render(<DndColumnSelect {...defaultProps} />, {
useDnd: true,
@@ -42,7 +49,7 @@ test('renders with default props', async () => {
});
test('renders with value', async () => {
render(<DndColumnSelect {...defaultProps} value="string" />, {
render(<DndColumnSelect {...defaultProps} value="Column A" />, {
useDnd: true,
useRedux: true,
});