Dashboard filter box default (#6236)

* Setting default FilterBox date filter to No Filter

* Adding test for FilterBox
This commit is contained in:
michellethomas 2018-11-01 09:43:04 -07:00 committed by GitHub
parent 59109f62b4
commit d34217ef97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,25 @@
import { FORM_DATA_DEFAULTS } from './shared.helper';
export default () => describe('FilterBox', () => {
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'filter_box' };
function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.verifySliceSuccess({ waitAlias: '@getJson' });
}
beforeEach(() => {
cy.server();
cy.login();
cy.route('POST', '/superset/explore_json/**').as('getJson');
});
it('should work with default date filter', () => {
verify(VIZ_DEFAULTS);
// Filter box should default to having a date filter with no filter selected
cy.get('div.filter_box').within(() => {
cy.get('span').contains('No filter');
});
});
});

View File

@ -5,6 +5,7 @@ import BubbleTest from './bubble';
import CompareTest from './compare';
import DistBarTest from './dist_bar';
import DualLineTest from './dual_line';
import FilterBox from './filter_box';
import HistogramTest from './histogram';
import LineTest from './line';
import PieTest from './pie';
@ -23,6 +24,7 @@ describe('All Visualizations', () => {
CompareTest();
DistBarTest();
DualLineTest();
FilterBox();
HistogramTest();
LineTest();
PieTest();

View File

@ -123,7 +123,7 @@ class FilterBox extends React.Component {
label={t('Time range')}
description={t('Select start and end date')}
onChange={(...args) => { this.changeFilter(TIME_RANGE, ...args); }}
value={this.state.selectedValues[TIME_RANGE]}
value={this.state.selectedValues[TIME_RANGE] || 'No filter'}
/>
</div>
</div>