mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Unified search] Fixes wrong negation label on the filter builder (#154216)
## Summary Closes https://github.com/elastic/kibana/issues/153608 Fixes the problem mentioned on the issue. When you edit a filter with negation to add another combined filter, then the negation was inherited by the first filter, which was not correct.  ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
16d8f404d8
commit
5436d6d007
3 changed files with 24 additions and 4 deletions
|
@ -510,7 +510,7 @@ class FilterEditorComponent extends Component<FilterEditorProps, State> {
|
|||
const alias = customLabel || null;
|
||||
const {
|
||||
$state,
|
||||
meta: { disabled = false, negate = false },
|
||||
meta: { disabled = false },
|
||||
} = this.props.filter;
|
||||
|
||||
if (!$state || !$state.store || !selectedDataView) {
|
||||
|
@ -533,12 +533,14 @@ class FilterEditorComponent extends Component<FilterEditorProps, State> {
|
|||
},
|
||||
};
|
||||
} else {
|
||||
// for the combined filters created on the builder, negate should always be false,
|
||||
// the global negation changes only from the exclude/inclue results panel item
|
||||
newFilter = buildCombinedFilter(
|
||||
BooleanRelation.AND,
|
||||
updatedFilters,
|
||||
selectedDataView,
|
||||
disabled,
|
||||
negate,
|
||||
false,
|
||||
alias,
|
||||
$state.store
|
||||
);
|
||||
|
|
|
@ -22,6 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const browser = getService('browser');
|
||||
|
||||
const PageObjects = getPageObjects(['common', 'context']);
|
||||
const testSubjects = getService('testSubjects');
|
||||
|
||||
describe('context filters', function contextSize() {
|
||||
beforeEach(async function () {
|
||||
|
@ -227,5 +228,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
|
||||
expect(await filterBar.getFilterEditorPreview()).to.equal('extension: is one of png, jpeg');
|
||||
});
|
||||
|
||||
it('should display the negated values correctly', async () => {
|
||||
await filterBar.addFilter({ field: 'extension', operation: 'is not', value: 'png' });
|
||||
|
||||
await PageObjects.context.waitUntilContextLoadingHasFinished();
|
||||
expect(await filterBar.getFilterCount()).to.be(1);
|
||||
const filterLabel = await filterBar.getFiltersLabel();
|
||||
expect(filterLabel[0]).to.be('NOT extension: png');
|
||||
|
||||
await filterBar.clickEditFilterById('0');
|
||||
await filterBar.addAndFilter('0');
|
||||
await filterBar.createFilter({ field: 'extension', operation: 'is', value: 'jpeg' }, '0.1');
|
||||
await testSubjects.clickWhenNotDisabled('saveFilter');
|
||||
|
||||
const filterLabelUpdated = await filterBar.getFiltersLabel();
|
||||
expect(filterLabelUpdated[0]).to.be('NOT extension: png AND extension: jpeg');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ export class FilterBarService extends FtrService {
|
|||
await addOrBtn.click();
|
||||
}
|
||||
|
||||
private async addAndFilter(path: string) {
|
||||
public async addAndFilter(path: string) {
|
||||
const filterForm = await this.testSubjects.find(`filter-${path}`);
|
||||
const addAndBtn = await filterForm.findByTestSubject('add-and-filter');
|
||||
await addAndBtn.click();
|
||||
|
@ -273,7 +273,7 @@ export class FilterBarService extends FtrService {
|
|||
return 'filters' in filter && 'condition' in filter;
|
||||
}
|
||||
|
||||
private async createFilter(filter: Filter, path: string = '0'): Promise<unknown> {
|
||||
public async createFilter(filter: Filter, path: string = '0'): Promise<unknown> {
|
||||
if (this.isFilterNode(filter)) {
|
||||
let startedAdding = false;
|
||||
for (const [index, f] of filter.filters.entries()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue