@ui5/webcomponents-tools 0.0.0-fd9a5462d → 0.0.0-ff1549e7b

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 (89) hide show
  1. package/CHANGELOG.md +531 -0
  2. package/README.md +5 -6
  3. package/assets-meta.js +18 -1
  4. package/bin/dev.js +6 -5
  5. package/components-package/eslint.js +34 -0
  6. package/components-package/nps.js +109 -42
  7. package/components-package/postcss.components.js +13 -13
  8. package/components-package/postcss.themes.js +29 -16
  9. package/components-package/vite.config.js +13 -0
  10. package/components-package/wdio.js +401 -344
  11. package/components-package/wdio.sync.js +368 -0
  12. package/icons-collection/nps.js +52 -11
  13. package/lib/copy-and-watch/index.js +30 -5
  14. package/lib/copy-list/index.js +28 -0
  15. package/lib/create-icons/index.js +124 -54
  16. package/lib/create-illustrations/index.js +161 -0
  17. package/lib/create-new-component/index.js +72 -93
  18. package/lib/create-new-component/jsFileContentTemplate.js +73 -0
  19. package/lib/create-new-component/tsFileContentTemplate.js +80 -0
  20. package/lib/dev-server/dev-server.js +66 -0
  21. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  22. package/lib/esm-abs-to-rel/index.js +58 -0
  23. package/lib/generate-custom-elements-manifest/index.js +327 -0
  24. package/lib/generate-js-imports/illustrations.js +72 -0
  25. package/lib/generate-json-imports/i18n.js +74 -32
  26. package/lib/generate-json-imports/themes.js +65 -18
  27. package/lib/hbs2lit/src/compiler.js +24 -4
  28. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  29. package/lib/hbs2lit/src/litVisitor2.js +125 -26
  30. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  31. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +35 -7
  32. package/lib/hbs2ui5/index.js +67 -18
  33. package/lib/i18n/defaults.js +65 -57
  34. package/lib/i18n/toJSON.js +13 -12
  35. package/lib/jsdoc/config.json +1 -1
  36. package/lib/jsdoc/configTypescript.json +29 -0
  37. package/lib/jsdoc/plugin.js +62 -1
  38. package/lib/jsdoc/preprocess.js +146 -0
  39. package/lib/jsdoc/template/publish.js +30 -2
  40. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  41. package/lib/postcss-css-to-esm/index.js +64 -16
  42. package/lib/postcss-css-to-json/index.js +31 -11
  43. package/lib/postcss-new-files/index.js +36 -0
  44. package/lib/postcss-p/postcss-p.mjs +14 -0
  45. package/lib/replace-global-core/index.js +25 -0
  46. package/lib/scoping/get-all-tags.js +37 -0
  47. package/lib/scoping/lint-src.js +31 -0
  48. package/lib/scoping/missing-dependencies.js +65 -0
  49. package/lib/scoping/report-tags-usage.js +28 -0
  50. package/lib/scoping/scope-test-pages.js +40 -0
  51. package/lib/test-runner/test-runner.js +71 -0
  52. package/package.json +54 -53
  53. package/bin/init-ui5-package.js +0 -3
  54. package/components-package/rollup.js +0 -134
  55. package/components-package/serve.json +0 -3
  56. package/lib/documentation/index.js +0 -143
  57. package/lib/documentation/templates/api-component-since.js +0 -3
  58. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  59. package/lib/documentation/templates/api-events-section.js +0 -35
  60. package/lib/documentation/templates/api-methods-section.js +0 -26
  61. package/lib/documentation/templates/api-properties-section.js +0 -40
  62. package/lib/documentation/templates/api-slots-section.js +0 -28
  63. package/lib/documentation/templates/template.js +0 -38
  64. package/lib/init-package/index.js +0 -112
  65. package/lib/init-package/resources/.eslintignore +0 -3
  66. package/lib/init-package/resources/bundle.es5.js +0 -25
  67. package/lib/init-package/resources/bundle.esm.js +0 -34
  68. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  69. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  70. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  71. package/lib/init-package/resources/config/rollup.config.js +0 -1
  72. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  73. package/lib/init-package/resources/package-scripts.js +0 -11
  74. package/lib/init-package/resources/src/Assets.js +0 -5
  75. package/lib/init-package/resources/src/Demo.hbs +0 -1
  76. package/lib/init-package/resources/src/Demo.js +0 -56
  77. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  78. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  79. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  80. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  81. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  82. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  83. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  84. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  85. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  86. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  87. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  88. package/lib/init-package/resources/test/pages/index.html +0 -51
  89. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -1,344 +1,401 @@
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: process.env.TRAVIS ? 1 : 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: '',
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'],
103
- // options
104
- chromeDriverArgs: ['--port=9515'], // default
105
- // Framework you want to run your specs with.
106
- // The following are supported: Mocha, Jasmine, and Cucumber
107
- // see also: https://webdriver.io/docs/frameworks.html
108
- //
109
- // Make sure you have the wdio adapter package for the specific framework installed
110
- // before running any tests.
111
- framework: 'mocha',
112
- //
113
- // Test reporter for stdout.
114
- // The only one supported by default is 'dot'
115
- // see also: https://webdriver.io/docs/dot-reporter.html
116
- reporters: ['dot', 'spec'],
117
-
118
- //
119
- // Options to be passed to Mocha.
120
- // See the full list at http://mochajs.org/
121
- mochaOpts: {
122
- ui: 'bdd',
123
- timeout: 60000
124
- },
125
- //
126
- // =====
127
- // Hooks
128
- // =====
129
- // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
130
- // it and to build services around it. You can either apply a single function or an array of
131
- // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
132
- // resolved to continue.
133
- /**
134
- * Gets executed once before all workers get launched.
135
- * @param {Object} config wdio configuration object
136
- * @param {Array.<Object>} capabilities list of capabilities details
137
- */
138
- // onPrepare: function (config, capabilities) {
139
- // },
140
- /**
141
- * Gets executed just before initialising the webdriver session and test framework. It allows you
142
- * to manipulate configurations depending on the capability or spec.
143
- * @param {Object} config wdio configuration object
144
- * @param {Array.<Object>} capabilities list of capabilities details
145
- * @param {Array.<String>} specs List of spec file paths that are to be run
146
- */
147
- // beforeSession: function (config, capabilities, specs) {
148
- // },
149
- /**
150
- * Gets executed before test execution begins. At this point you can access to all global
151
- * variables like `browser`. It is the perfect place to define custom commands.
152
- * @param {Array.<Object>} capabilities list of capabilities details
153
- * @param {Array.<String>} specs List of spec file paths that are to be run
154
- */
155
- before: function (capabilities, specs) {
156
- browser.addCommand("isFocusedDeep", function () {
157
- return browser.execute(function (elem) {
158
- let activeElement = document.activeElement;
159
-
160
- while (activeElement.shadowRoot) {
161
- if (activeElement.shadowRoot.activeElement) {
162
- activeElement = activeElement.shadowRoot.activeElement;
163
- } else {
164
- break;
165
- }
166
- }
167
- return elem === activeElement;
168
- }, this);
169
- }, true);
170
-
171
- browser.addCommand("setProperty", function(property, value) {
172
- return browser.execute((elem, property, value) => {
173
- return elem[property] = value;
174
- }, this, property, value);
175
- }, true);
176
-
177
- browser.addCommand("setAttribute", function(attribute, value) {
178
- return browser.execute((elem, attribute, value) => {
179
- return elem.setAttribute(attribute, value);
180
- }, this, attribute, value);
181
- }, true);
182
-
183
- browser.addCommand("removeAttribute", function(attribute) {
184
- return browser.execute((elem, attribute) => {
185
- return elem.removeAttribute(attribute);
186
- }, this, attribute);
187
- }, true);
188
-
189
- browser.addCommand("hasClass", function(className) {
190
- return browser.execute((elem, className) => {
191
- return elem.classList.contains(className);
192
- }, this, className);
193
- }, true);
194
-
195
- browser.addCommand("getStaticAreaItemClassName", function(selector) {
196
- return browser.execute(async (selector) => {
197
- const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
198
- return staticAreaItem.host.classList[0];
199
- }, selector);
200
- }, false);
201
- },
202
- /**
203
- * Runs before a WebdriverIO command gets executed.
204
- * @param {String} commandName hook command name
205
- * @param {Array} args arguments that command would receive
206
- */
207
- beforeCommand: function (commandName, args) {
208
- const waitFor = [
209
- "$",
210
- "$$",
211
- "getAttribute",
212
- "getCSSProperty",
213
- "getHTML",
214
- "getProperty",
215
- "getSize",
216
- "getStaticAreaItemClassName", // custom
217
- "getText",
218
- "getValue",
219
- "hasClass", // custom
220
- "isDisplayed",
221
- "isDisplayedInViewport",
222
- "isEnabled",
223
- "isExisting",
224
- "isFocused",
225
- "isFocusedDeep", // custom
226
- "shadow$",
227
- "shadow$$",
228
- ];
229
- if (waitFor.includes(commandName)) {
230
- browser.executeAsync(function (done) {
231
- window.RenderScheduler.whenFinished().then(done);
232
- });
233
- }
234
- },
235
-
236
- /**
237
- * Hook that gets executed before the suite starts
238
- * @param {Object} suite suite details
239
- */
240
- // beforeSuite: function (suite) {
241
- // },
242
- /**
243
- * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
244
- * @param {Object} test test details
245
- */
246
- // beforeTest: function (test) {
247
- // },
248
- /**
249
- * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
250
- * beforeEach in Mocha)
251
- */
252
- // beforeHook: function () {
253
- // },
254
- /**
255
- * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
256
- * afterEach in Mocha)
257
- */
258
- // afterHook: function () {
259
- // },
260
- /**
261
- * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
262
- * @param {Object} test test details
263
- */
264
- // afterTest: function (test) {
265
- // },
266
- /**
267
- * Hook that gets executed after the suite has ended
268
- * @param {Object} suite suite details
269
- */
270
- // afterSuite: function (suite) {
271
- // },
272
-
273
- /**
274
- * Runs after a WebdriverIO command gets executed
275
- * @param {String} commandName hook command name
276
- * @param {Array} args arguments that command would receive
277
- * @param {Number} result 0 - command success, 1 - command error
278
- * @param {Object} error error object if any
279
- */
280
- afterCommand: function (commandName, args, result, error) {
281
-
282
- // url -> set configuration first
283
- if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
284
- browser.execute(function() {
285
- window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
286
- });
287
- }
288
-
289
- const waitFor = [
290
- "addValue",
291
- "clearValue",
292
- "click",
293
- "doubleClick",
294
- "dragAndDrop",
295
- "keys",
296
- "pause",
297
- "removeAttribute", // custom
298
- "setAttribute", // custom
299
- "setProperty", // custom
300
- "setValue",
301
- "setWindowSize",
302
- "touchAction",
303
- "url"
304
- ];
305
- if (waitFor.includes(commandName)) {
306
- browser.executeAsync(function (done) {
307
- window.RenderScheduler.whenFinished().then(done);
308
- });
309
- }
310
- },
311
- /**
312
- * Gets executed after all tests are done. You still have access to all global variables from
313
- * the test.
314
- * @param {Number} result 0 - test pass, 1 - test fail
315
- * @param {Array.<Object>} capabilities list of capabilities details
316
- * @param {Array.<String>} specs List of spec file paths that ran
317
- */
318
- // after: function (result, capabilities, specs) {
319
- // },
320
- /**
321
- * Gets executed right after terminating the webdriver session.
322
- * @param {Object} config wdio configuration object
323
- * @param {Array.<Object>} capabilities list of capabilities details
324
- * @param {Array.<String>} specs List of spec file paths that ran
325
- */
326
- // afterSession: function (config, capabilities, specs) {
327
- // },
328
- /**
329
- * Gets executed after all workers got shut down and the process is about to exit.
330
- * @param {Object} exitCode 0 - success, 1 - fail
331
- * @param {Object} config wdio configuration object
332
- * @param {Array.<Object>} capabilities list of capabilities details
333
- * @param {<Object>} results object containing test results
334
- */
335
- // onComplete: function(exitCode, config, capabilities, results) {
336
- // },
337
- /**
338
- * Gets executed when a refresh happens.
339
- * @param {String} oldSessionId session ID of the old session
340
- * @param {String} newSessionId session ID of the new session
341
- */
342
- //onReload: function(oldSessionId, newSessionId) {
343
- //}
344
- }
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: [
60
+ '--headless',
61
+ '--start-maximized',
62
+ '--no-sandbox',
63
+ '--disable-gpu',
64
+ '--disable-infobars',
65
+ '--disable-extensions',
66
+ '--disable-dev-shm-usage',
67
+ ],
68
+ // args: ['--disable-gpu'],
69
+ }
70
+ }],
71
+ //
72
+ // port to find chromedriver
73
+ port: 9515, // default
74
+ // ===================
75
+ // Test Configurations
76
+ // ===================
77
+ // Define all options that are relevant for the WebdriverIO instance here
78
+ //
79
+ // Level of logging verbosity: trace | debug | info | warn | error
80
+ logLevel: 'error',
81
+ //
82
+ // Warns when a deprecated command is used
83
+ deprecationWarnings: true,
84
+ //
85
+ // If you only want to run your tests until a specific amount of tests have failed use
86
+ // bail (default is 0 - don't bail, run all tests).
87
+ bail: 0,
88
+ //
89
+ // Set a base URL in order to shorten url command calls. If your `url` parameter starts
90
+ // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
91
+ // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
92
+ // gets prepended directly.
93
+ baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
94
+ path: '',
95
+ //
96
+ // Default timeout for all waitFor* commands.
97
+ waitforTimeout: 10000,
98
+ //
99
+ // Default timeout in milliseconds for request
100
+ // if Selenium Grid doesn't send response
101
+ connectionRetryTimeout: 90000,
102
+ //
103
+ // Default request retries count
104
+ connectionRetryCount: 3,
105
+ //
106
+ // Test runner services
107
+ // Services take over a specific job you don't want to take care of. They enhance
108
+ // your test setup with almost no effort. Unlike plugins, they don't add new
109
+ // commands. Instead, they hook themselves up into the test process.
110
+ services: ['chromedriver', 'devtools',
111
+ ['static-server', {
112
+ folders: [
113
+ { mount: '/', path: './dist' },
114
+ ],
115
+ port: '4567',
116
+ }],
117
+ ],
118
+ // options
119
+ chromeDriverArgs: ['--port=9515'], // default
120
+ // Framework you want to run your specs with.
121
+ // The following are supported: Mocha, Jasmine, and Cucumber
122
+ // see also: https://webdriver.io/docs/frameworks.html
123
+ //
124
+ // Make sure you have the wdio adapter package for the specific framework installed
125
+ // before running any tests.
126
+ framework: 'mocha',
127
+ //
128
+ // Test reporter for stdout.
129
+ // The only one supported by default is 'dot'
130
+ // see also: https://webdriver.io/docs/dot-reporter.html
131
+ reporters: ['dot', 'spec'],
132
+
133
+ //
134
+ // Options to be passed to Mocha.
135
+ // See the full list at http://mochajs.org/
136
+ mochaOpts: {
137
+ ui: 'bdd',
138
+ timeout: 60000
139
+ },
140
+ //
141
+ // =====
142
+ // Hooks
143
+ // =====
144
+ // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
145
+ // it and to build services around it. You can either apply a single function or an array of
146
+ // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
147
+ // resolved to continue.
148
+ /**
149
+ * Gets executed once before all workers get launched.
150
+ * @param {Object} config wdio configuration object
151
+ * @param {Array.<Object>} capabilities list of capabilities details
152
+ */
153
+ // onPrepare: function (config, capabilities) {
154
+ // },
155
+ /**
156
+ * Gets executed just before initialising the webdriver session and test framework. It allows you
157
+ * to manipulate configurations depending on the capability or spec.
158
+ * @param {Object} config wdio configuration object
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
+ // beforeSession: function (config, capabilities, specs) {
163
+ // },
164
+ /**
165
+ * Gets executed before test execution begins. At this point you can access to all global
166
+ * variables like `browser`. It is the perfect place to define custom commands.
167
+ * @param {Array.<Object>} capabilities list of capabilities details
168
+ * @param {Array.<String>} specs List of spec file paths that are to be run
169
+ */
170
+ before: async function (capabilities, specs) {
171
+ await browser.addCommand("isFocusedDeep", async function () {
172
+ return browser.executeAsync(function (elem, done) {
173
+ let activeElement = document.activeElement;
174
+
175
+ while (activeElement.shadowRoot) {
176
+ if (activeElement.shadowRoot.activeElement) {
177
+ activeElement = activeElement.shadowRoot.activeElement;
178
+ } else {
179
+ break;
180
+ }
181
+ }
182
+ done(elem === activeElement);
183
+ }, this);
184
+ }, true);
185
+
186
+ await browser.addCommand("isFocusedDeepElement", async function (element) {
187
+ return browser.executeAsync(function (elem, element, done) {
188
+ let activeElement = document.activeElement;
189
+
190
+ while (activeElement.shadowRoot) {
191
+ if (activeElement.shadowRoot.activeElement) {
192
+ activeElement = activeElement.shadowRoot.activeElement;
193
+ } else {
194
+ break;
195
+ }
196
+ }
197
+ done(element === activeElement);
198
+ }, this, element);
199
+ }, true);
200
+
201
+ await browser.addCommand("setProperty", async function(property, value) {
202
+ return browser.executeAsync((elem, property, value, done) => {
203
+ elem[property] = value;
204
+ done();
205
+ }, this, property, value);
206
+ }, true);
207
+
208
+ await browser.addCommand("setAttribute", async function(attribute, value) {
209
+ return browser.executeAsync((elem, attribute, value, done) => {
210
+ elem.setAttribute(attribute, value);
211
+ done();
212
+ }, this, attribute, value);
213
+ }, true);
214
+
215
+ await browser.addCommand("removeAttribute", async function(attribute) {
216
+ return browser.executeAsync((elem, attribute, done) => {
217
+ elem.removeAttribute(attribute);
218
+ done();
219
+ }, this, attribute);
220
+ }, true);
221
+
222
+ await browser.addCommand("hasClass", async function(className) {
223
+ return browser.executeAsync((elem, className, done) => {
224
+ done(elem.classList.contains(className));
225
+ }, this, className);
226
+ }, true);
227
+
228
+ await browser.addCommand("hasAttribute", async function(attrName) {
229
+ return browser.executeAsync((elem, attrName, done) => {
230
+ done(elem.hasAttribute(attrName));
231
+ }, this, attrName);
232
+ }, true);
233
+
234
+ await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
235
+ return browser.executeAsync(async (selector, done) => {
236
+ const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
237
+ done(staticAreaItem.host.classList[0]);
238
+ }, selector);
239
+ }, false);
240
+
241
+ await browser.addLocatorStrategy('activeElement', (selector) => {
242
+ return document.querySelector(selector).shadowRoot.activeElement;
243
+ });
244
+ },
245
+ /**
246
+ * Runs before a WebdriverIO command gets executed.
247
+ * @param {String} commandName hook command name
248
+ * @param {Array} args arguments that command would receive
249
+ */
250
+ beforeCommand: async function (commandName, args) {
251
+ const waitFor = [
252
+ "$",
253
+ "$$",
254
+ "getAttribute",
255
+ "hasAttribute", // custom
256
+ "getCSSProperty",
257
+ "getHTML",
258
+ "getProperty",
259
+ "getSize",
260
+ "getStaticAreaItemClassName", // custom
261
+ "getText",
262
+ "getValue",
263
+ "hasClass", // custom
264
+ "isDisplayed",
265
+ "isDisplayedInViewport",
266
+ "isEnabled",
267
+ "isExisting",
268
+ "isFocused",
269
+ "isFocusedDeep", // custom
270
+ "isFocusedDeepElement", // custom
271
+ "shadow$",
272
+ "shadow$$",
273
+ ];
274
+ if (waitFor.includes(commandName)) {
275
+ await browser.executeAsync(function (done) {
276
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
277
+ });
278
+ }
279
+ },
280
+
281
+ /**
282
+ * Hook that gets executed before the suite starts
283
+ * @param {Object} suite suite details
284
+ */
285
+ // beforeSuite: function (suite) {
286
+ // },
287
+ /**
288
+ * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
289
+ * @param {Object} test test details
290
+ */
291
+ // beforeTest: function (test) {
292
+ // },
293
+ /**
294
+ * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
295
+ * beforeEach in Mocha)
296
+ */
297
+ // beforeHook: function () {
298
+ // },
299
+ /**
300
+ * Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
301
+ * afterEach in Mocha)
302
+ */
303
+ // afterHook: function () {
304
+ // },
305
+ /**
306
+ * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
307
+ * @param {Object} test test details
308
+ */
309
+ // afterTest: function (test) {
310
+ // },
311
+ /**
312
+ * Hook that gets executed after the suite has ended
313
+ * @param {Object} suite suite details
314
+ */
315
+ // afterSuite: function (suite) {
316
+ // },
317
+
318
+ /**
319
+ * Runs after a WebdriverIO command gets executed
320
+ * @param {String} commandName hook command name
321
+ * @param {Array} args arguments that command would receive
322
+ * @param {Number} result 0 - command success, 1 - command error
323
+ * @param {Object} error error object if any
324
+ */
325
+ afterCommand: async function (commandName, args, result, error) {
326
+
327
+ // url -> set configuration first
328
+ if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
329
+ await browser.executeAsync(function(done) {
330
+ window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
331
+ done();
332
+ });
333
+ }
334
+
335
+ const waitFor = [
336
+ "addValue",
337
+ "clearValue",
338
+ "click",
339
+ "doubleClick",
340
+ "dragAndDrop",
341
+ "pause",
342
+ "removeAttribute", // custom
343
+ "scrollIntoView",
344
+ "setAttribute", // custom
345
+ "setProperty", // custom
346
+ "setValue",
347
+ "setWindowSize",
348
+ "touchAction",
349
+ "url",
350
+ ];
351
+
352
+ const waitForWithDelay = [
353
+ "keys",
354
+ ];
355
+
356
+ if (waitFor.includes(commandName)) {
357
+ await browser.executeAsync(function (done) {
358
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
359
+ });
360
+ } else if (waitForWithDelay.includes(commandName)) {
361
+ await browser.executeAsync(function (done) {
362
+ setTimeout(() => {
363
+ window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
364
+ }, 10);
365
+ });
366
+ }
367
+ },
368
+ /**
369
+ * Gets executed after all tests are done. You still have access to all global variables from
370
+ * the test.
371
+ * @param {Number} result 0 - test pass, 1 - test fail
372
+ * @param {Array.<Object>} capabilities list of capabilities details
373
+ * @param {Array.<String>} specs List of spec file paths that ran
374
+ */
375
+ // after: function (result, capabilities, specs) {
376
+ // },
377
+ /**
378
+ * Gets executed right after terminating the webdriver session.
379
+ * @param {Object} config wdio configuration object
380
+ * @param {Array.<Object>} capabilities list of capabilities details
381
+ * @param {Array.<String>} specs List of spec file paths that ran
382
+ */
383
+ // afterSession: function (config, capabilities, specs) {
384
+ // },
385
+ /**
386
+ * Gets executed after all workers got shut down and the process is about to exit.
387
+ * @param {Object} exitCode 0 - success, 1 - fail
388
+ * @param {Object} config wdio configuration object
389
+ * @param {Array.<Object>} capabilities list of capabilities details
390
+ * @param {<Object>} results object containing test results
391
+ */
392
+ // onComplete: function(exitCode, config, capabilities, results) {
393
+ // },
394
+ /**
395
+ * Gets executed when a refresh happens.
396
+ * @param {String} oldSessionId session ID of the old session
397
+ * @param {String} newSessionId session ID of the new session
398
+ */
399
+ //onReload: function(oldSessionId, newSessionId) {
400
+ //}
401
+ }