mirror of
https://github.com/apache/superset.git
synced 2026-04-12 12:47:53 +00:00
fix: [filter_box] fix 2 issues in single value filter_box (#9829)
* fix: [filter_box] fix 2 issues in single value filter_box * add unit test * add fix per comments
This commit is contained in:
@@ -52,4 +52,53 @@ describe('FilterBoxItemControl', () => {
|
||||
const popover = shallow(inst.renderForm());
|
||||
expect(popover.find(FormRow)).toHaveLength(7);
|
||||
});
|
||||
|
||||
it('convert type for single value filter_box', () => {
|
||||
inst = getWrapper({
|
||||
datasource: {
|
||||
columns: [
|
||||
{
|
||||
column_name: 'SP_POP_TOTL',
|
||||
description: null,
|
||||
expression: null,
|
||||
filterable: true,
|
||||
groupby: true,
|
||||
id: 312,
|
||||
is_dttm: false,
|
||||
type: 'FLOAT',
|
||||
verbose_name: null,
|
||||
},
|
||||
],
|
||||
metrics: [
|
||||
{
|
||||
d3format: null,
|
||||
description: null,
|
||||
expression: 'sum("SP_POP_TOTL")',
|
||||
id: 3,
|
||||
metric_name: 'sum__SP_POP_TOTL',
|
||||
verbose_name: null,
|
||||
warning_text: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
}).instance();
|
||||
inst.setState({
|
||||
asc: true,
|
||||
clearable: true,
|
||||
column: 'SP_POP_TOTL',
|
||||
defaultValue: 254454778,
|
||||
metric: undefined,
|
||||
multiple: false,
|
||||
});
|
||||
inst.setState = sinon.spy();
|
||||
|
||||
inst.onControlChange('defaultValue', '1');
|
||||
expect(inst.setState.callCount).toBe(1);
|
||||
expect(inst.setState.getCall(0).args[0]).toEqual({ defaultValue: 1 });
|
||||
|
||||
// user input is invalid for number type column
|
||||
inst.onControlChange('defaultValue', 'abc');
|
||||
expect(inst.setState.callCount).toBe(2);
|
||||
expect(inst.setState.getCall(1).args[0]).toEqual({ defaultValue: null });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user