mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fixes auto suggest in security solution (#145924)
This commit is contained in:
parent
48adb0c467
commit
3a6825cf47
4 changed files with 38 additions and 8 deletions
|
@ -31,11 +31,7 @@ import { compact, debounce, isEmpty, isEqual, isFunction, partition } from 'loda
|
|||
import { CoreStart, DocLinksStart, Toast } from '@kbn/core/public';
|
||||
import type { Query } from '@kbn/es-query';
|
||||
import { DataPublicPluginStart, getQueryLog } from '@kbn/data-plugin/public';
|
||||
import {
|
||||
type DataView,
|
||||
DataView as KibanaDataView,
|
||||
DataViewsPublicPluginStart,
|
||||
} from '@kbn/data-views-plugin/public';
|
||||
import { type DataView, DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
import type { PersistedLog } from '@kbn/data-plugin/public';
|
||||
import { getFieldSubtypeNested, KIBANA_USER_QUERY_LANGUAGE_KEY } from '@kbn/data-plugin/common';
|
||||
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -188,7 +184,7 @@ export default class QueryStringInputUI extends PureComponent<QueryStringInputPr
|
|||
QueryStringInputProps['indexPatterns'][number],
|
||||
DataView
|
||||
>(this.props.indexPatterns || [], (indexPattern): indexPattern is DataView => {
|
||||
return indexPattern instanceof KibanaDataView;
|
||||
return indexPattern.hasOwnProperty('fields') && indexPattern.hasOwnProperty('title');
|
||||
});
|
||||
const idOrTitlePatterns = stringPatterns.map((sp) =>
|
||||
typeof sp === 'string' ? { type: 'title', value: sp } : sp
|
||||
|
|
|
@ -6,8 +6,17 @@
|
|||
*/
|
||||
|
||||
import { login, visit } from '../../tasks/login';
|
||||
import { openAddFilterPopover, fillAddFilterForm } from '../../tasks/search_bar';
|
||||
import { GLOBAL_SEARCH_BAR_FILTER_ITEM } from '../../screens/search_bar';
|
||||
import {
|
||||
openAddFilterPopover,
|
||||
fillAddFilterForm,
|
||||
openKqlQueryBar,
|
||||
fillKqlQueryBar,
|
||||
} from '../../tasks/search_bar';
|
||||
import {
|
||||
AUTO_SUGGEST_AGENT_NAME,
|
||||
AUTO_SUGGEST_HOST_NAME_VALUE,
|
||||
GLOBAL_SEARCH_BAR_FILTER_ITEM,
|
||||
} from '../../screens/search_bar';
|
||||
import { getHostIpFilter } from '../../objects/filter';
|
||||
|
||||
import { HOSTS_URL } from '../../urls/navigation';
|
||||
|
@ -29,4 +38,11 @@ describe('SearchBar', () => {
|
|||
`${getHostIpFilter().key}: ${getHostIpFilter().value}`
|
||||
);
|
||||
});
|
||||
|
||||
it('auto suggests fields from the data view and auto completes available field values', () => {
|
||||
openKqlQueryBar();
|
||||
cy.get(AUTO_SUGGEST_AGENT_NAME).should('be.visible');
|
||||
fillKqlQueryBar(`host.name:`);
|
||||
cy.get(AUTO_SUGGEST_HOST_NAME_VALUE).should('be.visible');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,3 +32,10 @@ export const GLOBAL_SEARCH_BAR_FILTER_ITEM = '#popoverFor_filter0';
|
|||
export const GLOBAL_SEARCH_BAR_FILTER_ITEM_AT = (value: number) => `#popoverFor_filter${value}`;
|
||||
|
||||
export const GLOBAL_SEARCH_BAR_PINNED_FILTER = '.globalFilterItem-isPinned';
|
||||
|
||||
export const GLOBAL_KQL_INPUT =
|
||||
'[data-test-subj="filters-global-container"] [data-test-subj="unifiedQueryInput"] textarea';
|
||||
|
||||
export const AUTO_SUGGEST_AGENT_NAME = `[data-test-subj="autocompleteSuggestion-field-agent.name-"]`;
|
||||
|
||||
export const AUTO_SUGGEST_HOST_NAME_VALUE = `[data-test-subj='autocompleteSuggestion-value-"siem-kibana"-']`;
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
ADD_FILTER_FORM_OPERATOR_FIELD,
|
||||
ADD_FILTER_FORM_FIELD_OPTION,
|
||||
ADD_FILTER_FORM_FILTER_VALUE_INPUT,
|
||||
GLOBAL_KQL_INPUT,
|
||||
} from '../screens/search_bar';
|
||||
|
||||
export const openAddFilterPopover = () => {
|
||||
|
@ -24,6 +25,16 @@ export const openAddFilterPopover = () => {
|
|||
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).click();
|
||||
};
|
||||
|
||||
export const openKqlQueryBar = () => {
|
||||
cy.get(GLOBAL_KQL_INPUT).should('be.visible');
|
||||
cy.get(GLOBAL_KQL_INPUT).click();
|
||||
};
|
||||
|
||||
export const fillKqlQueryBar = (query: string) => {
|
||||
cy.get(GLOBAL_KQL_INPUT).should('be.visible');
|
||||
cy.get(GLOBAL_KQL_INPUT).type(query);
|
||||
};
|
||||
|
||||
export const fillAddFilterForm = ({ key, value, operator }: SearchBarFilter) => {
|
||||
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('exist');
|
||||
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('be.visible');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue