mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
Added time filter to query search page (#1329)
* Added time filter to query search page * Added start date * Updated python endpoint test * changed spec * Added specs and tests * Modified python/js tests and some function/file names based on code review comments * Resolved conflicts in DashboardSelect_spec and QuerySearch_spec * Break python tests for separate functions, Move sql queries to setUp() * Get around eslint error for spec * Small changes based on comments
This commit is contained in:
@@ -5,6 +5,7 @@ import QuerySearch from '../../../javascripts/SqlLab/components/QuerySearch';
|
||||
import { shallow } from 'enzyme';
|
||||
import { describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('QuerySearch', () => {
|
||||
const mockedProps = {
|
||||
@@ -15,19 +16,53 @@ describe('QuerySearch', () => {
|
||||
React.isValidElement(<QuerySearch {...mockedProps} />)
|
||||
).to.equal(true);
|
||||
});
|
||||
const wrapper = shallow(<QuerySearch {...mockedProps} />);
|
||||
|
||||
it('should have two Select', () => {
|
||||
const wrapper = shallow(<QuerySearch {...mockedProps} />);
|
||||
expect(wrapper.find(Select)).to.have.length(2);
|
||||
it('should have four Select', () => {
|
||||
expect(wrapper.find(Select)).to.have.length(4);
|
||||
});
|
||||
|
||||
it('updates userId on user selects change', () => {
|
||||
wrapper.find('[name="select-user"]')
|
||||
.simulate('change', { value: 1 });
|
||||
expect(wrapper.state().userId).to.equal(1);
|
||||
});
|
||||
|
||||
it('updates fromTime on user selects from time', () => {
|
||||
wrapper.find('[name="select-from"]')
|
||||
.simulate('change', { value: 0 });
|
||||
expect(wrapper.state().from).to.equal(0);
|
||||
});
|
||||
|
||||
it('updates toTime on user selects to time', () => {
|
||||
wrapper.find('[name="select-to"]')
|
||||
.simulate('change', { value: 0 });
|
||||
expect(wrapper.state().to).to.equal(0);
|
||||
});
|
||||
|
||||
it('updates status on user selects status', () => {
|
||||
wrapper.find('[name="select-status"]')
|
||||
.simulate('change', { value: 'success' });
|
||||
expect(wrapper.state().status).to.equal('success');
|
||||
});
|
||||
|
||||
it('should have one input for searchText', () => {
|
||||
const wrapper = shallow(<QuerySearch {...mockedProps} />);
|
||||
expect(wrapper.find('input')).to.have.length(1);
|
||||
});
|
||||
|
||||
it('updates search text on user inputs search text', () => {
|
||||
wrapper.find('input').simulate('change', { target: { value: 'text' } });
|
||||
expect(wrapper.state().searchText).to.equal('text');
|
||||
});
|
||||
|
||||
it('should have one Button', () => {
|
||||
const wrapper = shallow(<QuerySearch {...mockedProps} />);
|
||||
expect(wrapper.find(Button)).to.have.length(1);
|
||||
});
|
||||
|
||||
it('refreshes queries when clicked', () => {
|
||||
const search = sinon.spy(QuerySearch.prototype, 'refreshQueries');
|
||||
wrapper.find(Button).simulate('click');
|
||||
/* eslint-disable no-unused-expressions */
|
||||
expect(search).to.have.been.called;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user