refactor: Sync Scoping tree with Forms data (#12171)

* refactor: sync Scoping tree with Forms data

* refactor: update scoping tree

* refactor: update scope tree logic to be more UX friendly

* test: fix tests

* lint: fix lin CR notes

* fix: fix jsx

* refactor: revert type changes

* refactor: revert type changes

* lint: fix lint

* lint: fix lint

* test: fix test

* fix: process initial dashboard case

* lint: fix lint / tests
This commit is contained in:
simchaNielsen
2021-01-20 11:40:53 +02:00
committed by GitHub
parent a422c765c7
commit 2463215d73
10 changed files with 357 additions and 98 deletions

View File

@@ -21,20 +21,40 @@ import { Provider } from 'react-redux';
import ScopingTree from 'src/dashboard/components/nativeFilters/ScopingTree';
import { styledMount as mount } from 'spec/helpers/theming';
import { mockStore } from 'spec/fixtures/mockStore';
import { FormInstance } from 'src/common/components';
import { NativeFiltersForm } from 'src/dashboard/components/nativeFilters/types';
import { getDefaultScopeValue } from 'src/dashboard/components/nativeFilters/FilterScope';
describe('ScopingTree', () => {
const mock = jest.fn();
const filterId = '1';
const form = {
getFieldValue: () => ({
[filterId]: {
scope: getDefaultScopeValue(),
},
}),
};
const wrapper = mount(
<Provider store={mockStore}>
<ScopingTree setFilterScope={mock} />
<ScopingTree
filterId={filterId}
initialScope={getDefaultScopeValue()}
form={(form as unknown) as FormInstance<NativeFiltersForm>}
/>
</Provider>,
);
it('is valid', () => {
const mock = () => null;
expect(React.isValidElement(<ScopingTree setFilterScope={mock} />)).toBe(
true,
);
expect(
React.isValidElement(
<ScopingTree
filterId={filterId}
initialScope={getDefaultScopeValue()}
form={(form as unknown) as FormInstance<NativeFiltersForm>}
/>,
),
).toBe(true);
});
it('renders a tree', () => {
expect(wrapper.find('TreeNode')).toExist();
});