mirror of
https://github.com/apache/superset.git
synced 2024-09-07 06:17:45 -04:00
Add tests for FilterBar CascadeFilterControl (#13950)
This commit is contained in:
parent
7fb138381f
commit
c0888dc16d
@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
import React from 'react';
|
||||||
|
import { render, screen } from 'spec/helpers/testing-library';
|
||||||
|
import { mockStore } from 'spec/fixtures/mockStore';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import { nativeFiltersInfo } from 'spec/javascripts/dashboard/fixtures/mockNativeFilters';
|
||||||
|
import CascadeFilterControl, { CascadeFilterControlProps } from '.';
|
||||||
|
|
||||||
|
const mockedProps = {
|
||||||
|
filter: {
|
||||||
|
...nativeFiltersInfo.filters.DefaultsID,
|
||||||
|
cascadeChildren: [
|
||||||
|
{
|
||||||
|
...nativeFiltersInfo.filters.DefaultsID,
|
||||||
|
name: 'test child filter 1',
|
||||||
|
cascadeChildren: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...nativeFiltersInfo.filters.DefaultsID,
|
||||||
|
name: 'test child filter 2',
|
||||||
|
cascadeChildren: [
|
||||||
|
{
|
||||||
|
...nativeFiltersInfo.filters.DefaultsID,
|
||||||
|
name: 'test child of a child filter',
|
||||||
|
cascadeChildren: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
onFilterSelectionChange: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const setup = (props: CascadeFilterControlProps) => (
|
||||||
|
<Provider store={mockStore}>
|
||||||
|
<CascadeFilterControl {...props} />
|
||||||
|
</Provider>
|
||||||
|
);
|
||||||
|
|
||||||
|
test('should render', () => {
|
||||||
|
const { container } = render(setup(mockedProps));
|
||||||
|
expect(container).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the filter name', () => {
|
||||||
|
render(setup(mockedProps));
|
||||||
|
expect(screen.getByText('test')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the children filter names', () => {
|
||||||
|
render(setup(mockedProps));
|
||||||
|
expect(screen.getByText('test child filter 1')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('test child filter 2')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should render the child of a child filter name', () => {
|
||||||
|
render(setup(mockedProps));
|
||||||
|
expect(screen.getByText('test child of a child filter')).toBeInTheDocument();
|
||||||
|
});
|
@ -19,11 +19,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { styled, DataMask } from '@superset-ui/core';
|
import { styled, DataMask } from '@superset-ui/core';
|
||||||
import Icon from 'src/components/Icon';
|
import Icon from 'src/components/Icon';
|
||||||
import FilterControl from '../FilterControls/FilterControl';
|
import FilterControl from 'src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControl';
|
||||||
import { Filter } from '../../types';
|
import { CascadeFilter } from 'src/dashboard/components/nativeFilters/FilterBar/CascadeFilters/types';
|
||||||
import { CascadeFilter } from './types';
|
import { Filter } from 'src/dashboard/components/nativeFilters/types';
|
||||||
|
|
||||||
interface CascadeFilterControlProps {
|
export interface CascadeFilterControlProps {
|
||||||
filter: CascadeFilter;
|
filter: CascadeFilter;
|
||||||
directPathToChild?: string[];
|
directPathToChild?: string[];
|
||||||
onFilterSelectionChange: (filter: Filter, dataMask: DataMask) => void;
|
onFilterSelectionChange: (filter: Filter, dataMask: DataMask) => void;
|
@ -24,10 +24,10 @@ import { Pill } from 'src/dashboard/components/FiltersBadge/Styles';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { getInitialMask } from 'src/dataMask/reducer';
|
import { getInitialMask } from 'src/dataMask/reducer';
|
||||||
import { MaskWithId } from 'src/dataMask/types';
|
import { MaskWithId } from 'src/dataMask/types';
|
||||||
import FilterControl from '../FilterControls/FilterControl';
|
import FilterControl from 'src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControl';
|
||||||
import CascadeFilterControl from './CascadeFilterControl';
|
import CascadeFilterControl from 'src/dashboard/components/nativeFilters/FilterBar/CascadeFilters/CascadeFilterControl';
|
||||||
import { CascadeFilter } from './types';
|
import { CascadeFilter } from 'src/dashboard/components/nativeFilters/FilterBar/CascadeFilters/types';
|
||||||
import { Filter } from '../../types';
|
import { Filter } from 'src/dashboard/components/nativeFilters/types';
|
||||||
|
|
||||||
interface CascadePopoverProps {
|
interface CascadePopoverProps {
|
||||||
filter: CascadeFilter;
|
filter: CascadeFilter;
|
Loading…
Reference in New Issue
Block a user