mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
Avoid removing custom sql adhoc metric when columns change (#7877)
* Avoid removing custom sql adhoc metric when columns change * Add tests to confirm sql metric does not get removed
This commit is contained in:
@@ -333,5 +333,40 @@ describe('MetricsControl', () => {
|
||||
'SUM(',
|
||||
)).toBe(true);
|
||||
});
|
||||
|
||||
it('Removes metrics if savedMetrics changes', () => {
|
||||
const { props, wrapper, onChange } = setup({
|
||||
value: [
|
||||
{
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
column: { type: 'double', column_name: 'value' },
|
||||
aggregate: AGGREGATES.SUM,
|
||||
label: 'SUM(value)',
|
||||
optionName: 'blahblahblah',
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(wrapper.state('value')).toHaveLength(1);
|
||||
|
||||
wrapper.setProps({ ...props, columns: [] });
|
||||
expect(onChange.lastCall.args).toEqual([[]]);
|
||||
});
|
||||
|
||||
it('Does not remove custom sql metric if savedMetrics changes', () => {
|
||||
const { props, wrapper, onChange } = setup({
|
||||
value: [
|
||||
{
|
||||
expressionType: EXPRESSION_TYPES.SQL,
|
||||
sqlExpression: 'COUNT(*)',
|
||||
label: 'old label',
|
||||
hasCustomLabel: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(wrapper.state('value')).toHaveLength(1);
|
||||
|
||||
wrapper.setProps({ ...props, columns: [] });
|
||||
expect(onChange.calledOnce).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user