-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactors 'data-providers' tests (#57474)
- Loading branch information
1 parent
70fcc3d
commit e7a2564
Showing
7 changed files
with
140 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const ALL_HOSTS_TABLE = '[data-test-subj="table-allHosts-loading-false"]'; | ||
|
||
export const HOSTS_NAMES = '[data-test-subj="draggable-content-host.name"]'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
const primaryButton = 0; | ||
|
||
/** | ||
* To overcome the React Beautiful DND sloppy click detection threshold: | ||
* https://github.com/atlassian/react-beautiful-dnd/blob/67b96c8d04f64af6b63ae1315f74fc02b5db032b/docs/sensors/mouse.md#sloppy-clicks-and-click-prevention- | ||
*/ | ||
const dndSloppyClickDetectionThreshold = 5; | ||
|
||
/** Starts dragging the subject */ | ||
export const drag = (subject: JQuery<HTMLElement>) => { | ||
const subjectLocation = subject[0].getBoundingClientRect(); | ||
|
||
cy.wrap(subject) | ||
.trigger('mousedown', { | ||
button: primaryButton, | ||
clientX: subjectLocation.left, | ||
clientY: subjectLocation.top, | ||
force: true, | ||
}) | ||
.wait(1) | ||
.trigger('mousemove', { | ||
button: primaryButton, | ||
clientX: subjectLocation.left + dndSloppyClickDetectionThreshold, | ||
clientY: subjectLocation.top, | ||
force: true, | ||
}) | ||
.wait(1); | ||
}; | ||
|
||
/** "Drops" the subject being dragged on the specified drop target */ | ||
export const drop = (dropTarget: JQuery<HTMLElement>) => { | ||
cy.wrap(dropTarget) | ||
.trigger('mousemove', { button: primaryButton, force: true }) | ||
.wait(1) | ||
.trigger('mouseup', { force: true }) | ||
.wait(1); | ||
}; | ||
|
||
/** Drags the subject being dragged on the specified drop target, but does not drop it */ | ||
export const dragWithoutDrop = (dropTarget: JQuery<HTMLElement>) => { | ||
cy.wrap(dropTarget).trigger('mousemove', 'center', { | ||
button: primaryButton, | ||
}); | ||
}; |
40 changes: 40 additions & 0 deletions
40
x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ALL_HOSTS_TABLE, HOSTS_NAMES } from '../../screens/hosts/all_hosts'; | ||
import { | ||
TIMELINE_DATA_PROVIDERS, | ||
TIMELINE_DATA_PROVIDERS_EMPTY, | ||
} from '../../screens/timeline/main'; | ||
import { DEFAULT_TIMEOUT } from '../../tasks/login'; | ||
import { drag, drop, dragWithoutDrop } from '../../tasks/common'; | ||
|
||
export const waitForAllHostsToBeLoaded = () => { | ||
cy.get(ALL_HOSTS_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist'); | ||
}; | ||
|
||
export const dragAndDropFirstHostToTimeline = () => { | ||
cy.get(HOSTS_NAMES) | ||
.first() | ||
.then(firstHost => drag(firstHost)); | ||
cy.get(TIMELINE_DATA_PROVIDERS).then(dataProvidersDropArea => drop(dataProvidersDropArea)); | ||
}; | ||
|
||
export const dragFirstHostToTimeline = () => { | ||
cy.get(HOSTS_NAMES) | ||
.first() | ||
.then(host => drag(host)); | ||
}; | ||
|
||
export const dragFirstHostToEmptyTimelineDataProviders = () => { | ||
cy.get(HOSTS_NAMES) | ||
.first() | ||
.then(host => drag(host)); | ||
|
||
cy.get(TIMELINE_DATA_PROVIDERS_EMPTY).then(dataProvidersDropArea => | ||
dragWithoutDrop(dataProvidersDropArea) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters