superset/superset-frontend/spec/javascripts/explore/components/SaveModal_spec.jsx

330 lines
10 KiB
React
Raw Normal View History

/**
* 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 React from 'react';
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { bindActionCreators } from 'redux';
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
style: Pass at propagating (and enhancing) Button component throughout Superset (#10649) * getting rid of weird focus/active outline ring * Buttons... buttons _everywhere_ * linting * Nixing views/CRUD/dataset/Button component * fixing 2 typing errors * fixing more TS errors * prefer src path for include * one more real button, one less CSS class * one more "button" to "Button" * Published Status is now a proper clickable Label * nixing the CRUD button again * touching up stories, with SupersetButton story * SIP-34 button colors * adding polished package to mix colors * updating button colors to match Superset theme * abstracting away from bootstrap-specific props (might pivot libraries soon!) * more abstraction from bsStyle/bsSize props * exchanging styles for a prop * linting * restoring feature flag to stock * using src alias * last <button> replacement * this classname would never be applied * more linting action * fixing unsupported bsSize 'medium', and cta typing error * more cta action * unnecessary styles * errant bsSize prop * cleanup * tweaks to make new New button work * Linting * fixing a couple tests * fixing theme based test failure * margin tweak for NEW button * another fixed test * another fixed test * fixing two more tests * fixing last broken tests. * always be linting * Adding tertiary/dashed buttons * cleaning up QueryAndSave buttons * fixing "link" button styles * fixing/updating link button styles * cta buttons on Modal component * linting. * exporting button story knobs, making ALL knobs safe for export. * capitalizing a file... no big whoop * Basic button tests * renaming button - temporarily * renaming file to fix capitalization issue * passing theme through to a difficult popover. * fixin' a newly busted unit test * lint fixin' * oops, shouldn't have changed this prop! * adding a dive() to themedShallow, and fixing a cypress/jest test * addressing lint stuff * touching up stories, with SupersetButton story * SIP-34 button colors * updating button colors to match Superset theme * abstracting away from bootstrap-specific props (might pivot libraries soon!) * linting * restoring feature flag to stock * cleanup * Linting * renaming button - temporarily * renaming file to fix capitalization issue * oops, shouldn't have changed this prop! * adding a dive() to themedShallow, and fixing a cypress/jest test * addressing lint stuff * nixing new modal button * Fixing another popover/button issue that should break cypress * lint :sparkles: * passing classNames through to new button (should fix some tests) * cleaning unused classes, making cypress tests use data attrs * fixin' the test * fixing another class-based test with data-test attr * no longer passing theme as prop to buttons in popovers... themeprovider is better * outline/border tweaks!
2020-08-28 20:34:28 -04:00
import { shallow } from 'enzyme';
import { styledMount as mount } from 'spec/helpers/theming';
import { FormControl, Modal, Radio } from 'react-bootstrap';
import Button from 'src/components/Button';
import sinon from 'sinon';
import fetchMock from 'fetch-mock';
import * as exploreUtils from 'src/explore/exploreUtils';
import * as saveModalActions from 'src/explore/actions/saveModalActions';
import SaveModal from 'src/explore/components/SaveModal';
describe('SaveModal', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const middlewares = [thunk];
const mockStore = configureStore(middlewares);
const initialState = {
chart: {},
saveModal: {
dashboards: [],
},
explore: {
can_overwrite: true,
user_id: '1',
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
datasource: {},
slice: {
slice_id: 1,
slice_name: 'title',
},
alert: null,
},
};
const store = mockStore(initialState);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const defaultProps = {
onHide: () => ({}),
actions: bindActionCreators(saveModalActions, arg => {
if (typeof arg === 'function') {
return arg(jest.fn);
}
return arg;
}),
form_data: { datasource: '107__table' },
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
};
const mockEvent = {
target: {
value: 'mock event target',
},
value: 10,
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
};
const getWrapper = () =>
shallow(<SaveModal {...defaultProps} />, {
context: { store },
}).dive();
it('renders a Modal with the right set of components', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const wrapper = getWrapper();
expect(wrapper.find(Modal)).toExist();
expect(wrapper.find(FormControl)).toExist();
expect(wrapper.find(Button)).toHaveLength(3);
expect(wrapper.find(Radio)).toHaveLength(2);
});
it('overwrite radio button is disabled for new slice', () => {
const wrapper = getWrapper();
wrapper.setProps({ slice: null });
expect(wrapper.find('#overwrite-radio').prop('disabled')).toBe(true);
});
it('disable overwrite option for non-owner', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const wrapperForNonOwner = getWrapper();
wrapperForNonOwner.setProps({ can_overwrite: false });
const overwriteRadio = wrapperForNonOwner.find('#overwrite-radio');
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(overwriteRadio).toHaveLength(1);
expect(overwriteRadio.prop('disabled')).toBe(true);
});
it('saves a new slice', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const wrapperForNewSlice = getWrapper();
wrapperForNewSlice.setProps({ can_overwrite: false });
wrapperForNewSlice.instance().changeAction('saveas');
const saveasRadio = wrapperForNewSlice.find('#saveas-radio');
saveasRadio.simulate('click');
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(wrapperForNewSlice.state().action).toBe('saveas');
});
it('overwrite a slice', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const wrapperForOverwrite = getWrapper();
const overwriteRadio = wrapperForOverwrite.find('#overwrite-radio');
overwriteRadio.simulate('click');
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(wrapperForOverwrite.state().action).toBe('overwrite');
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
it('componentDidMount', () => {
sinon.spy(SaveModal.prototype, 'componentDidMount');
sinon.spy(defaultProps.actions, 'fetchDashboards');
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
mount(<SaveModal {...defaultProps} />, {
context: { store },
});
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(SaveModal.prototype.componentDidMount.calledOnce).toBe(true);
expect(defaultProps.actions.fetchDashboards.calledOnce).toBe(true);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
SaveModal.prototype.componentDidMount.restore();
defaultProps.actions.fetchDashboards.restore();
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
it('onChange', () => {
const wrapper = getWrapper();
wrapper.instance().onSliceNameChange(mockEvent);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(wrapper.state().newSliceName).toBe(mockEvent.target.value);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
wrapper.instance().onDashboardSelectChange(mockEvent);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(wrapper.state().saveToDashboardId).toBe(mockEvent.value);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
describe('saveOrOverwrite', () => {
beforeEach(() => {
sinon.stub(exploreUtils, 'getExploreUrl').callsFake(() => 'mockURL');
sinon.stub(defaultProps.actions, 'saveSlice').callsFake(() =>
Promise.resolve({
data: {
dashboard_url: 'http://localhost/mock_dashboard/',
slice: { slice_url: '/mock_slice/' },
},
}),
);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
afterEach(() => {
exploreUtils.getExploreUrl.restore();
defaultProps.actions.saveSlice.restore();
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
it('should save slice', () => {
const wrapper = getWrapper();
wrapper.instance().saveOrOverwrite(true);
const { args } = defaultProps.actions.saveSlice.getCall(0);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(args[0]).toEqual(defaultProps.form_data);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
it('existing dashboard', () => {
const wrapper = getWrapper();
const saveToDashboardId = 100;
wrapper.setState({ saveToDashboardId });
wrapper.instance().saveOrOverwrite(true);
const { args } = defaultProps.actions.saveSlice.getCall(0);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(args[1].save_to_dashboard_id).toBe(saveToDashboardId);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
it('new dashboard', () => {
const wrapper = getWrapper();
const newDashboardName = 'new dashboard name';
wrapper.setState({ newDashboardName });
wrapper.instance().saveOrOverwrite(true);
const { args } = defaultProps.actions.saveSlice.getCall(0);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(args[1].new_dashboard_name).toBe(newDashboardName);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
describe('should always reload or redirect', () => {
let wrapper;
let windowLocation;
beforeEach(() => {
wrapper = getWrapper();
windowLocation = window.location;
// To bypass "TypeError: Cannot redefine property: assign"
Object.defineProperty(window, 'location', {
value: { ...windowLocation, assign: () => {} },
});
sinon.stub(window.location, 'assign');
});
afterEach(() => {
window.location.assign.restore();
Object.defineProperty(window, 'location', windowLocation);
});
it('Save & go to dashboard', () => {
return new Promise(done => {
wrapper.instance().saveOrOverwrite(true);
defaultProps.actions.saveSlice().then(() => {
expect(window.location.assign.callCount).toEqual(1);
expect(window.location.assign.getCall(0).args[0]).toEqual(
'http://localhost/mock_dashboard/',
);
done();
});
});
});
it('saveas new slice', () => {
return new Promise(done => {
wrapper.setState({
action: 'saveas',
newSliceName: 'new slice name',
});
wrapper.instance().saveOrOverwrite(false);
defaultProps.actions.saveSlice().then(() => {
expect(window.location.assign.callCount).toEqual(1);
expect(window.location.assign.getCall(0).args[0]).toEqual(
'/mock_slice/',
);
done();
});
});
});
it('overwrite original slice', () => {
return new Promise(done => {
wrapper.setState({ action: 'overwrite' });
wrapper.instance().saveOrOverwrite(false);
defaultProps.actions.saveSlice().then(() => {
expect(window.location.assign.callCount).toEqual(1);
expect(window.location.assign.getCall(0).args[0]).toEqual(
'/mock_slice/',
);
done();
});
});
});
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
describe('fetchDashboards', () => {
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
let dispatch;
let actionThunk;
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const userID = 1;
const mockDashboardData = {
pks: ['id'],
result: [{ id: 'id', dashboard_title: 'dashboard title' }],
};
const saveEndpoint = `glob:*/dashboardasync/api/read?_flt_0_owners=${1}`;
beforeAll(() => {
fetchMock.get(saveEndpoint, mockDashboardData);
});
afterAll(fetchMock.restore);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
beforeEach(() => {
dispatch = sinon.spy();
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
afterEach(() => {
fetchMock.resetHistory();
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const makeRequest = () => {
actionThunk = saveModalActions.fetchDashboards(userID);
return actionThunk(dispatch);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
};
it('makes the fetch request', () =>
makeRequest().then(() => {
expect(fetchMock.calls(saveEndpoint)).toHaveLength(1);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
return Promise.resolve();
}));
it('calls correct actions on success', () =>
makeRequest().then(() => {
expect(dispatch.callCount).toBe(1);
expect(dispatch.getCall(0).args[0].type).toBe(
saveModalActions.FETCH_DASHBOARDS_SUCCEEDED,
);
return Promise.resolve();
}));
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
it('calls correct actions on error', () => {
fetchMock.get(
saveEndpoint,
{ throws: 'error' },
{ overwriteRoutes: true },
);
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
return makeRequest().then(() => {
expect(dispatch.callCount).toBe(1);
expect(dispatch.getCall(0).args[0].type).toBe(
saveModalActions.FETCH_DASHBOARDS_FAILED,
);
fetchMock.get(saveEndpoint, mockDashboardData, {
overwriteRoutes: true,
});
return Promise.resolve();
});
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
});
it('removeAlert', () => {
sinon.spy(defaultProps.actions, 'removeSaveModalAlert');
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
const wrapper = getWrapper();
wrapper.setProps({ alert: 'old alert' });
wrapper.instance().removeAlert();
expect(defaultProps.actions.removeSaveModalAlert.callCount).toBe(1);
[refactor] Migrate from Mocha+Chai to Jest (#6079) * [refactor] Migrate from Mocha+Chai to Jest This change migrates all the existing unit tests - to Jest's global expect and matchers from chai's imported expect, asserts and matchers. - to Jest's describe/test from mocha's describe/it The majority of the mechanical changes to tests are achieved through running jest-codemods. The only two note-worthy manual tweaks: 1. Setting a testURL of http://localhost in jest config and adjusting a few tests to leverage this value instead of relying on about:blank. 2. Re-enabling ExploreChartPanel_spec which was previously commented out as we cannot have empty tests with nothing in it with Jest. :) This change also removes dependencies to Mocha and Chai. * Remove the test:one command as it now does the same thing as test. * Fixing lint errors. The diff looks large but is large done through `yarn run lint --fix` The only noteworthy change is the one in eslintrc for tests. The env has been updated from mocha to jest. * Adding eslint-plugin-jest and further modify tests. - One small fix in sqllab's Timer Spec for a test that is not using the spy it created for testing. - Deletion of a duplicated test caught by eslint-plugin-jest. * - Make istanbul coverage work with Jest. - Remove dependency on stand-alone istanbul and babel-istanbul as they're built-into jest. Yes! * Attempt to fix dynamic imports in tests. * run sequentially and log heap usage * - tweaking maxworkers for travis and specifying coverageDirectory for codecov - remove dynamic import in shim.js now that it is set in babelrc for tests only.
2018-10-15 16:10:18 -04:00
expect(wrapper.state().alert).toBeNull();
defaultProps.actions.removeSaveModalAlert.restore();
Explore view save modal spec (#3110) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * improve test coverage for explore view components: - SaveModal component - URLShortLinkButton * remove comment-out code * [bugfix] wrong 'Cant have overlap between Series and Breakdowns' (#3254) * [explore] make edit datasource a basic link (#3244) * Relying on FAB for font-awesome.min.css (#3261) * Modernize SQLA pessimistic handling (#3256) Looks like SQLAlchemy has redefined the best practice around pessimistic connection handling. * [webpack] break CSS and JS files while webpackin' (#3262) * [webpack] break CSS and JS files while webpackin' * cleaning up some templates * Fix pylint issue * import logging (#3264) * [bugfix] preserve order in groupby (#3268) Recently in https://github.com/apache/incubator-superset/commit/4c3313b01cb508ced8519a68f6479db423974929 I introduced an issue where the order of groupby fields might change. This addresses this issue and will preserve ordering. * Explicitly add Flask as dependancy (#3252) * Use sane Celery defaults to prevent tasks from being delayed (#3267) * Improve the chart type of Visualize in sqllab (#3241) * Improve the chart type of Visualize in sqllab & Add some css & Fix the link address in the navbar * add vizTypes filter * Set default ports Druid (#3266) For Druid set the default port for the broker and coordinator. * [explore] Split large reducer logic in ExploreViewContainer (#3088) * split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
2017-08-10 20:04:44 -04:00
});
});