@brightspace-ui/testing 1.22.0 → 1.24.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/README.md +22 -0
- package/package.json +1 -1
- package/src/browser/commands.js +9 -0
- package/src/browser/index.js +1 -1
- package/src/server/report/result.js +12 -0
package/README.md
CHANGED
|
@@ -189,6 +189,28 @@ it('should click at coordinate', async() => {
|
|
|
189
189
|
});
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
+
Elements configured using the [Drag & Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API) can be interacted with using `dragDropElems(sourceElem, destElem)`:
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
import { dragDropElems } from '@brightspace-ui/testing';
|
|
196
|
+
|
|
197
|
+
it('should drag & drop', async() => {
|
|
198
|
+
const rootElem = await fixture(html`
|
|
199
|
+
<div>
|
|
200
|
+
<div id="source" draggable="true"></div>
|
|
201
|
+
<div id="dest"></div>
|
|
202
|
+
</div>
|
|
203
|
+
`);
|
|
204
|
+
// NOTE: destination must have "dragover" and "drop"
|
|
205
|
+
// event listeners added for the drag & drop API to function
|
|
206
|
+
await dragDropElems(
|
|
207
|
+
rootElem.querySelector('#source'),
|
|
208
|
+
rootElem.querySelector('#target')
|
|
209
|
+
);
|
|
210
|
+
// do assertions
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
192
214
|
### Using the Keyboard
|
|
193
215
|
|
|
194
216
|
To place focus on an element using the keyboard, use `focusElem(elem)`. Doing so will trigger its `:focus-visible` CSS pseudo-class.
|
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.24.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
|
@@ -24,6 +24,15 @@ export async function clickElem(elem) {
|
|
|
24
24
|
return clickAt(position.x, position.y);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export async function dragDropElems(elem, toElem) {
|
|
28
|
+
const fromPosition = getElementPosition(elem);
|
|
29
|
+
const toPosition = getElementPosition(toElem);
|
|
30
|
+
await sendMouse({ type: 'move', position: [fromPosition.x, fromPosition.y] });
|
|
31
|
+
await sendMouse({ type: 'down' });
|
|
32
|
+
await sendMouse({ type: 'move', position: [toPosition.x, toPosition.y] });
|
|
33
|
+
await sendMouse({ type: 'up' });
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
export async function focusElem(elem) {
|
|
28
37
|
await cmdSendKeys({ press: 'Shift' }); // Tab moves focus, Escape causes dismissible things to close
|
|
29
38
|
elem.focus({ focusVisible: true });
|
package/src/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './vdiff.js';
|
|
2
2
|
|
|
3
3
|
export { assert, aTimeout, defineCE, expect, html, nextFrame, oneDefaultPreventedEvent, oneEvent, waitUntil } from '@open-wc/testing';
|
|
4
|
-
export { clickAt, clickElem, focusElem, hoverAt, hoverElem, sendKeys, sendKeysElem, setViewport } from './commands.js';
|
|
4
|
+
export { clickAt, clickElem, dragDropElems, focusElem, hoverAt, hoverElem, sendKeys, sendKeysElem, setViewport } from './commands.js';
|
|
5
5
|
export { fixture } from './fixture.js';
|
|
6
6
|
export { runConstructor } from './constructor.js';
|
|
@@ -63,6 +63,18 @@ export const RESULT_STYLE = css`
|
|
|
63
63
|
position: absolute;
|
|
64
64
|
top: 0;
|
|
65
65
|
}
|
|
66
|
+
.result-overlay img:active {
|
|
67
|
+
filter:
|
|
68
|
+
drop-shadow(0 0 0.5px red)
|
|
69
|
+
drop-shadow(0 0 0.5px red)
|
|
70
|
+
drop-shadow(0 0 0.5px red)
|
|
71
|
+
drop-shadow(0 0 0.5px red)
|
|
72
|
+
drop-shadow(0 0 0.5px red)
|
|
73
|
+
drop-shadow(0 0 0.5px red)
|
|
74
|
+
drop-shadow(0 0 0.5px red)
|
|
75
|
+
drop-shadow(0 0 0.5px red)
|
|
76
|
+
drop-shadow(0 0 0.5px red);
|
|
77
|
+
}
|
|
66
78
|
.result-part-info {
|
|
67
79
|
align-items: center;
|
|
68
80
|
display: flex;
|