mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
feat: hide datasource legacy based on featureflag (#11371)
This commit is contained in:
@@ -29,6 +29,7 @@ import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
|
||||
import DatasourceModal from 'src/datasource/DatasourceModal';
|
||||
import DatasourceEditor from 'src/datasource/DatasourceEditor';
|
||||
import * as featureFlags from 'src/featureFlags';
|
||||
import mockDatasource from '../../fixtures/mockDatasource';
|
||||
|
||||
const mockStore = configureStore([thunk]);
|
||||
@@ -61,12 +62,19 @@ async function mountAndWait(props = mockedProps) {
|
||||
|
||||
describe('DatasourceModal', () => {
|
||||
let wrapper;
|
||||
|
||||
let isFeatureEnabledMock;
|
||||
beforeEach(async () => {
|
||||
isFeatureEnabledMock = jest
|
||||
.spyOn(featureFlags, 'isFeatureEnabled')
|
||||
.mockReturnValue(true);
|
||||
fetchMock.reset();
|
||||
wrapper = await mountAndWait();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.find(DatasourceModal)).toExist();
|
||||
});
|
||||
@@ -98,4 +106,35 @@ describe('DatasourceModal', () => {
|
||||
expected,
|
||||
); /* eslint no-underscore-dangle: 0 */
|
||||
});
|
||||
|
||||
it('renders a legacy data source btn', () => {
|
||||
expect(
|
||||
wrapper.find('button[data-test="datasource-modal-legacy-edit"]'),
|
||||
).toExist();
|
||||
});
|
||||
});
|
||||
|
||||
describe('DatasourceModal without legacy data btn', () => {
|
||||
let wrapper;
|
||||
let isFeatureEnabledMock;
|
||||
beforeEach(async () => {
|
||||
isFeatureEnabledMock = jest
|
||||
.spyOn(featureFlags, 'isFeatureEnabled')
|
||||
.mockReturnValue(false);
|
||||
fetchMock.reset();
|
||||
wrapper = await mountAndWait();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
});
|
||||
|
||||
it('hides legacy data source btn', () => {
|
||||
isFeatureEnabledMock = jest
|
||||
.spyOn(featureFlags, 'isFeatureEnabled')
|
||||
.mockReturnValue(false);
|
||||
expect(
|
||||
wrapper.find('button[data-test="datasource-modal-legacy-edit"]'),
|
||||
).not.toExist();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user