mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
chore(dashboard): Add ErrorBoudary for AdhocFilter components (#12352)
* Add ErrorBoudary for AdhocFilter components * Add tests * typo fix
This commit is contained in:
@@ -22,6 +22,7 @@ import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
import Button from 'src/components/Button';
|
||||
|
||||
import ErrorBoundary from 'src/components/ErrorBoundary';
|
||||
import Tabs from 'src/common/components/Tabs';
|
||||
import AdhocFilter, {
|
||||
EXPRESSION_TYPES,
|
||||
@@ -47,6 +48,14 @@ const sqlAdhocFilter = new AdhocFilter({
|
||||
clause: CLAUSES.WHERE,
|
||||
});
|
||||
|
||||
const faultyAdhocFilter = new AdhocFilter({
|
||||
expressionType: null,
|
||||
subject: null,
|
||||
operator: '>',
|
||||
comparator: '10',
|
||||
clause: CLAUSES.WHERE,
|
||||
});
|
||||
|
||||
const sumValueAdhocMetric = new AdhocMetric({
|
||||
expressionType: EXPRESSION_TYPES.SIMPLE,
|
||||
column: { type: 'VARCHAR(255)', column_name: 'source' },
|
||||
@@ -97,6 +106,14 @@ describe('AdhocFilterEditPopover', () => {
|
||||
expect(wrapper.find(AdhocFilterEditPopoverSqlTabContent)).toExist();
|
||||
});
|
||||
|
||||
it('renders simple and sql tabs with ErrorBoundary instead of content', () => {
|
||||
const { wrapper } = setup({ adhocFilter: faultyAdhocFilter });
|
||||
expect(wrapper.find(Tabs)).toExist();
|
||||
expect(wrapper.find(Tabs.TabPane)).toHaveLength(2);
|
||||
expect(wrapper.find(Button)).toHaveLength(2);
|
||||
expect(wrapper.find(ErrorBoundary)).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('overwrites the adhocFilter in state with onAdhocFilterChange', () => {
|
||||
const { wrapper } = setup();
|
||||
wrapper.instance().onAdhocFilterChange(sqlAdhocFilter);
|
||||
|
||||
Reference in New Issue
Block a user