[Security Solituon] Unskip search bar Serverless Cypress tests (#169347)

**Addreses:** https://github.com/elastic/kibana/issues/161540

## Summary

This PR unskips `search_bar.cy.ts` Serverless Cypress tests.

## Details

Besides just unskipping `search_bar.cy.ts` this PR also makes sure the test isn't flaky by making `operator` required in `fillAddFilterForm()`. It turned out the test works only if the Cypress window is in focus when an operator isn't set. Such behavior can lead to test flakiness in CI. This way choosing an operator via keyboard is a safer option.

## Flaky test runner

`search_bar.cy.ts` [150 runs](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3614)
This commit is contained in:
Maxim Palenov 2023-10-25 11:24:32 +02:00 committed by GitHub
parent c303263344
commit 906987c286
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 14 deletions

View file

@ -23,8 +23,7 @@ import { getHostIpFilter } from '../../objects/filter';
import { hostsUrl } from '../../urls/navigation';
import { waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts';
// FLAKY: https://github.com/elastic/kibana/issues/165637
describe('SearchBar', { tags: ['@ess', '@serverless', '@brokenInServerless'] }, () => {
describe('SearchBar', { tags: ['@ess', '@serverless'] }, () => {
beforeEach(() => {
login();
visit(hostsUrl('allHosts'));

View file

@ -361,6 +361,7 @@ describe.skip(`Detections : Page Filters`, { tags: ['@ess', '@brokenInServerless
openAddFilterPopover();
fillAddFilterForm({
key: 'kibana.alert.workflow_status',
operator: 'is',
value: 'invalid',
});
waitForPageFilters();

View file

@ -7,11 +7,12 @@
export interface SearchBarFilter {
key: string;
operator: 'is' | 'is not' | 'is one of' | 'is not one of' | 'exists' | 'does not exist';
value?: string;
operator?: 'is' | 'is not' | 'is one of' | 'is not one of' | 'exists' | 'does not exist';
}
export const getHostIpFilter = (): SearchBarFilter => ({
key: 'host.ip',
operator: 'is',
value: '1.1.1.1',
});

View file

@ -26,9 +26,6 @@ export const ADD_FILTER_FORM_FIELD_OPTION = (value: string) =>
export const ADD_FILTER_FORM_OPERATOR_FIELD =
'[data-test-subj="filterOperatorList"] input[data-test-subj="comboBoxSearchInput"]';
export const ADD_FILTER_FORM_OPERATOR_OPTION_IS =
'[data-test-subj="comboBoxOptionsList filterOperatorList-optionsList"] button[title="is"]';
export const ADD_FILTER_FORM_FILTER_VALUE_INPUT = '[data-test-subj="filterParams"] input';
export const ADD_FILTER_FORM_SAVE_BUTTON = '[data-test-subj="saveFilter"]';

View file

@ -13,7 +13,6 @@ import {
GLOBAL_SEARCH_BAR_SUBMIT_BUTTON,
ADD_FILTER_FORM_SAVE_BUTTON,
ADD_FILTER_FORM_FIELD_INPUT,
ADD_FILTER_FORM_OPERATOR_OPTION_IS,
ADD_FILTER_FORM_OPERATOR_FIELD,
ADD_FILTER_FORM_FILTER_VALUE_INPUT,
GLOBAL_KQL_INPUT,
@ -53,19 +52,17 @@ export const removeKqlFilter = () => {
});
};
export const fillAddFilterForm = ({ key, value, operator }: SearchBarFilter) => {
export const fillAddFilterForm = ({ key, operator, value }: SearchBarFilter) => {
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('exist');
cy.get(ADD_FILTER_FORM_FIELD_INPUT).should('be.visible');
cy.get(ADD_FILTER_FORM_FIELD_INPUT).type(`${key}{downarrow}{enter}`);
if (!operator) {
cy.get(ADD_FILTER_FORM_OPERATOR_FIELD).click();
cy.get(ADD_FILTER_FORM_OPERATOR_OPTION_IS).click();
} else {
cy.get(ADD_FILTER_FORM_OPERATOR_FIELD).type(`${operator}{enter}`);
}
cy.get(ADD_FILTER_FORM_OPERATOR_FIELD).type(`${operator}{downarrow}{enter}`);
if (value) {
cy.get(ADD_FILTER_FORM_FILTER_VALUE_INPUT).type(value);
}
cy.get(ADD_FILTER_FORM_SAVE_BUTTON).click();
cy.get(ADD_FILTER_FORM_SAVE_BUTTON).should('not.exist');
};