@ui5/webcomponents-tools 0.0.0-f651a470c → 0.0.0-f6676abdd

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +1346 -0
  2. package/README.md +3 -5
  3. package/assets-meta.js +11 -10
  4. package/components-package/cypress/support/commands.js +66 -0
  5. package/components-package/cypress/support/component-index.html +17 -0
  6. package/components-package/cypress/support/component.d.ts +22 -0
  7. package/components-package/cypress/support/component.js +46 -0
  8. package/components-package/cypress/support/cypress-ct-preact.js +11 -0
  9. package/components-package/cypress.config.js +33 -0
  10. package/components-package/eslint.js +94 -28
  11. package/components-package/nps.js +58 -47
  12. package/components-package/postcss.components.js +1 -21
  13. package/components-package/postcss.themes.js +1 -26
  14. package/components-package/vite.config.js +7 -11
  15. package/components-package/wdio.js +415 -393
  16. package/icons-collection/nps.js +9 -7
  17. package/lib/amd-to-es6/index.js +102 -0
  18. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  19. package/lib/cem/custom-elements-manifest.config.mjs +544 -0
  20. package/lib/cem/event.mjs +168 -0
  21. package/lib/cem/schema-internal.json +1413 -0
  22. package/lib/cem/schema.json +1098 -0
  23. package/lib/cem/types-internal.d.ts +808 -0
  24. package/lib/cem/types.d.ts +736 -0
  25. package/lib/cem/utils.mjs +423 -0
  26. package/lib/cem/validate.js +70 -0
  27. package/lib/create-icons/index.js +8 -6
  28. package/lib/create-illustrations/index.js +51 -30
  29. package/lib/create-new-component/{tsFileContentTemplate.js → Component.js} +15 -25
  30. package/lib/create-new-component/ComponentTemplate.js +12 -0
  31. package/lib/create-new-component/index.js +35 -73
  32. package/lib/css-processors/css-processor-components.mjs +77 -0
  33. package/lib/css-processors/css-processor-themes.mjs +74 -0
  34. package/lib/css-processors/scope-variables.mjs +49 -0
  35. package/lib/css-processors/shared.mjs +56 -0
  36. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  37. package/lib/dev-server/{dev-server.js → dev-server.mjs} +4 -4
  38. package/lib/dev-server/virtual-index-html-plugin.js +24 -20
  39. package/lib/generate-js-imports/illustrations.js +78 -64
  40. package/lib/generate-json-imports/i18n.js +45 -61
  41. package/lib/generate-json-imports/themes.js +16 -33
  42. package/lib/hbs2lit/src/compiler.js +9 -6
  43. package/lib/hbs2lit/src/litVisitor2.js +42 -17
  44. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  45. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +39 -6
  46. package/lib/hbs2ui5/index.js +23 -6
  47. package/lib/i18n/defaults.js +3 -2
  48. package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
  49. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  50. package/lib/scoping/get-all-tags.js +10 -3
  51. package/lib/scoping/lint-src.js +8 -7
  52. package/lib/scoping/scope-test-pages.js +2 -1
  53. package/lib/test-runner/test-runner.js +2 -2
  54. package/package.json +25 -13
  55. package/tsconfig.json +18 -0
  56. package/types/index.d.ts +1 -0
  57. package/components-package/wdio.sync.js +0 -360
  58. package/lib/create-new-component/jsFileContentTemplate.js +0 -77
  59. package/lib/esm-abs-to-rel/index.js +0 -58
  60. package/lib/generate-custom-elements-manifest/index.js +0 -327
  61. package/lib/jsdoc/config.json +0 -29
  62. package/lib/jsdoc/configTypescript.json +0 -29
  63. package/lib/jsdoc/plugin.js +0 -2468
  64. package/lib/jsdoc/preprocess.js +0 -146
  65. package/lib/jsdoc/template/publish.js +0 -4120
  66. package/lib/postcss-css-to-esm/index.js +0 -90
  67. package/lib/postcss-css-to-json/index.js +0 -47
  68. package/lib/postcss-new-files/index.js +0 -36
  69. package/lib/postcss-p/postcss-p.mjs +0 -14
  70. package/lib/replace-global-core/index.js +0 -25
