@brightspace-ui/testing 1.50.1 → 1.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/browser/commands.js +16 -0
- package/src/browser/index.js +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@brightspace-ui/testing",
|
|
3
3
|
"description": "Utilities for testing front-end components and applications",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.51.0",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "npm run lint:eslint && npm run lint:style",
|
package/src/browser/commands.js
CHANGED
|
@@ -40,6 +40,22 @@ export async function dragDropElems(elem, toElem) {
|
|
|
40
40
|
await sendMouse({ type: 'up' });
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
export async function dragElemBy(elem, offsetX = 0, offsetY = 0) {
|
|
44
|
+
const dragIncrementSize = 10; // To mimic real user dragging
|
|
45
|
+
const numSteps = Math.ceil(Math.max(Math.abs(offsetX), Math.abs(offsetY)) / dragIncrementSize);
|
|
46
|
+
|
|
47
|
+
const position = getElementPosition(elem);
|
|
48
|
+
await sendMouse({ type: 'move', position: [position.x, position.y] });
|
|
49
|
+
|
|
50
|
+
await sendMouse({ type: 'down' });
|
|
51
|
+
for (let i = 1; i <= numSteps; i++) {
|
|
52
|
+
const dx = Math.sign(offsetX) * Math.min(Math.abs(offsetX), dragIncrementSize * i);
|
|
53
|
+
const dy = Math.sign(offsetY) * Math.min(Math.abs(offsetY), dragIncrementSize * i);
|
|
54
|
+
await sendMouse({ type: 'move', position: [position.x + dx, position.y + dy] });
|
|
55
|
+
}
|
|
56
|
+
await sendMouse({ type: 'up' });
|
|
57
|
+
}
|
|
58
|
+
|
|
43
59
|
export async function focusElem(elem) {
|
|
44
60
|
await cmdSendKeys({ press: 'Shift' }); // Tab moves focus, Escape causes dismissible things to close
|
|
45
61
|
elem.focus({ focusVisible: true });
|
package/src/browser/index.js
CHANGED
|
@@ -2,6 +2,6 @@ import './vdiff.js';
|
|
|
2
2
|
import './axe.js';
|
|
3
3
|
|
|
4
4
|
export { assert, aTimeout, defineCE, expect, html, nextFrame, oneDefaultPreventedEvent, oneEvent, waitUntil } from '@open-wc/testing';
|
|
5
|
-
export { clickAt, clickElem, clickElemAt, dragDropElems, focusElem, hoverAt, hoverElem, hoverElemAt, sendKeys, sendKeysElem, setViewport } from './commands.js';
|
|
5
|
+
export { clickAt, clickElem, clickElemAt, dragDropElems, dragElemBy, focusElem, hoverAt, hoverElem, hoverElemAt, sendKeys, sendKeysElem, setViewport } from './commands.js';
|
|
6
6
|
export { fixture, waitForElem } from './fixture.js';
|
|
7
7
|
export { runConstructor } from './constructor.js';
|