superset/superset-frontend/spec/javascripts/sqllab/SaveDatasetModal_spec.tsx

60 lines
2.2 KiB
TypeScript
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';
import { shallow } from 'enzyme';
import { Radio } from 'src/components/Radio';
import { AutoComplete, Input } from 'src/common/components';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
describe('SaveDatasetModal', () => {
const mockedProps = {
visible: false,
onOk: () => {},
onHide: () => {},
handleDatasetNameChange: () => {},
handleSaveDatasetRadioBtnState: () => {},
saveDatasetRadioBtnState: 1,
handleOverwriteCancel: () => {},
handleOverwriteDataset: () => {},
handleOverwriteDatasetOption: () => {},
defaultCreateDatasetValue: 'someDatasets',
feat: Sqllab to Explore UX improvements (#11755) * create boiler modal component * hello world modal * setup modal flow * setup savemodal for components * flake8 * fix onclick reference * working create datasource boiler * saving spot for callback on text input * working dataset with input box * working redirect on completion * get data for owners dropdown * fix build with pull from master * fix the filteroption * 💯 * move state to upper component * add overwrite state * hacked overwrite process * linting * fix filter * cleaning up the coe * Delete preset.code-workspace * remove unused code * remove visualize * update default value * remove unneeded vars * checkout package-lock.json * linting * get user id * remove page filter * setup proper call for updating columns in dataset * add move to explore flow * linting * add param for overriding columns * linting * change title * fix some tings * cleanup * linting * add types in some places * save toast * use moment * add error toast * create enum for radio states * initial state for saving query * add tpying * addressing concerns * update propTypes * add functionality for CTAS explor btn * handle CTAS state * fix onclick to reference upper level component * formatting * reset state after closing * add error message when user doesn't pick an already selected dataset * remove unneeded todo * remove styling * move async calls to api directory * remove console.log * add user id param * typing * littty * move put to seperate file * save * dsf * fix typing errors * adding more types * fix typing erros * linting * add basic spec test * create dataset modal * add components reference * Rename SaveDatasetModal_spec.jsx to SaveDatasetModal_spec.tsx * remove sinon for now * fix typing errors on modal files * fix linting * address comments * attempt to fix linting * add props * fix test * fix the linting * yerp * fix this references * spaces * handleOverwriteCancel reference cleanup * rename bool value for shouldOverwriteDataset * fix typing for onChange * you still the best in the world * fix spec * align branches * push * fix key names * fix dataset reference * lowercase * fix save bug with tiem * fixed styling * fix date state after push to explore * add disabling states * plz refactor this * this is working fully now * do some renaming * renaming * remove console.logs * still refactoring * remove unneeded code * remove unneeded variables * still cleaning * added interface * fix typing issues * cleanup unused code * fix npm lnit * fix initial problems * add props to test * remove unneeded files * skip linting * saving * this works * remove old test * remove old test * fix linting * fix broken test * remove jsx file * refactoring * cleanup * remove comments * reset user object * fix functions * fix this * reverting CTAS btn flow * remove onclick * save frontend work * allow for database id to be passed as param in body * use enum * fix linting * style alignment * get rid of .then * add function to compute default value with tiem * lit * remove ts-error * fix typing
2020-12-08 20:29:41 -05:00
shouldOverwriteDataset: false,
userDatasetOptions: [],
disableSaveAndExploreBtn: false,
handleSaveDatasetModalSearch: () => Promise,
feat: Sqllab to Explore UX improvements (#11755) * create boiler modal component * hello world modal * setup modal flow * setup savemodal for components * flake8 * fix onclick reference * working create datasource boiler * saving spot for callback on text input * working dataset with input box * working redirect on completion * get data for owners dropdown * fix build with pull from master * fix the filteroption * 💯 * move state to upper component * add overwrite state * hacked overwrite process * linting * fix filter * cleaning up the coe * Delete preset.code-workspace * remove unused code * remove visualize * update default value * remove unneeded vars * checkout package-lock.json * linting * get user id * remove page filter * setup proper call for updating columns in dataset * add move to explore flow * linting * add param for overriding columns * linting * change title * fix some tings * cleanup * linting * add types in some places * save toast * use moment * add error toast * create enum for radio states * initial state for saving query * add tpying * addressing concerns * update propTypes * add functionality for CTAS explor btn * handle CTAS state * fix onclick to reference upper level component * formatting * reset state after closing * add error message when user doesn't pick an already selected dataset * remove unneeded todo * remove styling * move async calls to api directory * remove console.log * add user id param * typing * littty * move put to seperate file * save * dsf * fix typing errors * adding more types * fix typing erros * linting * add basic spec test * create dataset modal * add components reference * Rename SaveDatasetModal_spec.jsx to SaveDatasetModal_spec.tsx * remove sinon for now * fix typing errors on modal files * fix linting * address comments * attempt to fix linting * add props * fix test * fix the linting * yerp * fix this references * spaces * handleOverwriteCancel reference cleanup * rename bool value for shouldOverwriteDataset * fix typing for onChange * you still the best in the world * fix spec * align branches * push * fix key names * fix dataset reference * lowercase * fix save bug with tiem * fixed styling * fix date state after push to explore * add disabling states * plz refactor this * this is working fully now * do some renaming * renaming * remove console.logs * still refactoring * remove unneeded code * remove unneeded variables * still cleaning * added interface * fix typing issues * cleanup unused code * fix npm lnit * fix initial problems * add props to test * remove unneeded files * skip linting * saving * this works * remove old test * remove old test * fix linting * fix broken test * remove jsx file * refactoring * cleanup * remove comments * reset user object * fix functions * fix this * reverting CTAS btn flow * remove onclick * save frontend work * allow for database id to be passed as param in body * use enum * fix linting * style alignment * get rid of .then * add function to compute default value with tiem * lit * remove ts-error * fix typing
2020-12-08 20:29:41 -05:00
filterAutocompleteOption: () => false,
onChangeAutoComplete: () => {},
};
it('renders a radio group btn', () => {
// @ts-ignore
const wrapper = shallow(<SaveDatasetModal {...mockedProps} />);
expect(wrapper.find(Radio.Group)).toExist();
});
it('renders a autocomplete', () => {
// @ts-ignore
const wrapper = shallow(<SaveDatasetModal {...mockedProps} />);
expect(wrapper.find(AutoComplete)).toExist();
});
it('renders an input form', () => {
// @ts-ignore
const wrapper = shallow(<SaveDatasetModal {...mockedProps} />);
expect(wrapper.find(Input)).toExist();
});
});