@brightspace-ui/testing 0.33.0 → 0.34.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 +10 -0
- package/package.json +1 -1
- package/src/browser/fixture.js +5 -1
- package/src/browser/reset.js +16 -2
- package/src/server/pause.js +5 -1
- package/src/server/wtr-config.js +4 -0
package/README.md
CHANGED
|
@@ -458,6 +458,16 @@ To capture the entire viewport, pass `document` as the target element to the ass
|
|
|
458
458
|
await expect(document).to.be.golden();
|
|
459
459
|
```
|
|
460
460
|
|
|
461
|
+
#### Rendering Fullscreen Fixtures
|
|
462
|
+
|
|
463
|
+
To render a fullscreen fixture that fills the viewport, pass a `fullscreen` option to `fixture()`:
|
|
464
|
+
|
|
465
|
+
```javascript
|
|
466
|
+
const elem = await fixture(html`<fullscreen-elem></fullscreen-elem>`, {
|
|
467
|
+
fullscreen: true
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
461
471
|
#### Including Other Elements
|
|
462
472
|
|
|
463
473
|
Elements using `absolute` or `fixed` positioning (like dropdowns or tooltips) may overflow the target element's capture area. To include them, apply the `vdiff-include` CSS 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": "0.
|
|
5
|
+
"version": "0.34.0",
|
|
6
6
|
"repository": "https://github.com/BrightspaceUI/testing.git",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"lint": "eslint . --ext .js",
|
package/src/browser/fixture.js
CHANGED
|
@@ -49,7 +49,11 @@ async function waitForElem(elem, awaitLoadingComplete = true) {
|
|
|
49
49
|
|
|
50
50
|
export async function fixture(element, opts = {}) {
|
|
51
51
|
await Promise.all([reset(opts), document.fonts.ready]);
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
const parentNode = document.createElement('div');
|
|
54
|
+
parentNode.setAttribute('id', 'd2l-test-fixture-container');
|
|
55
|
+
|
|
56
|
+
const elem = await wcFixture(element, { parentNode });
|
|
53
57
|
await waitForElem(elem, opts.awaitLoadingComplete);
|
|
54
58
|
|
|
55
59
|
await pause();
|
package/src/browser/reset.js
CHANGED
|
@@ -2,7 +2,8 @@ import { sendMouse, setViewport } from '@web/test-runner-commands';
|
|
|
2
2
|
import { getDocumentLocaleSettings } from '@brightspace-ui/intl/lib/common.js';
|
|
3
3
|
import { nextFrame } from '@open-wc/testing';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_FULLSCREEN = false,
|
|
6
|
+
DEFAULT_LANG = 'en',
|
|
6
7
|
DEFAULT_MATHJAX_RENDER_LATEX = false,
|
|
7
8
|
DEFAULT_VIEWPORT_HEIGHT = 800,
|
|
8
9
|
DEFAULT_VIEWPORT_WIDTH = 800;
|
|
@@ -10,6 +11,7 @@ const DEFAULT_LANG = 'en',
|
|
|
10
11
|
const documentLocaleSettings = getDocumentLocaleSettings();
|
|
11
12
|
|
|
12
13
|
let
|
|
14
|
+
currentFullscreen = false,
|
|
13
15
|
currentMathjaxRenderLatex = DEFAULT_MATHJAX_RENDER_LATEX,
|
|
14
16
|
currentRtl = false,
|
|
15
17
|
currentViewportHeight = 0,
|
|
@@ -29,7 +31,8 @@ export async function reset(opts = {}) {
|
|
|
29
31
|
viewport: {
|
|
30
32
|
height: DEFAULT_VIEWPORT_HEIGHT,
|
|
31
33
|
width: DEFAULT_VIEWPORT_WIDTH
|
|
32
|
-
}
|
|
34
|
+
},
|
|
35
|
+
fullscreen: DEFAULT_FULLSCREEN
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
opts = { ...defaultOpts, ...opts };
|
|
@@ -40,6 +43,17 @@ export async function reset(opts = {}) {
|
|
|
40
43
|
|
|
41
44
|
window.scroll(0, 0);
|
|
42
45
|
|
|
46
|
+
if (opts.fullscreen !== currentFullscreen) {
|
|
47
|
+
if (opts.fullscreen) {
|
|
48
|
+
document.body.classList.add('fullscreen');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
document.body.classList.remove('fullscreen');
|
|
52
|
+
}
|
|
53
|
+
awaitNextFrame = true;
|
|
54
|
+
currentFullscreen = opts.fullscreen;
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
if (shouldResetMouse) {
|
|
44
58
|
shouldResetMouse = false;
|
|
45
59
|
await sendMouse({ type: 'move', position: [0, 0] }).catch(() => {});
|
package/src/server/pause.js
CHANGED