Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Fix EventsViewer DnD cypress tests #82619

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ describe('Events Viewer', () => {
});
});

context.skip('Events columns', () => {
context('Events columns', () => {
before(() => {
loginAndWaitForPage(HOSTS_URL);
openEvents();
cy.scrollTo('bottom');
waitsForEventsToBeLoaded();
});

Expand All @@ -160,9 +161,8 @@ describe('Events Viewer', () => {
const expectedOrderAfterDragAndDrop =
'message@timestamphost.nameevent.moduleevent.datasetevent.actionuser.namesource.ipdestination.ip';

cy.scrollTo('bottom');
cy.get(HEADERS_GROUP).invoke('text').should('equal', originalColumnOrder);
dragAndDropColumn({ column: 0, newPosition: 1 });
dragAndDropColumn({ column: 0, newPosition: 0 });
cy.get(HEADERS_GROUP).invoke('text').should('equal', expectedOrderAfterDragAndDrop);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ export const LOAD_MORE =
'[data-test-subj="events-viewer-panel"] [data-test-subj="TimelineMoreButton"';

export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]';

export const EVENTS_VIEWER_PAGINATION =
'[data-test-subj="events-viewer-panel"] [data-test-subj="timeline-pagination"]';
16 changes: 11 additions & 5 deletions x-pack/plugins/security_solution/cypress/tasks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,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 All @@ -42,11 +42,17 @@ export const dragWithoutDrop = (dropTarget: JQuery<HTMLElement>) => {

/** "Drops" the subject being dragged on the specified drop target */
export const drop = (dropTarget: JQuery<HTMLElement>) => {
const targetLocation = dropTarget[0].getBoundingClientRect();
cy.wrap(dropTarget)
.trigger('mousemove', { button: primaryButton, force: true })
.wait(3000)
.trigger('mousemove', {
button: primaryButton,
clientX: targetLocation.left,
clientY: targetLocation.top,
force: true,
})
.wait(300)
.trigger('mouseup', { force: true })
.wait(3000);
.wait(300);
};

export const reload = (afterReload: () => void) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { drag, drop } from '../common';
import {
CLOSE_MODAL,
EVENTS_VIEWER_FIELDS_BUTTON,
EVENTS_VIEWER_PAGINATION,
FIELDS_BROWSER_CONTAINER,
HOST_GEO_CITY_NAME_CHECKBOX,
HOST_GEO_COUNTRY_NAME_CHECKBOX,
Expand All @@ -16,6 +17,7 @@ import {
SERVER_SIDE_EVENT_COUNT,
} from '../../screens/hosts/events';
import { DRAGGABLE_HEADER } from '../../screens/timeline';
import { REFRESH_BUTTON } from '../../screens/security_header';

export const addsHostGeoCityNameToHeader = () => {
cy.get(HOST_GEO_CITY_NAME_CHECKBOX).check({
Expand Down Expand Up @@ -53,7 +55,9 @@ export const opensInspectQueryModal = () => {
};

export const waitsForEventsToBeLoaded = () => {
cy.get(SERVER_SIDE_EVENT_COUNT).should('exist').invoke('text').should('not.equal', '0');
cy.get(SERVER_SIDE_EVENT_COUNT).should('not.have.text', '0');
cy.get(REFRESH_BUTTON).should('not.have.text', 'Updating');
cy.get(EVENTS_VIEWER_PAGINATION).should('exist');
};

export const dragAndDropColumn = ({
Expand Down