@@ -1,393 +1,415 @@
1
- exports.config = {
2
- //
3
- // ====================
4
- // Runner Configuration
5
- // ====================
6
- //
7
- // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
8
- // on a remote machine).
9
- runner: 'local',
10
-
11
- //
12
- // ==================
13
- // Specify Test Files
14
- // ==================
15
- // Define which test specs should run. The pattern is relative to the directory
16
- // from which `wdio` was called. Notice that, if you are calling `wdio` from an
17
- // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
18
- // directory is where your package.json resides, so `wdio` will be called from there.
19
- //
20
- specs: [
21
- './test/specs/**/*.js'
22
- ],
23
- // Patterns to exclude.
24
- exclude: [
25
- // 'path/to/excluded/files'
26
- ],
27
- //
28
- // ============
29
- // Capabilities
30
- // ============
31
- // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
32
- // time. Depending on the number of capabilities, WebdriverIO launches several test
33
- // sessions. Within your capabilities you can overwrite the spec and exclude options in
34
- // order to group specific specs to a specific capability.
35
- //
36
- // First, you can define how many instances should be started at the same time. Let's
37
- // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
38
- // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
39
- // files and you set maxInstances to 10, all spec files will get tested at the same time
40
- // and 30 processes will get spawned. The property handles how many capabilities
41
- // from the same test should run tests.
42
- //
43
- maxInstances: 10,
44
- //
45
- // If you have trouble getting all important capabilities together, check out the
46
- // Sauce Labs platform configurator - a great tool to configure your capabilities:
47
- // https://docs.saucelabs.com/reference/platforms-configurator
48
- //
49
- capabilities: [{
50
- // maxInstances can get overwritten per capability. So if you have an in-house Selenium
51
- // grid with only 5 firefox instances available you can make sure that not more than
52
- // 5 instances get started at a time.
53
- maxInstances: 5,
54
- //
55
- browserName: 'chrome',
56
- 'goog:chromeOptions': {
57
- // to run chrome headless the following flags are required
58
- // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59
- args: ['--headless', '--disable-gpu'],
60
- // args: ['--disable-gpu'],
61
- }
62
- }],
63
- //
64
- // port to find chromedriver
65
- port: 9515, // default
66
- // ===================
67
- // Test Configurations
68
- // ===================
69
- // Define all options that are relevant for the WebdriverIO instance here
70
- //
71
- // Level of logging verbosity: trace | debug | info | warn | error
72
- logLevel: 'error',
73
- //
74
- // Warns when a deprecated command is used
75
- deprecationWarnings: true,
76
- //
77
- // If you only want to run your tests until a specific amount of tests have failed use
78
- // bail (default is 0 - don't bail, run all tests).
79
- bail: 0,
80
- //
81
- // Set a base URL in order to shorten url command calls. If your `url` parameter starts
82
- // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
83
- // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
84
- // gets prepended directly.
85
- baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
86
- path: '',
87
- //
88
- // Default timeout for all waitFor* commands.
89
- waitforTimeout: 10000,
90
- //
91
- // Default timeout in milliseconds for request
92
- // if Selenium Grid doesn't send response
93
- connectionRetryTimeout: 90000,
94
- //
95
- // Default request retries count
96
- connectionRetryCount: 3,
97
- //
98
- // Test runner services
99
- // Services take over a specific job you don't want to take care of. They enhance
100
- // your test setup with almost no effort. Unlike plugins, they don't add new
101
- // commands. Instead, they hook themselves up into the test process.
102
- services: ['chromedriver', 'devtools',
103
- ['static-server', {
104
- folders: [
105
- { mount: '/', path: './dist' },
106
- ],
107
- port: '4567',
108
- }],
109
- ],
110
- // options
111
- chromeDriverArgs: ['--port=9515'], // default
112
- // Framework you want to run your specs with.
113
- // The following are supported: Mocha, Jasmine, and Cucumber
114
- // see also: https://webdriver.io/docs/frameworks.html
115
- //
116
- // Make sure you have the wdio adapter package for the specific framework installed
117
- // before running any tests.
118
- framework: 'mocha',
119
- //
120
- // Test reporter for stdout.
121
- // The only one supported by default is 'dot'
122
- // see also: https://webdriver.io/docs/dot-reporter.html
123
- reporters: ['dot', 'spec'],
124
-
125
- //
126
- // Options to be passed to Mocha.
127
- // See the full list at http://mochajs.org/
128
- mochaOpts: {
129
- ui: 'bdd',
130
- timeout: 60000
131
- },
132
- //
133
- // =====
134
- // Hooks
135
- // =====
136
- // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
137
- // it and to build services around it. You can either apply a single function or an array of
138
- // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
139
- // resolved to continue.
140
- /**
141
- * Gets executed once before all workers get launched.
142
- * @param {Object} config wdio configuration object
143
- * @param {Array.<Object>} capabilities list of capabilities details
144
- */
145
- // onPrepare: function (config, capabilities) {
146
- // },
147
- /**
148
- * Gets executed just before initialising the webdriver session and test framework. It allows you
149
- * to manipulate configurations depending on the capability or spec.
150
- * @param {Object} config wdio configuration object
151
- * @param {Array.<Object>} capabilities list of capabilities details
152
- * @param {Array.<String>} specs List of spec file paths that are to be run
153
- */
154
- // beforeSession: function (config, capabilities, specs) {
155
- // },
156
- /**
157
- * Gets executed before test execution begins. At this point you can access to all global
158
- * variables like `browser`. It is the perfect place to define custom commands.
159
- * @param {Array.<Object>} capabilities list of capabilities details
160
- * @param {Array.<String>} specs List of spec file paths that are to be run
161
- */
162
- before: async function (capabilities, specs) {
163
- await browser.addCommand("isFocusedDeep", async function () {
164
- return browser.executeAsync(function (elem, done) {
165
- let activeElement = document.activeElement;
166
-
167
- while (activeElement.shadowRoot) {
168
- if (activeElement.shadowRoot.activeElement) {
169
- activeElement = activeElement.shadowRoot.activeElement;
170
- } else {
171
- break;
172
- }
173
- }
174
- done(elem === activeElement);
175
- }, this);
176
- }, true);
177
-
178
- await browser.addCommand("isFocusedDeepElement", async function (element) {
179
- return browser.executeAsync(function (elem, element, done) {
180
- let activeElement = document.activeElement;
181
-
182
- while (activeElement.shadowRoot) {
183
- if (activeElement.shadowRoot.activeElement) {
184
- activeElement = activeElement.shadowRoot.activeElement;
185
- } else {
186
- break;
187
- }
188
- }
189
- done(element === activeElement);
190
- }, this, element);
191
- }, true);
192
-
193
- await browser.addCommand("setProperty", async function(property, value) {
194
- return browser.executeAsync((elem, property, value, done) => {
195
- elem[property] = value;
196
- done();
197
- }, this, property, value);
198
- }, true);
199
-
200
- await browser.addCommand("setAttribute", async function(attribute, value) {
201
- return browser.executeAsync((elem, attribute, value, done) => {
202
- elem.setAttribute(attribute, value);
203
- done();
204
- }, this, attribute, value);
205
- }, true);
206
-
207
- await browser.addCommand("removeAttribute", async function(attribute) {
208
- return browser.executeAsync((elem, attribute, done) => {
209
- elem.removeAttribute(attribute);
210
- done();
211
- }, this, attribute);
212
- }, true);
213
-
214
- await browser.addCommand("hasClass", async function(className) {
215
- return browser.executeAsync((elem, className, done) => {
216
- done(elem.classList.contains(className));
217
- }, this, className);
218
- }, true);
219
-
220
- await browser.addCommand("hasAttribute", async function(attrName) {
221
- return browser.executeAsync((elem, attrName, done) => {
222
- done(elem.hasAttribute(attrName));
223
- }, this, attrName);
224
- }, true);
225
-
226
- await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
227
- return browser.executeAsync(async (selector, done) => {
228
- const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
229
- done(staticAreaItem.host.classList[0]);
230
- }, selector);
231
- }, false);
232
-
233
- await browser.addLocatorStrategy('activeElement', (selector) => {
234
- return document.querySelector(selector).shadowRoot.activeElement;
235
- });
236
- },
237
- /**
238
- * Runs before a WebdriverIO command gets executed.
239
- * @param {String} commandName hook command name
240
- * @param {Array} args arguments that command would receive
241
- */
242
- beforeCommand: async function (commandName, args) {
243
- const waitFor = [
244
- "$",
245
- "$$",
246
- "getAttribute",
247
- "hasAttribute", // custom
248
- "getCSSProperty",
249
- "getHTML",
250
- "getProperty",
251
- "getSize",
252
- "getStaticAreaItemClassName", // custom
253
- "getText",
254
- "getValue",
255
- "hasClass", // custom
256
- "isDisplayed",
257
- "isDisplayedInViewport",
258
- "isEnabled",
259
- "isExisting",
260
- "isFocused",
261
- "isFocusedDeep", // custom
262
- "isFocusedDeepElement", // custom
263
- "shadow$",
264
- "shadow$$",
265
- ];
266
- if (waitFor.includes(commandName)) {
267
- await browser.executeAsync(function (done) {
268
- window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
269
- });
270
- }
271
- },
272
-
273
- /**
274
- * Hook that gets executed before the suite starts
275
- * @param {Object} suite suite details
276
- */
277
- // beforeSuite: function (suite) {
278
- // },
279
- /**
280
- * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
281
- * @param {Object} test test details
282
- */
283
- // beforeTest: function (test) {
284
- // },
285
- /**
286
- * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
287
- * beforeEach in Mocha)
288
- */
289
- // beforeHook: function () {
290
- // },
291
- /**
292
- * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
293
- * afterEach in Mocha)
294
- */
295
- // afterHook: function () {
296
- // },
297
- /**
298
- * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
299
- * @param {Object} test test details
300
- */
301
- // afterTest: function (test) {
302
- // },
303
- /**
304
- * Hook that gets executed after the suite has ended
305
- * @param {Object} suite suite details
306
- */
307
- // afterSuite: function (suite) {
308
- // },
309
-
310
- /**
311
- * Runs after a WebdriverIO command gets executed
312
- * @param {String} commandName hook command name
313
- * @param {Array} args arguments that command would receive
314
- * @param {Number} result 0 - command success, 1 - command error
315
- * @param {Object} error error object if any
316
- */
317
- afterCommand: async function (commandName, args, result, error) {
318
-
319
- // url -> set configuration first
320
- if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
321
- await browser.executeAsync(function(done) {
322
- window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
323
- done();
324
- });
325
- }
326
-
327
- const waitFor = [
328
- "addValue",
329
- "clearValue",
330
- "click",
331
- "doubleClick",
332
- "dragAndDrop",
333
- "pause",
334
- "removeAttribute", // custom
335
- "scrollIntoView",
336
- "setAttribute", // custom
337
- "setProperty", // custom
338
- "setValue",
339
- "setWindowSize",
340
- "touchAction",
341
- "url",
342
- ];
343
-
344
- const waitForWithDelay = [
345
- "keys",
346
- ];
347
-
348
- if (waitFor.includes(commandName)) {
349
- await browser.executeAsync(function (done) {
350
- window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
351
- });
352
- } else if (waitForWithDelay.includes(commandName)) {
353
- await browser.executeAsync(function (done) {
354
- setTimeout(() => {
355
- window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
356
- }, 10);
357
- });
358
- }
359
- },
360
- /**
361
- * Gets executed after all tests are done. You still have access to all global variables from
362
- * the test.
363
- * @param {Number} result 0 - test pass, 1 - test fail
364
- * @param {Array.<Object>} capabilities list of capabilities details
365
- * @param {Array.<String>} specs List of spec file paths that ran
366
- */
367
- // after: function (result, capabilities, specs) {
368
- // },
369
- /**
370
- * Gets executed right after terminating the webdriver session.
371
- * @param {Object} config wdio configuration object
372
- * @param {Array.<Object>} capabilities list of capabilities details
373
- * @param {Array.<String>} specs List of spec file paths that ran
374
- */
375
- // afterSession: function (config, capabilities, specs) {
376
- // },
377
- /**
378
- * Gets executed after all workers got shut down and the process is about to exit.
379
- * @param {Object} exitCode 0 - success, 1 - fail
380
- * @param {Object} config wdio configuration object
381
- * @param {Array.<Object>} capabilities list of capabilities details
382
- * @param {<Object>} results object containing test results
383
- */
384
- // onComplete: function(exitCode, config, capabilities, results) {
385
- // },
386
- /**
387
- * Gets executed when a refresh happens.
388
- * @param {String} oldSessionId session ID of the old session
389
- * @param {String} newSessionId session ID of the new session
390
- */
391
- //onReload: function(oldSessionId, newSessionId) {
392
- //}
393
- }
1
+ const dns = require("node:dns");
2
+ const assert = require("chai").assert;
3
+
4
+ exports.config = {
5
+ //
6
+ // ====================
7
+ // Runner Configuration
8
+ // ====================
9
+ //
10
+ // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
11
+ // on a remote machine).
12
+ runner: 'local',
13
+
14
+ //
15
+ // ==================
16
+ // Specify Test Files
17
+ // ==================
18
+ // Define which test specs should run. The pattern is relative to the directory
19
+ // from which `wdio` was called. Notice that, if you are calling `wdio` from an
20
+ // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
21
+ // directory is where your package.json resides, so `wdio` will be called from there.
22
+ //
23
+ specs: [
24
+ './test/specs/**/*.js'
25
+ ],
26
+ // Patterns to exclude.
27
+ exclude: [
28
+ // 'path/to/excluded/files'
29
+ ],
30
+ //
31
+ // ============
32
+ // Capabilities
33
+ // ============
34
+ // Define your capabilities here. WebdriverIO can run multiple capabilities at the same
35
+ // time. Depending on the number of capabilities, WebdriverIO launches several test
36
+ // sessions. Within your capabilities you can overwrite the spec and exclude options in
37
+ // order to group specific specs to a specific capability.
38
+ //
39
+ // First, you can define how many instances should be started at the same time. Let's
40
+ // say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
41
+ // set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
42
+ // files and you set maxInstances to 10, all spec files will get tested at the same time
43
+ // and 30 processes will get spawned. The property handles how many capabilities
44
+ // from the same test should run tests.
45
+ //
46
+ maxInstances: 10,
47
+ //
48
+ // If you have trouble getting all important capabilities together, check out the
49
+ // Sauce Labs platform configurator - a great tool to configure your capabilities:
50
+ // https://docs.saucelabs.com/reference/platforms-configurator
51
+ //
52
+ capabilities: [{
53
+ // maxInstances can get overwritten per capability. So if you have an in-house Selenium
54
+ // grid with only 5 firefox instances available you can make sure that not more than
55
+ // 5 instances get started at a time.
56
+ maxInstances: 5,
57
+ //
58
+ browserName: 'chrome',
59
+ 'goog:chromeOptions': {
60
+ // to run chrome headless the following flags are required
61
+ // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
62
+ args: [
63
+ '--headless',
64
+ '--disable-search-engine-choice-screen',
65
+ '--start-maximized',
66
+ '--no-sandbox',
67
+ '--disable-gpu',
68
+ '--disable-infobars',
69
+ '--disable-extensions',
70
+ '--disable-dev-shm-usage',
71
+ ],
72
+ // args: ['--disable-gpu'],
73
+ }
74
+ }],
75
+ //
76
+ // port to find chromedriver
77
+ port: 9515, // default
78
+ // ===================
79
+ // Test Configurations
80
+ // ===================
81
+ // Define all options that are relevant for the WebdriverIO instance here
82
+ //
83
+ // Level of logging verbosity: trace | debug | info | warn | error
84
+ logLevel: 'error',
85
+ //
86
+ // Warns when a deprecated command is used
87
+ deprecationWarnings: true,
88
+ //
89
+ // If you only want to run your tests until a specific amount of tests have failed use
90
+ // bail (default is 0 - don't bail, run all tests).
91
+ bail: 0,
92
+ //
93
+ // Set a base URL in order to shorten url command calls. If your `url` parameter starts
94
+ // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
95
+ // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
96
+ // gets prepended directly.
97
+ baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
98
+ path: '',
99
+ //
100
+ // Default timeout for all waitFor* commands.
101
+ waitforTimeout: 10000,
102
+ //
103
+ // Default timeout in milliseconds for request
104
+ // if Selenium Grid doesn't send response
105
+ connectionRetryTimeout: 90000,
106
+ //
107
+ // Default request retries count
108
+ connectionRetryCount: 3,
109
+ //
110
+ // Test runner services
111
+ // Services take over a specific job you don't want to take care of. They enhance
112
+ // your test setup with almost no effort. Unlike plugins, they don't add new
113
+ // commands. Instead, they hook themselves up into the test process.
114
+ services: ['chromedriver', ['static-server', {
115
+ folders: [
116
+ { mount: '/', path: './dist' },
117
+ ],
118
+ port: '4567',
119
+ }],
120
+ ],
121
+ // options
122
+ chromeDriverArgs: ['--port=9515'], // default
123
+ // Framework you want to run your specs with.
124
+ // The following are supported: Mocha, Jasmine, and Cucumber
125
+ // see also: https://webdriver.io/docs/frameworks.html
126
+ //
127
+ // Make sure you have the wdio adapter package for the specific framework installed
128
+ // before running any tests.
129
+ framework: 'mocha',
130
+ //
131
+ // Test reporter for stdout.
132
+ // The only one supported by default is 'dot'
133
+ // see also: https://webdriver.io/docs/dot-reporter.html
134
+ reporters: ['dot', 'spec'],
135
+
136
+ //
137
+ // Options to be passed to Mocha.
138
+ // See the full list at http://mochajs.org/
139
+ mochaOpts: {
140
+ ui: 'bdd',
141
+ timeout: 60000
142
+ },
143
+ //
144
+ // =====
145
+ // Hooks
146
+ // =====
147
+ // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
148
+ // it and to build services around it. You can either apply a single function or an array of
149
+ // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
150
+ // resolved to continue.
151
+ /**
152
+ * Gets executed once before all workers get launched.
153
+ * @param {Object} config wdio configuration object
154
+ * @param {Array.<Object>} capabilities list of capabilities details
155
+ */
156
+ // onPrepare: function (config, capabilities) {
157
+ // },
158
+ /**
159
+ * Gets executed just before initialising the webdriver session and test framework. It allows you
160
+ * to manipulate configurations depending on the capability or spec.
161
+ * @param {Object} config wdio configuration object
162
+ * @param {Array.<Object>} capabilities list of capabilities details
163
+ * @param {Array.<String>} specs List of spec file paths that are to be run
164
+ */
165
+ // beforeSession: function (config, capabilities, specs) {
166
+ // },
167
+ beforeSession: () => {
168
+ dns.setDefaultResultOrder('ipv4first');
169
+ },
170
+ /**
171
+ * Gets executed before test execution begins. At this point you can access to all global
172
+ * variables like `browser`. It is the perfect place to define custom commands.
173
+ * @param {Array.<Object>} capabilities list of capabilities details
174
+ * @param {Array.<String>} specs List of spec file paths that are to be run
175
+ */
176
+ before: async function (capabilities, specs) {
177
+ await browser.addCommand("isFocusedDeep", async function () {
178
+ return browser.executeAsync(function (elem, done) {
179
+ let activeElement = document.activeElement;
180
+
181
+ while (activeElement.shadowRoot) {
182
+ if (activeElement.shadowRoot.activeElement) {
183
+ activeElement = activeElement.shadowRoot.activeElement;
184
+ } else {
185
+ break;
186
+ }
187
+ }
188
+ done(elem === activeElement);
189
+ }, this);
190
+ }, true);
191
+
192
+ await browser.addCommand("isFocusedDeepElement", async function (element) {
193
+ return browser.executeAsync(function (elem, element, done) {
194
+ let activeElement = document.activeElement;
195
+
196
+ while (activeElement.shadowRoot) {
197
+ if (activeElement.shadowRoot.activeElement) {
198
+ activeElement = activeElement.shadowRoot.activeElement;
199
+ } else {
200
+ break;
201
+ }
202
+ }
203
+ done(element === activeElement);
204
+ }, this, element);
205
+ }, true);
206
+
207
+ await browser.addCommand("setProperty", async function(property, value) {
208
+ return browser.executeAsync((elem, property, value, done) => {
209
+ elem[property] = value;
210
+ done();
211
+ }, this, property, value);
212
+ }, true);
213
+
214
+ await browser.addCommand("setAttribute", async function(attribute, value) {
215
+ return browser.executeAsync((elem, attribute, value, done) => {
216
+ elem.setAttribute(attribute, value);
217
+ done();
218
+ }, this, attribute, value);
219
+ }, true);
220
+
221
+ await browser.addCommand("removeAttribute", async function(attribute) {
222
+ return browser.executeAsync((elem, attribute, done) => {
223
+ elem.removeAttribute(attribute);
224
+ done();
225
+ }, this, attribute);
226
+ }, true);
227
+
228
+ await browser.addCommand("hasClass", async function(className) {
229
+ return browser.executeAsync((elem, className, done) => {
230
+ done(elem.classList.contains(className));
231
+ }, this, className);
232
+ }, true);
233
+
234
+ await browser.addCommand("hasAttribute", async function(attrName) {
235
+ return browser.executeAsync((elem, attrName, done) => {
236
+ done(elem.hasAttribute(attrName));
237
+ }, this, attrName);
238
+ }, true);
239
+
240
+ await browser.addCommand("matches", async function(selector) {
241
+ return browser.executeAsync((elem, selector, done) => {
242
+ done(elem.matches(selector));
243
+ }, this, selector);
244
+ }, true);
245
+
246
+ await browser.addLocatorStrategy('activeElement', (selector) => {
247
+ return document.querySelector(selector).shadowRoot.activeElement;
248
+ });
249
+ },
250
+ /**
251
+ * Runs before a WebdriverIO command gets executed.
252
+ * @param {String} commandName hook command name
253
+ * @param {Array} args arguments that command would receive
254
+ */
255
+ beforeCommand: async function (commandName, args) {
256
+ const waitFor = [
257
+ "$",
258
+ "$$",
259
+ "getAttribute",
260
+ "hasAttribute", // custom
261
+ "matches", // custom
262
+ "getCSSProperty",
263
+ "getHTML",
264
+ "getProperty",
265
+ "getSize",
266
+ "getText",
267
+ "getValue",
268
+ "hasClass", // custom
269
+ "isDisplayed",
270
+ "isDisplayedInViewport",
271
+ "isEnabled",
272
+ "isExisting",
273
+ "isFocused",
274
+ "isFocusedDeep", // custom
275
+ "isFocusedDeepElement", // custom
276
+ "shadow$",
277
+ "shadow$$"
278
+ ];
279
+ if (waitFor.includes(commandName)) {
280
+ await browser.executeAsync(function (done) {
281
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
282
+ });
283
+ }
284
+ },
285
+
286
+ /**
287
+ * Hook that gets executed before the suite starts
288
+ * @param {Object} suite suite details
289
+ */
290
+ // beforeSuite: function (suite) {
291
+ // },
292
+ /**
293
+ * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
294
+ * @param {Object} test test details
295
+ */
296
+ // beforeTest: function (test) {
297
+ // },
298
+ /**
299
+ * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
300
+ * beforeEach in Mocha)
301
+ */
302
+ // beforeHook: function () {
303
+ // },
304
+ /**
305
+ * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
306
+ * afterEach in Mocha)
307
+ */
308
+ // afterHook: function () {
309
+ // },
310
+ /**
311
+ * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
312
+ * @param {Object} test test details
313
+ */
314
+ afterTest: async function (test) {
315
+ // fetch the browser logs and fail the test if there are `console.error` messages with the `[UI5-FWK]` marker
316
+ const logs = await browser.getLogs('browser');
317
+ const severeLogs = logs
318
+ .filter(l => l.level === "SEVERE" && l.message.includes("[UI5-FWK]"))
319
+ .map(l => l.message);
320
+
321
+ if (severeLogs.length) {
322
+ test.callback(new Error(`[${test.title}]\n\n ${severeLogs.join("\n ")}`));
323
+ }
324
+ },
325
+ /**
326
+ * Hook that gets executed after the suite has ended
327
+ * @param {Object} suite suite details
328
+ */
329
+ // afterSuite: function (suite) {
330
+ // },
331
+
332
+ /**
333
+ * Runs after a WebdriverIO command gets executed
334
+ * @param {String} commandName hook command name
335
+ * @param {Array} args arguments that command would receive
336
+ * @param {Number} result 0 - command success, 1 - command error
337
+ * @param {Object} error error object if any
338
+ */
339
+ afterCommand: async function (commandName, args, result, error) {
340
+
341
+ // url -> set configuration first
342
+ if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
343
+ await browser.executeAsync(function(done) {
344
+ window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
345
+ done();
346
+ });
347
+ }
348
+
349
+ const waitFor = [
350
+ "addValue",
351
+ "clearValue",
352
+ "click",
353
+ "doubleClick",
354
+ "dragAndDrop",
355
+ "pause",
356
+ "removeAttribute", // custom
357
+ "scrollIntoView",
358
+ "setAttribute", // custom
359
+ "setProperty", // custom
360
+ "setValue",
361
+ "setWindowSize",
362
+ "touchAction",
363
+ "url",
364
+ ];
365
+
366
+ const waitForWithDelay = [
367
+ "keys",
368
+ ];
369
+
370
+ if (waitFor.includes(commandName)) {
371
+ await browser.executeAsync(function (done) {
372
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
373
+ });
374
+ } else if (waitForWithDelay.includes(commandName)) {
375
+ await browser.executeAsync(function (done) {
376
+ setTimeout(() => {
377
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
378
+ }, 10);
379
+ });
380
+ }
381
+ },
382
+ /**
383
+ * Gets executed after all tests are done. You still have access to all global variables from
384
+ * the test.
385
+ * @param {Number} result 0 - test pass, 1 - test fail
386
+ * @param {Array.<Object>} capabilities list of capabilities details
387
+ * @param {Array.<String>} specs List of spec file paths that ran
388
+ */
389
+ // after: function (result, capabilities, specs) {
390
+ // },
391
+ /**
392
+ * Gets executed right after terminating the webdriver session.
393
+ * @param {Object} config wdio configuration object
394
+ * @param {Array.<Object>} capabilities list of capabilities details
395
+ * @param {Array.<String>} specs List of spec file paths that ran
396
+ */
397
+ // afterSession: function (config, capabilities, specs) {
398
+ // },
399
+ /**
400
+ * Gets executed after all workers got shut down and the process is about to exit.
401
+ * @param {Object} exitCode 0 - success, 1 - fail
402
+ * @param {Object} config wdio configuration object
403
+ * @param {Array.<Object>} capabilities list of capabilities details
404
+ * @param {<Object>} results object containing test results
405
+ */
406
+ // onComplete: function(exitCode, config, capabilities, results) {
407
+ // },
408
+ /**
409
+ * Gets executed when a refresh happens.
410
+ * @param {String} oldSessionId session ID of the old session
411
+ * @param {String} newSessionId session ID of the new session
412
+ */
413
+ //onReload: function(oldSessionId, newSessionId) {
414
+ //}
415
+ }