Skip to content

Commit

Permalink
[ES|QL] Cleanup the filters when transitioning from dataviews to ES|QL (
Browse files Browse the repository at this point in the history
elastic#190477)

## Summary

Closes elastic#190459

Clean ups the filters when moving from DataViews to ES|QL mode.

### 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
  • Loading branch information
stratoula authored Aug 14, 2024
1 parent 54234a2 commit c026279
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,15 @@ describe('Test discover state actions', () => {
test('transitionFromDataViewToESQL', async () => {
const savedSearchWithQuery = copySavedSearch(savedSearchMock);
const query = { query: "foo: 'bar'", language: 'kuery' };
const filters = [{ meta: { index: 'the-data-view-id' }, query: { match_all: {} } }];
savedSearchWithQuery.searchSource.setField('query', query);
savedSearchWithQuery.searchSource.setField('filter', filters);
const { state } = await getState('/', { savedSearch: savedSearchWithQuery });
await state.actions.transitionFromDataViewToESQL(dataViewMock);
expect(state.appState.getState().query).toStrictEqual({
esql: 'FROM the-data-view-title | LIMIT 10',
});
expect(state.appState.getState().filters).toStrictEqual([]);
});

test('transitionFromESQLToDataView', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export function getDiscoverStateContainer({
const queryString = getInitialESQLQuery(dataView);
appStateContainer.update({
query: { esql: queryString },
filters: [],
dataSource: {
type: DataSourceType.Esql,
},
Expand Down

0 comments on commit c026279

Please sign in to comment.