Skip to content

Commit

Permalink
[SIEM] Fixes search bar Cypress test (#74833) (#75390)
Browse files Browse the repository at this point in the history
* fixes search bar test

* fixes typecheck issue

* fixes test

* uses data-test-subj locator instead of class

* fixes failing kibana tests

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
MadameSheema and elasticmachine authored Aug 19, 2020
1 parent 38bb67c commit 33a6d6d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { hostIpFilter } from '../objects/filter';
import { HOSTS_URL } from '../urls/navigation';
import { waitForAllHostsToBeLoaded } from '../tasks/hosts/all_hosts';

describe.skip('SearchBar', () => {
describe('SearchBar', () => {
before(() => {
loginAndWaitForPage(HOSTS_URL);
waitForAllHostsToBeLoaded();
Expand All @@ -21,6 +21,10 @@ describe.skip('SearchBar', () => {
it('adds correctly a filter to the global search bar', () => {
openAddFilterPopover();
fillAddFilterForm(hostIpFilter);
cy.get(GLOBAL_SEARCH_BAR_FILTER_ITEM(hostIpFilter)).should('be.visible');

cy.get(GLOBAL_SEARCH_BAR_FILTER_ITEM).should(
'have.text',
`${hostIpFilter.key}: ${hostIpFilter.value}`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SearchBarFilter } from '../objects/filter';

export const GLOBAL_SEARCH_BAR_ADD_FILTER =
'[data-test-subj="globalDatePicker"] [data-test-subj="addFilter"]';

Expand All @@ -28,5 +26,4 @@ export const ADD_FILTER_FORM_FILTER_VALUE_INPUT = '[data-test-subj="filterParams

export const ADD_FILTER_FORM_SAVE_BUTTON = '[data-test-subj="saveFilter"]';

export const GLOBAL_SEARCH_BAR_FILTER_ITEM = ({ key, value }: SearchBarFilter) =>
`[data-test-subj="filter filter-enabled filter-key-${key} filter-value-${value} filter-unpinned"]`;
export const GLOBAL_SEARCH_BAR_FILTER_ITEM = '#popoverFor_filter0';
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ export const openFirstHostDetails = () => {
};

export const waitForAllHostsToBeLoaded = () => {
cy.get(ALL_HOSTS_TABLE).should('exist');
cy.get(ALL_HOSTS_TABLE).should('be.visible');
};
4 changes: 3 additions & 1 deletion x-pack/plugins/security_solution/cypress/tasks/search_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {

export const openAddFilterPopover = () => {
cy.get(GLOBAL_SEARCH_BAR_SUBMIT_BUTTON).should('be.enabled');
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).click({ force: true });
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).should('be.visible');
cy.get(GLOBAL_SEARCH_BAR_ADD_FILTER).click();
};

export const fillAddFilterForm = ({ key, value }: SearchBarFilter) => {
Expand All @@ -32,4 +33,5 @@ export const fillAddFilterForm = ({ key, value }: SearchBarFilter) => {
cy.get(ADD_FILTER_FORM_OPERATOR_OPTION_IS).click();
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');
};

0 comments on commit 33a6d6d

Please sign in to comment.