Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkancso committed Dec 20, 2024
1 parent 88e9d95 commit f8370fd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/scenes/src/variables/adhoc/AdHocFiltersVariable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@ describe.each(['11.1.2', '11.1.1'])('AdHocFiltersVariable', (v) => {
});
});

it('does not render hidden filter in url', () => {
const { filtersVar } = setup();

act(() => {
filtersVar._updateFilter(filtersVar.state.filters[0], { hidden: true });
});

expect(locationService.getLocation().search).toBe('?var-filters=key2%7C%3D%7Cval2');
});

it('overrides state when url has empty key', () => {
const { filtersVar } = setup();

Expand Down Expand Up @@ -1047,6 +1057,23 @@ describe.each(['11.1.2', '11.1.1'])('AdHocFiltersVariable', (v) => {
expect(await screen.findByText('key2 = val2')).toBeInTheDocument();
});

it('does not display hidden filters', async () => {
act(() => {
const { filtersVar } = setup();

filtersVar.setState({
filters: [
...filtersVar.state.filters,
{ key: 'hidden_key', operator: '=', value: 'hidden_val', hidden: true },
],
});
});

expect(await screen.findByText('key1 = val1')).toBeInTheDocument();
expect(await screen.findByText('key2 = val2')).toBeInTheDocument();
expect(await screen.queryAllByText('hidden_key = hidden_val')).toEqual([]);
});

it('focusing the input opens the key dropdown', async () => {
await userEvent.click(screen.getByRole('combobox'));

Expand Down

0 comments on commit f8370fd

Please sign in to comment.