Skip to content

Commit

Permalink
[Security Solution] Fix EventsViewer DnD cypress tests (#82619) (#82912)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski authored Nov 7, 2020
1 parent c2d04d3 commit 3723c77
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
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

0 comments on commit 3723c77

Please sign in to comment.