@brightspace-ui/testing 1.10.0 → 1.10.2

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.10.0",
5
+ "version": "1.10.2",
6
6
  "repository": "https://github.com/BrightspaceUI/testing.git",
7
7
  "scripts": {
8
8
  "lint": "eslint . --ext .js",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@brightspace-ui/intl": "^3",
41
- "@open-wc/testing": "^3",
41
+ "@open-wc/testing": "^4",
42
42
  "@rollup/plugin-node-resolve": "^15",
43
43
  "@web/config-loader": "^0.3",
44
44
  "@web/dev-server": "^0.4",
@@ -31,19 +31,41 @@ function getComposedChildren(node) {
31
31
 
32
32
  async function waitForElem(elem, awaitLoadingComplete = true) {
33
33
 
34
- const update = elem?.updateComplete;
35
- if (typeof update === 'object' && Promise.resolve(update) === update) {
36
- await update;
37
- await nextFrame();
38
- }
34
+ const doWait = async() => {
39
35
 
40
- if (awaitLoadingComplete && typeof elem?.getLoadingComplete === 'function') {
41
- await elem.getLoadingComplete();
42
- await nextFrame();
43
- }
36
+ const update = elem?.updateComplete;
37
+ if (typeof update === 'object' && Promise.resolve(update) === update) {
38
+ await update;
39
+ await nextFrame();
40
+ }
41
+
42
+ if (awaitLoadingComplete && typeof elem?.getLoadingComplete === 'function') {
43
+ await elem.getLoadingComplete();
44
+ await nextFrame();
45
+ }
44
46
 
45
- const children = getComposedChildren(elem);
46
- await Promise.all(children.map(e => waitForElem(e, awaitLoadingComplete)));
47
+ const children = getComposedChildren(elem);
48
+ await Promise.all(children.map(e => waitForElem(e, awaitLoadingComplete)));
49
+
50
+ };
51
+
52
+ await new Promise((resolve) => {
53
+ const observer = new MutationObserver((records) => {
54
+ for (const record of records) {
55
+ for (const removedNode of record.removedNodes) {
56
+ if (removedNode === elem) {
57
+ observer.disconnect();
58
+ resolve();
59
+ return;
60
+ }
61
+ }
62
+ }
63
+ });
64
+ observer.observe(elem.parentNode, { childList: true });
65
+ doWait()
66
+ .then(() => observer.disconnect())
67
+ .then(resolve);
68
+ });
47
69
 
48
70
  }
49
71