Skip to content

Commit

Permalink
[Security Solution] Update the script of data provider's Cypress test (
Browse files Browse the repository at this point in the history
…#93780) (#93951)

* rollback timeout for dnd and rewrite script for the failing case

* rollback timeout for dnd and rewrite script for the failing case

* rollback timeout for dnd and rewrite script for the failing case

* rollback unnecessary change

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

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
angorayc and kibanamachine authored Mar 8, 2021
1 parent 93142f3 commit a5c1197
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

import { loginAndWaitForPage } from '../../tasks/login';
import { openTimelineUsingToggle } from '../../tasks/security_main';
import { closeTimeline, createNewTimeline } from '../../tasks/timeline';
import { addDataProvider, closeTimeline, createNewTimeline } from '../../tasks/timeline';

import { HOSTS_URL } from '../../urls/navigation';
import { cleanKibana } from '../../tasks/common';
Expand Down Expand Up @@ -56,20 +56,22 @@ describe('timeline data providers', () => {
});
});

it('displays the data provider action menu when Enter is pressed', () => {
dragAndDropFirstHostToTimeline();
it('displays the data provider action menu when Enter is pressed', (done) => {
openTimelineUsingToggle();
cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('not.exist');
addDataProvider({ field: 'host.name', operator: 'exists' }).then(() => {
cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('not.exist');

cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.pipe(($el) => $el.trigger('focus'))
.should('exist');
cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.first()
.parent()
.type('{enter}');
cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.pipe(($el) => $el.trigger('focus'))
.should('exist');
cy.get(`${TIMELINE_FLYOUT_HEADER} ${TIMELINE_DROPPED_DATA_PROVIDERS}`)
.first()
.parent()
.type('{enter}');

cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist');
cy.get(TIMELINE_DATA_PROVIDERS_ACTION_MENU).should('exist');
done();
});
});

it('sets the background to euiColorSuccess with a 10% alpha channel when the user starts dragging a host, but is not hovering over the data providers', () => {
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ export const TIMELINE_DATA_PROVIDERS_ACTION_MENU = '[data-test-subj="providerAct

export const TIMELINE_ADD_FIELD_BUTTON = '[data-test-subj="addField"]';

export const TIMELINE_DATA_PROVIDER_FIELD = '[data-test-subj="field"]';

export const TIMELINE_DATA_PROVIDER_OPERATOR = `[data-test-subj="operator"]`;

export const TIMELINE_DATA_PROVIDER_VALUE = `[data-test-subj="value"]`;

export const SAVE_DATA_PROVIDER_BTN = `[data-test-subj="save"]`;

export const TIMELINE_DATA_PROVIDERS_EMPTY =
'[data-test-subj="dataProviders"] [data-test-subj="empty"]';

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/security_solution/cypress/tasks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export const drag = (subject: JQuery<HTMLElement>) => {
clientY: subjectLocation.top,
force: true,
})
.wait(3000)
.wait(300)
.trigger('mousemove', {
button: primaryButton,
clientX: subjectLocation.left + dndSloppyClickDetectionThreshold,
clientY: subjectLocation.top,
force: true,
})
.wait(3000);
.wait(300);
};

/** Drags the subject being dragged on the specified drop target, but does not drop it */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*/

import { ALL_HOSTS_TABLE, HOSTS_NAMES_DRAGGABLE, HOSTS_NAMES } from '../../screens/hosts/all_hosts';
import { TIMELINE_ADD_FIELD_BUTTON, TIMELINE_DATA_PROVIDERS_EMPTY } from '../../screens/timeline';
import { TIMELINE_DATA_PROVIDERS, TIMELINE_DATA_PROVIDERS_EMPTY } from '../../screens/timeline';

import { drag, dragWithoutDrop, drop } from '../../tasks/common';

export const dragAndDropFirstHostToTimeline = () => {
cy.get(HOSTS_NAMES_DRAGGABLE)
.first()
.then((firstHost) => drag(firstHost));
cy.get(TIMELINE_ADD_FIELD_BUTTON)
cy.get(TIMELINE_DATA_PROVIDERS)
.filter(':visible')
.then((dataProvidersDropArea) => drop(dataProvidersDropArea));
};
Expand Down
26 changes: 23 additions & 3 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ import {
TIMELINE_EDIT_MODAL_SAVE_BUTTON,
QUERY_TAB_BUTTON,
CLOSE_OPEN_TIMELINE_MODAL_BTN,
TIMELINE_ADD_FIELD_BUTTON,
TIMELINE_DATA_PROVIDER_FIELD,
TIMELINE_DATA_PROVIDER_OPERATOR,
TIMELINE_DATA_PROVIDER_VALUE,
SAVE_DATA_PROVIDER_BTN,
} from '../screens/timeline';
import { TIMELINES_TABLE } from '../screens/timelines';

Expand Down Expand Up @@ -114,6 +119,17 @@ export const addFilter = (filter: TimelineFilter) => {
cy.get(SAVE_FILTER_BTN).click();
};

export const addDataProvider = (filter: TimelineFilter) => {
cy.get(TIMELINE_ADD_FIELD_BUTTON).click();
cy.get(TIMELINE_DATA_PROVIDER_FIELD).type(`${filter.field}{downarrow}{enter}`);
cy.get(TIMELINE_DATA_PROVIDER_OPERATOR).type(filter.operator);
cy.get(COMBO_BOX).contains(filter.operator).click();
if (filter.operator !== 'exists') {
cy.get(TIMELINE_DATA_PROVIDER_VALUE).type(`${filter.value}{enter}`);
}
return cy.get(SAVE_DATA_PROVIDER_BTN).click();
};

export const addNewCase = () => {
cy.get(ALL_CASES_CREATE_NEW_CASE_TABLE_BTN).click();
};
Expand Down Expand Up @@ -145,9 +161,13 @@ export const closeTimeline = () => {
};

export const createNewTimeline = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
cy.get(CREATE_NEW_TIMELINE).should('be.visible');
cy.get(CREATE_NEW_TIMELINE).click();
cy.get(TIMELINE_SETTINGS_ICON)
.filter(':visible')
.click({ force: true })
.then(() => {
cy.get(CREATE_NEW_TIMELINE).should('be.visible');
cy.get(CREATE_NEW_TIMELINE).click();
});
};

export const createNewTimelineTemplate = () => {
Expand Down

0 comments on commit a5c1197

Please sign in to comment.