Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Modernized tests for Pane, Section, PositionedOverlay, SingleThumb, RangeSlider, and ConnectedFilter components ([#4429](https://github.com/Shopify/polaris-react/pull/4429))
- Modernized tests for ContextualSaveBar and DataTable and its subcomponents ([#4397](https://github.com/Shopify/polaris-react/pull/4397))
- Modernized tests for IndexTable, Indicator, InlineError, KeyboardKey, and KeypressListener components([#4431](https://github.com/Shopify/polaris-react/pull/4431))
- Modernized tests for Form and Filters components ([#4434](https://github.com/Shopify/polaris-react/pull/4434)).
- Modernized tests for Form and Filters components ([#4434](https://github.com/Shopify/polaris-react/pull/4434) and [#4458](https://github.com/Shopify/polaris-react/pull/4458))
- Modernized tests for OptionList and its subcomponents ([#4441](https://github.com/Shopify/polaris-react/pull/4441))
- Modernized tests for Modal ([#4433](https://github.com/Shopify/polaris-react/pull/4433))
- Modernized tests for Navigation and Navigation.Section ([#4440](https://github.com/Shopify/polaris-react/pull/4440))
Expand Down
30 changes: 13 additions & 17 deletions src/components/Filters/tests/Filters.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ import {
TextStyle,
ButtonProps,
} from 'components';
// eslint-disable-next-line no-restricted-imports
import {
findByTestID,
mountWithAppProvider,
trigger,
} from 'test-utilities/legacy';
import {mountWithApp} from 'test-utilities';

import {WithinFilterContext} from '../../../utilities/within-filter-context';
import {Filters, FiltersProps} from '../Filters';
import {ConnectedFilterControl, TagsWrapper} from '../components';
import {Collapsible} from '../../Collapsible';
import * as focusUtils from '../../../utilities/focus';
import styles from '../Filters.scss';

const MockFilter = (props: {id: string}) => <div id={props.id} />;
const MockChild = () => <div />;
Expand Down Expand Up @@ -346,20 +341,21 @@ describe('<Filters />', () => {
});

it('toggles a shortcut filter', () => {
const resourceFilters = mountWithAppProvider(
const resourceFilters = mountWithApp(
<Filters {...mockPropsWithShortcuts} />,
);

const connected = resourceFilters.find(ConnectedFilterControl).first();
connected.setState({availableWidth: 999});
const shortcut = findByTestID(resourceFilters, 'FilterShortcutContainer')
.find(Button)
.first();

trigger(shortcut, 'onClick');
expect(resourceFilters.find(Popover).first().props().active).toBe(true);
trigger(shortcut, 'onClick');
expect(resourceFilters.find(Popover).first().props().active).toBe(false);
const connected = resourceFilters.find(ConnectedFilterControl);
connected!.instance.setState({availableWidth: 999});
resourceFilters.forceUpdate();
const shortcut = resourceFilters
.find('div', {className: styles.RightContainer})!
.find(Button);

shortcut!.trigger('onClick');
expect(resourceFilters).toContainReactComponent(Popover, {active: true});
shortcut!.trigger('onClick');
expect(resourceFilters).toContainReactComponent(Popover, {active: false});
});

it('receives the expected props when there are no shortcut filters', () => {
Expand Down