Skip to content

Commit

Permalink
[Security Solution][Investigations] - Fix flaky timeline (+) test (#1…
Browse files Browse the repository at this point in the history
…57856)

## Summary

This PR fixes the flaky test
#153771.

It was run 30 Times locally in this commit:
075960ccd7f7df7beb21f8055fc681525f42f59f
  • Loading branch information
michaelolo24 authored May 18, 2023
1 parent e854907 commit fbd5ec0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
*/

import { TIMELINE_BOTTOM_BAR_TOGGLE_BUTTON } from '../../screens/security_main';
import {
CREATE_NEW_TIMELINE,
TIMELINE_FLYOUT_HEADER,
TIMELINE_SETTINGS_ICON,
} from '../../screens/timeline';
import { CREATE_NEW_TIMELINE, TIMELINE_FLYOUT_HEADER } from '../../screens/timeline';
import { cleanKibana } from '../../tasks/common';

import { waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts';
Expand All @@ -20,6 +16,10 @@ import {
closeTimelineUsingToggle,
openTimelineUsingToggle,
} from '../../tasks/security_main';
import {
closeCreateTimelineOptionsPopover,
openCreateTimelineOptionsPopover,
} from '../../tasks/timeline';

import { HOSTS_URL } from '../../urls/navigation';

Expand Down Expand Up @@ -61,13 +61,13 @@ describe('timeline flyout button', () => {
cy.get(TIMELINE_BOTTOM_BAR_TOGGLE_BUTTON).should('have.focus');
});

// FLAKY: https://github.com/elastic/kibana/issues/153771
it.skip('the `(+)` button popover menu owns focus', () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
it('the `(+)` button popover menu owns focus when open', () => {
openCreateTimelineOptionsPopover();
cy.get(`${CREATE_NEW_TIMELINE}`)
.should('be.visible')
.pipe(($el) => $el.trigger('focus'))
.should('have.focus');
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').type('{esc}');
closeCreateTimelineOptionsPopover();
cy.get(CREATE_NEW_TIMELINE).should('not.exist');
});

Expand Down
13 changes: 10 additions & 3 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,16 @@ export const createNewTimeline = () => {
.pipe(($el) => $el.trigger('click'));
};

export const openCreateTimelineOptionsPopover = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').should('be.visible').click();
};

export const closeCreateTimelineOptionsPopover = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').should('be.visible').type('{esc}');
};

export const createNewTimelineTemplate = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
openCreateTimelineOptionsPopover();
cy.get(CREATE_NEW_TIMELINE_TEMPLATE).click();
};

Expand Down Expand Up @@ -355,8 +363,7 @@ export const openTimelineInspectButton = () => {

export const openTimelineFromSettings = () => {
const click = ($el: Cypress.ObjectLike) => cy.wrap($el).click();
cy.get(TIMELINE_SETTINGS_ICON).should('be.visible');
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').pipe(click);
openCreateTimelineOptionsPopover();
cy.get(OPEN_TIMELINE_ICON).should('be.visible');
cy.get(OPEN_TIMELINE_ICON).pipe(click);
};
Expand Down

0 comments on commit fbd5ec0

Please sign in to comment.