@enact/ui-test-utils 0.7.1 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/ui-test-utils",
3
- "version": "0.7.1",
3
+ "version": "1.0.0",
4
4
  "description": "UI Testing for the Enact framework",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -23,7 +23,6 @@
23
23
  "@wdio/selenium-standalone-service": "^7.8.0",
24
24
  "@wdio/spec-reporter": "^7.9.0",
25
25
  "@wdio/static-server-service": "^7.8.0",
26
- "@wdio/sync": "^7.9.0",
27
26
  "chai": "4.3.4",
28
27
  "chalk": "^4.1.2",
29
28
  "cross-spawn": "^7.0.3",
@@ -39,16 +38,16 @@
39
38
  "webdriverio": "^7.9.0"
40
39
  },
41
40
  "devDependencies": {
42
- "babel-eslint": "^10.1.0",
43
- "eslint": "^7.11.0",
44
- "eslint-config-enact": "^3.0.0",
45
- "eslint-config-prettier": "^6.11.0",
46
- "eslint-plugin-babel": "^5.3.1",
47
- "eslint-plugin-enact": "^0.2.0",
48
- "eslint-plugin-import": "^2.22.0",
49
- "eslint-plugin-jsx-a11y": "^6.3.1",
50
- "eslint-plugin-prettier": "^3.1.4",
51
- "eslint-plugin-react": "^7.21.5",
52
- "eslint-plugin-react-hooks": "^4.2.0"
41
+ "@babel/eslint-plugin": "^7.17.7",
42
+ "eslint": "^8.12.0",
43
+ "eslint-config-enact": "^4.1.1",
44
+ "eslint-config-prettier": "^8.5.0",
45
+ "eslint-plugin-enact": "^1.0.1",
46
+ "eslint-plugin-import": "^2.25.4",
47
+ "eslint-plugin-jest": "^26.1.5",
48
+ "eslint-plugin-jsx-a11y": "^6.5.1",
49
+ "eslint-plugin-prettier": "^4.0.0",
50
+ "eslint-plugin-react": "^7.29.4",
51
+ "eslint-plugin-react-hooks": "^4.3.0"
53
52
  }
54
53
  }
@@ -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/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
@@ -12,13 +12,17 @@ class Page {
12
12
  return this._url;
13
13
  }
14
14
 
15
- open (appPath, urlExtra = '?locale=en-US') {
15
+ async open (appPath, urlExtra = '?locale=en-US') {
16
16
  this._url = `/${appPath}/${urlExtra}`;
17
17
  // Can't resize browser window when connected to remote debugger!
18
18
  if (!browser._options || !browser._options.remote) {
19
- browser.setWindowSize(1920, 1080);
19
+ await browser.setWindowSize(1920, 1080);
20
20
  }
21
- browser.url(this.url);
21
+
22
+ await browser.url(this.url);
23
+
24
+ const body = await $('body');
25
+ await body.waitForExist({timeout: 1000});
22
26
  }
23
27
 
24
28
  serializeParams (params) {
@@ -27,14 +31,14 @@ class Page {
27
31
  return queryObject;
28
32
  }
29
33
 
30
- delay (delay = 1000) {
31
- browser.pause(delay);
34
+ async delay (delay = 1000) {
35
+ await browser.pause(delay);
32
36
  return browser;
33
37
  }
34
- keyDelay (key, delay = 50) {
35
- browser.keys(key);
36
- browser.pause(delay);
37
- return browser;
38
+ async keyDelay (key, delay = 50) {
39
+ await browser.keys(key);
40
+ await browser.pause(delay);
41
+ return await browser;
38
42
  }
39
43
  spotlightLeft () {
40
44
  return this.keyDelay('Left arrow');
@@ -64,25 +68,25 @@ class Page {
64
68
  }
65
69
 
66
70
  // For testing "pointer off" by timeout.
67
- hidePointerByKeycode () {
71
+ async hidePointerByKeycode () {
68
72
  browser.execute(function () {
69
73
  const event = document.createEvent('Events');
70
74
  event.initEvent('keydown', true, true);
71
75
  event.keyCode = 1537;
72
76
  document.getElementById('root').dispatchEvent(event);
73
77
  });
74
- this.delay();
78
+ await this.delay();
75
79
  return browser;
76
80
  }
77
81
 
78
- showPointerByKeycode () {
79
- browser.execute(function () {
82
+ async showPointerByKeycode () {
83
+ await browser.execute(function () {
80
84
  const event = document.createEvent('Events');
81
85
  event.initEvent('keydown', true, true);
82
86
  event.keyCode = 1536;
83
87
  document.getElementById('root').dispatchEvent(event);
84
88
  });
85
- this.delay();
89
+ await this.delay();
86
90
  return browser;
87
91
  }
88
92
 
@@ -128,12 +132,12 @@ class Page {
128
132
  * @param {Number} [config.timeout=1200] Time to wait for focus condition
129
133
  * @param {Number} [config.interval=200] Time between checks
130
134
  */
131
- waitForFocused (target, {targetName = 'item', timeoutMsg = `timed out waiting for ${targetName} focused`, timeout = 1200, interval = 200} = {}) {
132
- browser.waitUntil(() => target.isExisting() && target.isFocused(), {timeout, timeoutMsg, interval});
135
+ async waitForFocused (target, {targetName = 'item', timeoutMsg = `timed out waiting for ${targetName} focused`, timeout = 1200, interval = 200} = {}) {
136
+ await browser.waitUntil(() => target.isExisting() && target.isFocused(), {timeout, timeoutMsg, interval});
133
137
  }
134
138
 
135
- waitTransitionEnd (delay = 3000, msg = 'timed out waiting for transitionend', callback, ignore = ['opacity', 'filter']) {
136
- browser.execute(
139
+ async waitTransitionEnd (delay = 3000, msg = 'timed out waiting for transitionend', callback, ignore = ['opacity', 'filter']) {
140
+ await browser.execute(
137
141
  // eslint-disable-next-line no-shadow
138
142
  function (ignore) {
139
143
  window.ontransitionend = function (evt) {
@@ -148,7 +152,7 @@ class Page {
148
152
  if (callback) {
149
153
  callback();
150
154
  }
151
- browser.waitUntil(
155
+ await browser.waitUntil(
152
156
  function () {
153
157
  return browser.execute(
154
158
  function () {
package/utils/runTest.js CHANGED
@@ -15,13 +15,14 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
15
15
  }
16
16
 
17
17
  describe(testName, function () {
18
- it('should fetch test cases', function () {
19
- Page.open('?request');
20
- let testCases = browser.execute(function () {
21
- return window.__TEST_DATA; // eslint-disable-line no-undef
18
+ it('should fetch test cases', async function () {
19
+ await Page.open('?request');
20
+
21
+ let testCases = await browser.execute(async function () {
22
+ return await window.__TEST_DATA; // eslint-disable-line no-undef
22
23
  });
23
24
 
24
- expect(testCases).to.be.an('object', 'Test data failed to load');
25
+ await expect(testCases).to.be.an('object', 'Test data failed to load');
25
26
 
26
27
  describe(testName, function () {
27
28
  for (const component in testCases) {
@@ -43,7 +44,7 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
43
44
  if (titlePattern && !testCase.title.match(titlePattern)) {
44
45
  return;
45
46
  }
46
- it(`${component}~/${testName}~/${testCase.title}`, function () {
47
+ it(`${component}~/${testName}~/${testCase.title}`, async function () {
47
48
  const params = Page.serializeParams(Object.assign({
48
49
  component,
49
50
  testId
@@ -60,9 +61,9 @@ const runTest = ({concurrency, filter, Page, testName, ...rest}) => {
60
61
  const context = {params, component, testName, url: Page.url, fileName: screenshotFileName};
61
62
  this.test.context = context;
62
63
 
63
- Page.open(`?${params}`);
64
+ await Page.open(`?${params}`);
64
65
 
65
- expect(browser.checkScreen(screenshotFileName, {
66
+ expect(await browser.checkScreen(screenshotFileName, {
66
67
  disableCSSAnimation: true,
67
68
  ignoreNothing: true,
68
69
  rawMisMatchPercentage: true
package/utils/selector.js CHANGED
@@ -42,15 +42,15 @@ const getSubComponent = curry((opts, el) => element(
42
42
 
43
43
  // Given two elements, determine if the first element is to the left of the second element
44
44
  // element, element => Boolean
45
- function expectOrdering (firstElement, secondElement) {
46
- expect(firstElement.getLocation().x < secondElement.getLocation().x).to.be.true();
45
+ async function expectOrdering (firstElement, secondElement) {
46
+ expect(await firstElement.getLocation().x < secondElement.getLocation().x).to.be.true();
47
47
  }
48
48
 
49
- const hasClass = curry((className, el) => {
49
+ const hasClass = curry(async (className, el) => {
50
50
  if (className[0] === '.') {
51
51
  className = className.slice(1);
52
52
  }
53
- const elementClass = el.getAttribute('className') || el.getAttribute('class');
53
+ const elementClass = await el.getAttribute('className') || await el.getAttribute('class');
54
54
  return elementClass.includes(className);
55
55
  });
56
56