1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-27 00:19:39 +01:00

test: filter selection avoid duplicates (#5636)

This commit is contained in:
Mateusz Kwasniewski 2023-12-13 15:57:49 +01:00 committed by GitHub
parent d00d27a9ac
commit adb9ba5c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,3 +81,41 @@ test('should keep filters order when adding a new filter', async () => {
expect(filterTexts).toEqual(['Tags', 'State']);
});
test('should remove selected item from the add filter list', async () => {
const availableFilters: IFilterItem[] = [
{
label: 'State',
options: [],
filterKey: 'irrelevantKey',
singularOperators: ['IRRELEVANT'],
pluralOperators: ['IRRELEVANT'],
},
{
label: 'Tags',
options: [],
filterKey: 'irrelevantKey',
singularOperators: ['IRRELEVANT'],
pluralOperators: ['IRRELEVANT'],
},
];
render(
<Filters
availableFilters={availableFilters}
onChange={() => {}}
state={{}}
/>,
);
// initial selection list
const addFilterButton = screen.getByText('Add Filter');
addFilterButton.click();
expect(screen.getByRole('menu').textContent).toBe('StateTags');
screen.getByText('State').click();
// reduced selection list
addFilterButton.click();
expect(screen.getByRole('menu').textContent).toBe('Tags');
});