[Security Solution] Update the script of data provider's Cypress test (#93780)

* 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 <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Angela Chuang 2021-03-08 14:50:44 +00:00 committed by GitHub
parent faae074607
commit 98c1f94477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 19 deletions

View file

@ -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';
@ -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', () => {

View file

@ -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"]';

View file

@ -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 */

View file

@ -6,7 +6,7 @@
*/
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';
@ -14,7 +14,7 @@ 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));
};

View file

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