[ES|QL] Cleanup the filters when transitioning from dataviews to ES|QL (#190477)

## Summary

Closes https://github.com/elastic/kibana/issues/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
This commit is contained in:
Stratoula Kalafateli 2024-08-14 13:21:39 +02:00 committed by GitHub
parent 54234a22b4
commit c026279547
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -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 () => {

View file

@ -383,6 +383,7 @@ export function getDiscoverStateContainer({
const queryString = getInitialESQLQuery(dataView);
appStateContainer.update({
query: { esql: queryString },
filters: [],
dataSource: {
type: DataSourceType.Esql,
},