From 906987c2860b53b91d449bc164957857adddc06a Mon Sep 17 00:00:00 2001 From: Maxim Palenov Date: Wed, 25 Oct 2023 11:24:32 +0200 Subject: [PATCH] [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) --- .../cypress/e2e/header/search_bar.cy.ts | 3 +-- .../alerts/detection_page_filters.cy.ts | 1 + .../cypress/objects/filter.ts | 3 ++- .../cypress/screens/search_bar.ts | 3 --- .../cypress/tasks/search_bar.ts | 13 +++++-------- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/header/search_bar.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/header/search_bar.cy.ts index 7600c8edd9bbd..203e966eef9ad 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/header/search_bar.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/header/search_bar.cy.ts @@ -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')); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/detection_page_filters.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/detection_page_filters.cy.ts index 0b0169da945b9..9231b73843b1c 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/detection_page_filters.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/detection_page_filters.cy.ts @@ -361,6 +361,7 @@ describe.skip(`Detections : Page Filters`, { tags: ['@ess', '@brokenInServerless openAddFilterPopover(); fillAddFilterForm({ key: 'kibana.alert.workflow_status', + operator: 'is', value: 'invalid', }); waitForPageFilters(); diff --git a/x-pack/test/security_solution_cypress/cypress/objects/filter.ts b/x-pack/test/security_solution_cypress/cypress/objects/filter.ts index 2ab271b795ca4..22df1394ff35c 100644 --- a/x-pack/test/security_solution_cypress/cypress/objects/filter.ts +++ b/x-pack/test/security_solution_cypress/cypress/objects/filter.ts @@ -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', }); diff --git a/x-pack/test/security_solution_cypress/cypress/screens/search_bar.ts b/x-pack/test/security_solution_cypress/cypress/screens/search_bar.ts index 4517f1e3b2632..36b3accb3e5a6 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/search_bar.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/search_bar.ts @@ -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"]'; diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts b/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts index 2d33ff2244571..3a4355cad2e7e 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/search_bar.ts @@ -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'); };