mirror of
https://github.com/apache/superset.git
synced 2026-04-17 15:15:20 +00:00
* [feat] Feature flag system via config
Adding a feature flag system that is driven by superset_config.py. This change includes:
- Server side changes to specify a dedicated FEATURE_FLAG dictionary for listing feature flags. E.g.
```
FEATURE_FLAGS = { 'SCOPED_FILTER': true }
```
- Pass the new feature flags to client via bootstrap-data
- Client side changes to inject feature flags into the redux state tree for dashboard, explore view and SqlLab
- Client side refactor/clean up so the feature flags can be properly tested. Also avoid modifying incoming bootstrap data when creating initial state for the redux state tree
- Re-enable tests that were previously disabled for ExploreViewContainer
* Fix lint errors.
* Remove the partial attempt to get reference to src working in tests (so we don't have to write ../../../src and such in tests). This will in a separate PR.
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import configureStore from 'redux-mock-store';
|
|
import thunk from 'redux-thunk';
|
|
|
|
import { shallow } from 'enzyme';
|
|
import { expect } from 'chai';
|
|
import sinon from 'sinon';
|
|
|
|
import App from '../../../src/SqlLab/components/App';
|
|
import TabbedSqlEditors from '../../../src/SqlLab/components/TabbedSqlEditors';
|
|
import getInitialState from '../../../src/SqlLab/getInitialState';
|
|
|
|
describe('SqlLab App', () => {
|
|
const middlewares = [thunk];
|
|
const mockStore = configureStore(middlewares);
|
|
let store;
|
|
let wrapper;
|
|
|
|
before(() => {
|
|
const bootstrapData = {
|
|
common: {
|
|
feature_flags: {
|
|
FOO_BAR: true,
|
|
},
|
|
},
|
|
};
|
|
store = mockStore(getInitialState(bootstrapData), {});
|
|
});
|
|
|
|
beforeEach(() => {
|
|
wrapper = shallow(<App />, { context: { store } });
|
|
});
|
|
|
|
it('should set feature flags', () => {
|
|
expect(wrapper.prop('isFeatureEnabled')('FOO_BAR')).to.equal(true);
|
|
});
|
|
|
|
it('is valid', () => {
|
|
expect(React.isValidElement(<App />)).to.equal(true);
|
|
});
|
|
|
|
it('should handler resize', () => {
|
|
const inner = wrapper.dive();
|
|
sinon.spy(inner.instance(), 'getHeight');
|
|
inner.instance().handleResize();
|
|
expect(inner.instance().getHeight.callCount).to.equal(1);
|
|
inner.instance().getHeight.restore();
|
|
});
|
|
|
|
it('should render', () => {
|
|
const inner = wrapper.dive();
|
|
expect(inner.find('.SqlLab')).to.have.length(1);
|
|
expect(inner.find(TabbedSqlEditors)).to.have.length(1);
|
|
});
|
|
});
|