Skip to content

Commit

Permalink
Prevent showing filter on unfilterable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Roes committed Jun 24, 2021
1 parent 01a4860 commit 81f81fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
import React from 'react';
import { mountWithIntl } from '@kbn/test/jest';
import { findTestSubject } from '@elastic/eui/lib/test';
import { FilterInBtn, FilterOutBtn } from './discover_grid_cell_actions';
import { FilterInBtn, FilterOutBtn, buildCellActions } from './discover_grid_cell_actions';
import { DiscoverGridContext } from './discover_grid_context';

import { indexPatternMock } from '../../../__mocks__/index_pattern';
import { esHits } from '../../../__mocks__/es_hits';
import { EuiButton } from '@elastic/eui';
import { IndexPatternField } from 'src/plugins/data/common';

describe('Discover cell actions ', function () {
it('should not show cell actions for unfilterable fields', async () => {
expect(
buildCellActions({ name: 'foo', filterable: false } as IndexPatternField)
).toBeUndefined();
});

it('triggers filter function when FilterInBtn is clicked', async () => {
const contextMock = {
expanded: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const FilterOutBtn = ({
};

export function buildCellActions(field: IndexPatternField) {
if (!field.aggregatable && !field.searchable) {
if (!field.filterable) {
return undefined;
}

Expand Down

0 comments on commit 81f81fc

Please sign in to comment.