Skip to content

Commit

Permalink
[Security Solituon] Unskip search bar Serverless Cypress tests (elast…
Browse files Browse the repository at this point in the history
…ic#169347)

**Addreses:** elastic#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)
  • Loading branch information
maximpn authored Oct 25, 2023
1 parent c303263 commit 906987c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ describe.skip(`Detections : Page Filters`, { tags: ['@ess', '@brokenInServerless
openAddFilterPopover();
fillAddFilterForm({
key: 'kibana.alert.workflow_status',
operator: 'is',
value: 'invalid',
});
waitForPageFilters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Original file line number Diff line number Diff line change
Expand Up @@ -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"]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
};
Expand Down

0 comments on commit 906987c

Please sign in to comment.