mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
[sql lab] allow users to save their queries (#2528)
* Allow users to save their queries Fixing tests . * Adding placeholder for Query Description * initJQueryCSRF -> initJQueryAjaxCSRF
This commit is contained in:
committed by
GitHub
parent
c1d9918abe
commit
122891c29b
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import AlertsWrapper from '../../../javascripts/SqlLab/components/AlertsWrapper';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
|
||||
describe('AlertsWrapper', () => {
|
||||
it('is valid', () => {
|
||||
expect(React.isValidElement(<AlertsWrapper />)).to.equal(true);
|
||||
});
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
import React from 'react';
|
||||
import Alerts from '../../../javascripts/SqlLab/components/Alerts';
|
||||
import { Alert } from 'react-bootstrap';
|
||||
import { shallow } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { alert } from './fixtures';
|
||||
|
||||
|
||||
describe('Alerts', () => {
|
||||
const mockedProps = {
|
||||
alerts: [alert],
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(React.isValidElement(<Alerts />)).to.equal(true);
|
||||
});
|
||||
it('is valid with props', () => {
|
||||
expect(React.isValidElement(<Alerts {...mockedProps} />)).to.equal(true);
|
||||
});
|
||||
it('renders an Alert', () => {
|
||||
const wrapper = shallow(<Alerts {...mockedProps} />);
|
||||
expect(wrapper.find(Alert)).to.have.length(1);
|
||||
});
|
||||
});
|
||||
48
superset/assets/spec/javascripts/sqllab/SaveQuery_spec.jsx
Normal file
48
superset/assets/spec/javascripts/sqllab/SaveQuery_spec.jsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
import SaveQuery from '../../../javascripts/SqlLab/components/SaveQuery';
|
||||
import { Overlay, Popover, FormControl } from 'react-bootstrap';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
|
||||
describe('SavedQuery', () => {
|
||||
const mockedProps = {
|
||||
dbId: 1,
|
||||
schema: 'main',
|
||||
sql: 'SELECT * FROM t',
|
||||
defaultLabel: 'untitled',
|
||||
animation: false,
|
||||
};
|
||||
it('is valid', () => {
|
||||
expect(
|
||||
React.isValidElement(<SaveQuery />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('is valid with props', () => {
|
||||
expect(
|
||||
React.isValidElement(<SaveQuery {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
it('has an Overlay and a Popover', () => {
|
||||
const wrapper = shallow(<SaveQuery {...mockedProps} />);
|
||||
expect(wrapper.find(Overlay)).to.have.length(1);
|
||||
expect(wrapper.find(Popover)).to.have.length(1);
|
||||
});
|
||||
it('pops and hides', () => {
|
||||
const wrapper = mount(<SaveQuery {...mockedProps} />);
|
||||
expect(wrapper.state().showSave).to.equal(false);
|
||||
wrapper.find('.toggleSave').simulate('click');
|
||||
expect(wrapper.state().showSave).to.equal(true);
|
||||
wrapper.find('.toggleSave').simulate('click');
|
||||
expect(wrapper.state().showSave).to.equal(false);
|
||||
});
|
||||
it('has a cancel button', () => {
|
||||
const wrapper = shallow(<SaveQuery {...mockedProps} />);
|
||||
expect(wrapper.find('.cancelQuery')).to.have.length(1);
|
||||
});
|
||||
it('has 2 FormControls', () => {
|
||||
const wrapper = shallow(<SaveQuery {...mockedProps} />);
|
||||
expect(wrapper.find(FormControl)).to.have.length(2);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user