@enact/ui-test-utils 1.0.0-alpha.1 → 1.0.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/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.1",
4
4
  "description": "UI Testing for the Enact framework",
5
+ "repository": "https://github.com/enactjs/ui-test-utils",
5
6
  "main": "index.js",
6
7
  "bin": {
7
8
  "start-tests": "./start-tests.js"
@@ -38,12 +39,13 @@
38
39
  "webdriverio": "^7.9.0"
39
40
  },
40
41
  "devDependencies": {
42
+ "@babel/eslint-plugin": "^7.17.7",
41
43
  "eslint": "^8.12.0",
42
- "eslint-config-enact": "^4.0.0",
44
+ "eslint-config-enact": "^4.1.1",
43
45
  "eslint-config-prettier": "^8.5.0",
44
- "eslint-plugin-babel": "^5.3.1",
45
- "eslint-plugin-enact": "^1.0.0",
46
+ "eslint-plugin-enact": "^1.0.1",
46
47
  "eslint-plugin-import": "^2.25.4",
48
+ "eslint-plugin-jest": "^26.1.5",
47
49
  "eslint-plugin-jsx-a11y": "^6.5.1",
48
50
  "eslint-plugin-prettier": "^4.0.0",
49
51
  "eslint-plugin-react": "^7.29.4",
@@ -1,4 +1,4 @@
1
- import {render} from 'react-dom';
1
+ import {createRoot} from 'react-dom/client';
2
2
  import App, {testMetadata} from 'UI_TEST_APP_ENTRY';
3
3
  import TestChooser from './TestChooser';
4
4
 
@@ -18,13 +18,9 @@ if ('testId' in props) props.testId = Number.parseInt(props.testId);
18
18
  if ('request' in props) {
19
19
  window.__TEST_DATA = testMetadata;
20
20
  } else if (Object.keys(props).length) {
21
- render(
22
- <App {...props} />,
23
- document.getElementById('root')
24
- );
21
+ createRoot(document.getElementById('root'))
22
+ .render(<App {...props} />);
25
23
  } else {
26
- render(
27
- <TestChooser metadata={testMetadata} />,
28
- document.getElementById('root')
29
- );
24
+ createRoot(document.getElementById('root'))
25
+ .render(<TestChooser metadata={testMetadata} />);
30
26
  }
package/start-tests.js CHANGED
File without changes
package/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {render} from 'react-dom';
1
+ import {createRoot} from 'react-dom/client';
2
2
  import App from 'UI_TEST_APP_ENTRY';
3
3
 
4
4
  const url = new URL(window.location.href);
@@ -7,10 +7,8 @@ const locale = url.searchParams.get('locale');
7
7
  const appElement = (<App locale={locale} />);
8
8
 
9
9
  if (typeof window !== 'undefined') {
10
- render(
11
- appElement,
12
- document.getElementById('root')
13
- );
10
+ createRoot(document.getElementById('root'))
11
+ .render(appElement);
14
12
  }
15
13
 
16
14
  export default appElement;
package/utils/Page.js CHANGED
@@ -13,6 +13,10 @@ class Page {
13
13
  }
14
14
 
15
15
  async open (appPath, urlExtra = '?locale=en-US') {
16
+ await browser.execute(function () {
17
+ document.body.innerHTML = '';
18
+ });
19
+
16
20
  this._url = `/${appPath}/${urlExtra}`;
17
21
  // Can't resize browser window when connected to remote debugger!
18
22
  if (!browser._options || !browser._options.remote) {
@@ -22,7 +26,9 @@ class Page {
22
26
  await browser.url(this.url);
23
27
 
24
28
  const body = await $('body');
25
- await body.waitForExist({timeout: 1000});
29
+ await body.waitForDisplayed({timeout: 5000});
30
+
31
+ await this.delay(200);
26
32
  }
27
33
 
28
34
  serializeParams (params) {
@@ -69,7 +75,7 @@ class Page {
69
75
 
70
76
  // For testing "pointer off" by timeout.
71
77
  async hidePointerByKeycode () {
72
- browser.execute(function () {
78
+ await browser.execute(function () {
73
79
  const event = document.createEvent('Events');
74
80
  event.initEvent('keydown', true, true);
75
81
  event.keyCode = 1537;
@@ -136,7 +142,7 @@ class Page {
136
142
  await browser.waitUntil(() => target.isExisting() && target.isFocused(), {timeout, timeoutMsg, interval});
137
143
  }
138
144
 
139
- async waitTransitionEnd (delay = 3000, msg = 'timed out waiting for transitionend', callback, ignore = ['opacity', 'filter']) {
145
+ async waitTransitionEnd (timeout = 3000, timeoutMsg = 'timed out waiting for transitionend', callback, ignore = ['opacity', 'filter']) {
140
146
  await browser.execute(
141
147
  // eslint-disable-next-line no-shadow
142
148
  function (ignore) {
@@ -153,15 +159,14 @@ class Page {
153
159
  callback();
154
160
  }
155
161
  await browser.waitUntil(
156
- function () {
157
- return browser.execute(
162
+ async function () {
163
+ return await browser.execute(
158
164
  function () {
159
165
  return window.__transition;
160
166
  }
161
167
  );
162
168
  },
163
- delay,
164
- msg
169
+ {timeout, timeoutMsg}
165
170
  );
166
171
  }
167
172
  }
package/utils/runTest.js CHANGED
@@ -19,7 +19,7 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
19
19
  await Page.open('?request');
20
20
 
21
21
  let testCases = await browser.execute(async function () {
22
- return await window.__TEST_DATA; // eslint-disable-line no-undef
22
+ return await window.__TEST_DATA;
23
23
  });
24
24
 
25
25
  await expect(testCases).to.be.an('object', 'Test data failed to load');