[8.8] [Security Solution][Investigations] - Fix flaky timeline (+) test (#157856) (#158071)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Security Solution][Investigations] - Fix flaky timeline (+) test
(#157856)](https://github.com/elastic/kibana/pull/157856)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"michael.olorunnisola@elastic.co"},"sourceCommit":{"committedDate":"2023-05-18T00:12:05Z","message":"[Security
Solution][Investigations] - Fix flaky timeline (+) test (#157856)\n\n##
Summary\r\n\r\nThis PR fixes the flaky
test\r\nhttps://github.com/elastic/kibana/issues/153771.\r\n\r\nIt was
run 30 Times locally in this
commit:\r\n075960ccd7f7df7beb21f8055fc681525f42f59f","sha":"fbd5ec0a5cd46808dc6418afc2f75d22c3ffe721","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:
SecuritySolution","Team:Threat
Hunting:Investigations","v8.8.0","v8.9.0"],"number":157856,"url":"https://github.com/elastic/kibana/pull/157856","mergeCommit":{"message":"[Security
Solution][Investigations] - Fix flaky timeline (+) test (#157856)\n\n##
Summary\r\n\r\nThis PR fixes the flaky
test\r\nhttps://github.com/elastic/kibana/issues/153771.\r\n\r\nIt was
run 30 Times locally in this
commit:\r\n075960ccd7f7df7beb21f8055fc681525f42f59f","sha":"fbd5ec0a5cd46808dc6418afc2f75d22c3ffe721"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157856","number":157856,"mergeCommit":{"message":"[Security
Solution][Investigations] - Fix flaky timeline (+) test (#157856)\n\n##
Summary\r\n\r\nThis PR fixes the flaky
test\r\nhttps://github.com/elastic/kibana/issues/153771.\r\n\r\nIt was
run 30 Times locally in this
commit:\r\n075960ccd7f7df7beb21f8055fc681525f42f59f","sha":"fbd5ec0a5cd46808dc6418afc2f75d22c3ffe721"}}]}]
BACKPORT-->
This commit is contained in:
Michael Olorunnisola 2023-05-18 09:16:37 -04:00 committed by GitHub
parent 99796ae901
commit d6f6c0ce54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View file

@ -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';
@ -20,6 +16,10 @@ import {
closeTimelineUsingToggle,
openTimelineUsingToggle,
} from '../../tasks/security_main';
import {
closeCreateTimelineOptionsPopover,
openCreateTimelineOptionsPopover,
} from '../../tasks/timeline';
import { HOSTS_URL } from '../../urls/navigation';
@ -61,13 +61,14 @@ describe('timeline flyout button', () => {
cy.get(TIMELINE_BOTTOM_BAR_TOGGLE_BUTTON).should('have.focus');
});
it('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}');
cy.get(CREATE_NEW_TIMELINE).should('not.be.visible');
closeCreateTimelineOptionsPopover();
cy.get(CREATE_NEW_TIMELINE).should('not.exist');
});
it('should render the global search dropdown when the input is focused', () => {

View file

@ -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();
};
@ -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);
};