Skip to content

Commit

Permalink
fix issue were operators do not appear properly in adhocs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvictor committed Feb 13, 2025
1 parent 55cb8a4 commit 33f376f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/scenes/src/variables/adhoc/AdHocFiltersVariable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,26 @@ describe.each(['11.1.2', '11.1.1'])('AdHocFiltersVariable', (v) => {
});

describe('operators', () => {
it('shows the regex operators when allowCustomValue is undefined', async () => {
setup();

const middleKeySelect = screen.getAllByRole('combobox')[1];
await userEvent.click(middleKeySelect);

expect(screen.getByRole('listbox')).toBeInTheDocument();

const options = screen.getAllByRole('option').map((option) => option.textContent?.trim());

expect(options).toEqual([
'=Equals',
'!=Not equal',
'=~Matches regex',
'!~Does not match regex',
'<Less than',
'>Greater than',
]);
});

it('shows the regex operators when allowCustomValue is set true', async () => {
setup({
allowCustomValue: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class AdHocFiltersVariable
}

public _getOperators() {
const { supportsMultiValueOperators, allowCustomValue } = this.state;
const { supportsMultiValueOperators, allowCustomValue = true } = this.state;

return OPERATORS.filter(({ isMulti, isRegex }) => {
if (!supportsMultiValueOperators && isMulti) {
Expand Down

0 comments on commit 33f376f

Please sign in to comment.