@brightspace-ui/testing 1.52.0 → 1.53.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 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.52.0",
5
+ "version": "1.53.0",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "npm run lint:eslint && npm run lint:style",
@@ -40,7 +40,7 @@ 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) {
43
+ export async function dragElemBy(elem, offsetX = 0, offsetY = 0, completeDrag = true) {
44
44
  const dragIncrementSize = 10; // To mimic real user dragging
45
45
  const numSteps = Math.ceil(Math.max(Math.abs(offsetX), Math.abs(offsetY)) / dragIncrementSize);
46
46
 
@@ -53,7 +53,7 @@ export async function dragElemBy(elem, offsetX = 0, offsetY = 0) {
53
53
  const dy = Math.sign(offsetY) * Math.min(Math.abs(offsetY), dragIncrementSize * i);
54
54
  await sendMouse({ type: 'move', position: [position.x + dx, position.y + dy] });
55
55
  }
56
- await sendMouse({ type: 'up' });
56
+ if (completeDrag) await sendMouse({ type: 'up' });
57
57
  }
58
58
 
59
59
  export async function focusElem(elem) {
@@ -74,7 +74,8 @@ export async function reset(opts = {}) {
74
74
 
75
75
  if (shouldResetMouse) {
76
76
  shouldResetMouse = false;
77
- await sendMouse({ type: 'move', position: [0, 0] }).catch(() => {});
77
+ await sendMouse({ type: 'move', position: [0, 0] });
78
+ await sendMouse({ type: 'up' });
78
79
  }
79
80
 
80
81
  if (document.activeElement !== document.body) {