@brightspace-ui/testing 0.33.0 → 0.34.1
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 +13 -6
- 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 +6 -0
package/README.md
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Testing utilities which are specifically designed and configured for Brightspace UI components and applications.
|
|
6
6
|
|
|
7
|
+
> **Migrating from `@open-wc/testing` and/or `@brightspace-ui/visual-diff`?**
|
|
8
|
+
> Refer to the [Migration Guide](./docs/migration-guide.md) for help migrating a repo to `@brightspace-ui/testing`.
|
|
9
|
+
|
|
7
10
|
Install from NPM:
|
|
8
11
|
|
|
9
12
|
```shell
|
|
@@ -458,6 +461,16 @@ To capture the entire viewport, pass `document` as the target element to the ass
|
|
|
458
461
|
await expect(document).to.be.golden();
|
|
459
462
|
```
|
|
460
463
|
|
|
464
|
+
#### Rendering Fullscreen Fixtures
|
|
465
|
+
|
|
466
|
+
To render a fullscreen fixture that fills the viewport, pass a `fullscreen` option to `fixture()`:
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
const elem = await fixture(html`<fullscreen-elem></fullscreen-elem>`, {
|
|
470
|
+
fullscreen: true
|
|
471
|
+
});
|
|
472
|
+
```
|
|
473
|
+
|
|
461
474
|
#### Including Other Elements
|
|
462
475
|
|
|
463
476
|
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.
|
|
@@ -543,12 +556,6 @@ The report supports filtering by status and browser, and allows for iteration th
|
|
|
543
556
|
|
|
544
557
|
To help surface instances where a browser version change may be responsible for vdiff failures in the report, a `.vdiff.json` tracking file will be committed to the root of the repository.
|
|
545
558
|
|
|
546
|
-
### Migrating
|
|
547
|
-
|
|
548
|
-
TODO:
|
|
549
|
-
- Migration commands
|
|
550
|
-
- Migration Guide
|
|
551
|
-
|
|
552
559
|
## Developing and Contributing
|
|
553
560
|
|
|
554
561
|
After cloning the repo, run `npm install` to install its dependencies.
|
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.1",
|
|
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
package/src/server/wtr-config.js
CHANGED
|
@@ -96,6 +96,10 @@ export class WTRConfig {
|
|
|
96
96
|
line-height: 1.4rem;
|
|
97
97
|
padding: 30px;
|
|
98
98
|
}
|
|
99
|
+
body.fullscreen > #d2l-test-fixture-container {
|
|
100
|
+
position: absolute;
|
|
101
|
+
inset: 0;
|
|
102
|
+
}
|
|
99
103
|
</style>
|
|
100
104
|
</head>
|
|
101
105
|
<body>
|
|
@@ -183,6 +187,8 @@ export class WTRConfig {
|
|
|
183
187
|
files: this.#pattern
|
|
184
188
|
});
|
|
185
189
|
} else if (group === 'vdiff') {
|
|
190
|
+
config.testsFinishTimeout = 5 * 60 * 1000;
|
|
191
|
+
|
|
186
192
|
config.reporters ??= [ defaultReporter() ];
|
|
187
193
|
config.reporters.push(visualDiffReporter({ updateGoldens: golden }));
|
|
188
194
|
|