@ui5/webcomponents-tools 0.0.0-8db0ce01a → 0.0.0-8dc1dc294
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/CHANGELOG.md +361 -0
- package/README.md +5 -6
- package/assets-meta.js +7 -1
- package/bin/dev.js +1 -5
- package/components-package/eslint.js +34 -0
- package/components-package/nps.js +92 -54
- package/components-package/postcss.components.js +13 -13
- package/components-package/postcss.themes.js +19 -16
- package/components-package/vite.config.js +12 -0
- package/components-package/wdio.js +87 -31
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +46 -15
- package/lib/copy-and-watch/index.js +24 -1
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +124 -58
- package/lib/create-illustrations/index.js +161 -0
- package/lib/create-new-component/index.js +108 -103
- package/lib/create-new-component/jsFileContentTemplate.js +77 -0
- package/lib/create-new-component/tsFileContentTemplate.js +84 -0
- package/lib/dev-server/dev-server.js +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +53 -0
- package/lib/esm-abs-to-rel/index.js +58 -0
- package/lib/generate-custom-elements-manifest/index.js +327 -0
- package/lib/generate-js-imports/illustrations.js +72 -0
- package/lib/generate-json-imports/i18n.js +38 -31
- package/lib/generate-json-imports/themes.js +31 -24
- package/lib/hbs2lit/src/compiler.js +20 -3
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +77 -14
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +4 -11
- package/lib/hbs2ui5/index.js +37 -21
- package/lib/i18n/defaults.js +65 -57
- package/lib/i18n/toJSON.js +12 -11
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +41 -0
- package/lib/jsdoc/preprocess.js +146 -0
- package/lib/jsdoc/template/publish.js +21 -2
- package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-css-to-esm/index.js +53 -8
- package/lib/postcss-css-to-json/index.js +18 -2
- package/lib/postcss-p/postcss-p.mjs +14 -0
- package/lib/replace-global-core/index.js +25 -0
- package/lib/scoping/get-all-tags.js +1 -8
- package/lib/scoping/lint-src.js +1 -1
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +1 -1
- package/lib/test-runner/test-runner.js +63 -0
- package/package.json +35 -42
- package/bin/init-ui5-package.js +0 -3
- package/components-package/rollup.js +0 -195
- package/lib/documentation/index.js +0 -165
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -40
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -38
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/init-package/index.js +0 -123
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.es5.js +0 -25
- package/lib/init-package/resources/bundle.esm.js +0 -31
- package/lib/init-package/resources/config/.eslintrc.js +0 -1
- package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
- package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
- package/lib/init-package/resources/config/rollup.config.js +0 -1
- package/lib/init-package/resources/config/wdio.conf.js +0 -1
- package/lib/init-package/resources/package-scripts.js +0 -11
- package/lib/init-package/resources/src/Assets.js +0 -5
- package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
- package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
- package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
- package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
- package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
- package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -56
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
@@ -1,35 +1,79 @@
|
|
1
1
|
const path = require("path");
|
2
2
|
const fs = require("fs");
|
3
|
-
|
3
|
+
const resolve = require("resolve");
|
4
4
|
const LIB = path.join(__dirname, `../lib/`);
|
5
|
-
const
|
6
|
-
const polyfillPath = path.join(polyfillDir, "{*.js,*.map,*.md,bundles/**/*.*}");
|
7
|
-
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
5
|
+
const preprocessJSDocScript = resolve.sync("@ui5/webcomponents-tools/lib/jsdoc/preprocess.js");
|
8
6
|
|
9
7
|
const getScripts = (options) => {
|
10
8
|
|
11
|
-
|
12
|
-
const
|
9
|
+
// The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
|
10
|
+
const illustrationsData = options.illustrationsData || [];
|
11
|
+
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath}`);
|
12
|
+
const createIllustrationsJSImportsScript = illustrations.join(" && ");
|
13
|
+
|
14
|
+
// The script creates the "dist/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
15
|
+
const illustrationDestinationPaths = illustrationsData.map(illustrations => illustrations.destinationPath);
|
16
|
+
const createIllustrationsLoadersScript = options.fioriPackage ? `node ${LIB}/generate-js-imports/illustrations.js ${illustrationDestinationPaths[0]} ${illustrationDestinationPaths[1]} dist/generated/js-imports` : "";
|
17
|
+
const tsOption = options.typescript;
|
18
|
+
const tsCommand = tsOption ? "tsc" : "";
|
19
|
+
const tsWatchCommand = tsOption ? "tsc --watch" : "";
|
20
|
+
const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
|
21
|
+
const copySrcGenerated = tsOption ? "" : "copy.srcGenerated";
|
22
|
+
|
23
|
+
if (tsOption) {
|
24
|
+
try {
|
25
|
+
require("typescript");
|
26
|
+
} catch(e) {
|
27
|
+
console.error(`TypeScript is not found. Try to install it by running \`npm install --save-dev typescript\` if you are using npm or by running \`yarn add --dev typescript\` if you are using yarn.`);
|
28
|
+
process.exit(e.code);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
let viteConfig;
|
33
|
+
if (fs.existsSync("config/vite.config.js")) {
|
34
|
+
// old project setup where config file is in separate folder
|
35
|
+
viteConfig = "-c config/vite.config.js";
|
36
|
+
} else if (fs.existsSync("vite.config.js")) {
|
37
|
+
// preferred way of custom configuration in root project folder
|
38
|
+
viteConfig = "";
|
39
|
+
} else {
|
40
|
+
// no custom configuration - use default from tools project
|
41
|
+
viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
|
42
|
+
}
|
43
|
+
|
44
|
+
let eslintConfig;
|
45
|
+
if (fs.existsSync("config/.eslintrc.js")) {
|
46
|
+
// old project setup where config file is in separate folder
|
47
|
+
eslintConfig = "--config config/.eslintrc.js";
|
48
|
+
} else if (fs.existsSync(".eslintrc.js")) {
|
49
|
+
// preferred way of custom configuration in root project folder
|
50
|
+
eslintConfig = "";
|
51
|
+
} else {
|
52
|
+
// no custom configuration - use default from tools project
|
53
|
+
eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
|
54
|
+
}
|
13
55
|
|
14
56
|
const scripts = {
|
15
|
-
clean:
|
16
|
-
lint:
|
17
|
-
lintfix:
|
57
|
+
clean: 'rimraf jsdoc-dist && rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
|
58
|
+
lint: `eslint . ${eslintConfig}`,
|
59
|
+
lintfix: `eslint . ${eslintConfig} --fix`,
|
18
60
|
prepare: {
|
19
|
-
default:
|
20
|
-
|
61
|
+
default: `${tsCrossEnv} nps clean prepare.all typescript generateAPI`,
|
62
|
+
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copy" "nps build.illustrations"',
|
63
|
+
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
21
64
|
},
|
65
|
+
typescript: tsCommand,
|
22
66
|
build: {
|
23
|
-
default: "nps lint
|
67
|
+
default: "nps prepare lint build.bundle",
|
24
68
|
templates: `mkdirp dist/generated/templates && node "${LIB}/hbs2ui5/index.js" -d src/ -o dist/generated/templates`,
|
25
69
|
styles: {
|
26
|
-
default:
|
27
|
-
themes: "postcss
|
70
|
+
default: `nps build.styles.themes build.styles.components ${copySrcGenerated}`,
|
71
|
+
themes: `node "${LIB}/postcss-p/postcss-p.mjs"`,
|
28
72
|
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
29
73
|
},
|
30
74
|
i18n: {
|
31
75
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
32
|
-
defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n
|
76
|
+
defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
33
77
|
json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
34
78
|
},
|
35
79
|
jsonImports: {
|
@@ -37,32 +81,26 @@ const getScripts = (options) => {
|
|
37
81
|
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes dist/generated/json-imports`,
|
38
82
|
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n dist/generated/json-imports`,
|
39
83
|
},
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
84
|
+
jsImports: {
|
85
|
+
default: "mkdirp dist/generated/js-imports && nps build.jsImports.illustrationsLoaders",
|
86
|
+
illustrationsLoaders: createIllustrationsLoadersScript,
|
87
|
+
},
|
88
|
+
bundle: `vite build ${viteConfig}`,
|
89
|
+
illustrations: createIllustrationsJSImportsScript,
|
46
90
|
},
|
47
91
|
copy: {
|
48
|
-
default: "nps copy.src copy.props
|
49
|
-
es5: "nps copy.src copy.props copy.test copy.webcomponents-polyfill",
|
92
|
+
default: "nps copy.src copy.props",
|
50
93
|
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
94
|
+
srcGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.js" dist/generated/`,
|
51
95
|
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.properties" dist/`,
|
52
|
-
test: `node "${LIB}/copy-and-watch/index.js" --silent "test/**/*.*" dist/test-resources`,
|
53
|
-
"webcomponents-polyfill": `node "${LIB}/copy-and-watch/index.js" --silent "${polyfillPath}" dist/webcomponentsjs/`,
|
54
|
-
"webcomponents-polyfill-placeholder": `node ${LIB}/polyfill-placeholder/index.js`
|
55
96
|
},
|
56
97
|
watch: {
|
57
|
-
default:
|
58
|
-
|
98
|
+
default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.typescript" "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
|
99
|
+
devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
|
59
100
|
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
101
|
+
typescript: tsWatchCommand,
|
60
102
|
props: 'nps "copy.props --watch --safe --skip-initial-copy"',
|
61
|
-
|
62
|
-
bundle: {
|
63
|
-
default: 'rollup --config config/rollup.config.js -w --environment DEV,DEPLOY_PUBLIC_PATH:/resources/',
|
64
|
-
es5: 'rollup --config config/rollup.config.js -w --environment ES5_BUILD,DEV,DEPLOY_PUBLIC_PATH:/resources/'
|
65
|
-
},
|
103
|
+
bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
|
66
104
|
styles: {
|
67
105
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
68
106
|
themes: 'nps "build.styles.themes -w"',
|
@@ -73,35 +111,35 @@ const getScripts = (options) => {
|
|
73
111
|
},
|
74
112
|
},
|
75
113
|
templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
|
76
|
-
|
114
|
+
api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
|
77
115
|
i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
|
78
116
|
},
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
}
|
83
|
-
|
84
|
-
serve: `node "${LIB}/serve/index.js" --dir="dist/" --port=${port} --portStep=${portStep} --packageName="${packageName}"`,
|
85
|
-
test: {
|
86
|
-
// --success first - report the exit code of the test run (first command to finish), as serve is always terminated and has a non-0 exit code
|
87
|
-
default: 'concurrently "nps serve" "nps test.run" --kill-others --success first',
|
88
|
-
run: "cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js",
|
89
|
-
spec: "wdio run config/wdio.conf.js",
|
90
|
-
},
|
91
|
-
startWithScope: "nps scope.prepare scope.dev",
|
117
|
+
start: "nps prepare watch.devServer",
|
118
|
+
test: `node "${LIB}/test-runner/test-runner.js"`,
|
119
|
+
"test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
|
120
|
+
"test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
|
121
|
+
startWithScope: "nps scope.prepare scope.watchWithBundle",
|
92
122
|
scope: {
|
93
123
|
prepare: "nps scope.lint prepare scope.testPages",
|
94
124
|
lint: `node "${LIB}/scoping/lint-src.js"`,
|
95
125
|
testPages: {
|
96
126
|
default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
|
97
|
-
clean: "rimraf
|
98
|
-
copy: `node "${LIB}/copy-and-watch/index.js" --silent "
|
99
|
-
replace: `node "${LIB}/scoping/scope-test-pages.js"
|
127
|
+
clean: "rimraf test/pages/scoped",
|
128
|
+
copy: `node "${LIB}/copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
|
129
|
+
replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
|
100
130
|
},
|
101
|
-
|
102
|
-
watch: 'concurrently "nps watch.templates" "nps watch.
|
103
|
-
bundle:
|
104
|
-
}
|
131
|
+
watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
|
132
|
+
watch: 'concurrently "nps watch.templates" "nps watch.api" "nps watch.src" "nps watch.props" "nps watch.styles"',
|
133
|
+
bundle: `node ${LIB}/dev-server/dev-server.js ${viteConfig}`,
|
134
|
+
},
|
135
|
+
generateAPI: {
|
136
|
+
default: "nps generateAPI.prepare generateAPI.preprocess generateAPI.jsdoc generateAPI.cleanup generateAPI.prepareManifest",
|
137
|
+
prepare: `node "${LIB}/copy-and-watch/index.js" --silent "dist/**/*.js" jsdoc-dist/`,
|
138
|
+
prepareManifest: `node "${LIB}/generate-custom-elements-manifest/index.js" dist dist`,
|
139
|
+
preprocess: `node "${preprocessJSDocScript}" jsdoc-dist/ src`,
|
140
|
+
jsdoc: `jsdoc -c "${LIB}/jsdoc/configTypescript.json"`,
|
141
|
+
cleanup: "rimraf jsdoc-dist/"
|
142
|
+
},
|
105
143
|
};
|
106
144
|
|
107
145
|
return scripts;
|
@@ -6,16 +6,16 @@ const fs = require("fs");
|
|
6
6
|
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
7
7
|
|
8
8
|
module.exports = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
9
|
+
plugins: [
|
10
|
+
postcssImport(),
|
11
|
+
cssnano({
|
12
|
+
preset: [
|
13
|
+
'default', {
|
14
|
+
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
15
|
+
mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
|
16
|
+
},
|
17
|
+
]
|
18
|
+
}),
|
19
|
+
postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName }),
|
20
|
+
]
|
21
|
+
}
|
@@ -1,23 +1,26 @@
|
|
1
1
|
const postcssImport = require('postcss-import');
|
2
|
-
const combineSelectors = require('postcss-combine-duplicated-selectors');
|
2
|
+
const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
|
3
3
|
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
4
|
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
5
|
const cssnano = require('cssnano');
|
6
|
+
const fs = require("fs");
|
7
|
+
|
8
|
+
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
6
9
|
|
7
10
|
module.exports = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
plugins: [
|
12
|
+
postcssImport(),
|
13
|
+
combineSelectors({
|
14
|
+
removeDuplicatedProperties: true
|
15
|
+
}),
|
16
|
+
cssnano({
|
17
|
+
preset: [
|
18
|
+
'default', {
|
19
|
+
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
20
|
+
},
|
21
|
+
]
|
22
|
+
},),
|
23
|
+
postcssCSStoJSON({ toReplace: 'src', packageName }),
|
24
|
+
postcssCSStoESM({ toReplace: 'src', packageName }),
|
25
|
+
]
|
23
26
|
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// vite.config.js
|
2
|
+
const { defineConfig } = require('vite');
|
3
|
+
const virtualIndex = require("../lib/dev-server/virtual-index-html-plugin.js");
|
4
|
+
|
5
|
+
module.exports = defineConfig(async () => {
|
6
|
+
return {
|
7
|
+
build: {
|
8
|
+
emptyOutDir: false,
|
9
|
+
},
|
10
|
+
plugins: [await virtualIndex()],
|
11
|
+
}
|
12
|
+
});
|
@@ -50,14 +50,21 @@ exports.config = {
|
|
50
50
|
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
51
51
|
// grid with only 5 firefox instances available you can make sure that not more than
|
52
52
|
// 5 instances get started at a time.
|
53
|
-
maxInstances:
|
53
|
+
maxInstances: 5,
|
54
54
|
//
|
55
55
|
browserName: 'chrome',
|
56
56
|
'goog:chromeOptions': {
|
57
57
|
// to run chrome headless the following flags are required
|
58
58
|
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
59
|
-
args: [
|
60
|
-
|
59
|
+
args: [
|
60
|
+
'headless', // start in headless mode
|
61
|
+
'start-maximized', // maximize the window
|
62
|
+
'no-sandbox', // disable sandbox isolation
|
63
|
+
'disable-infobars', // disable the infos
|
64
|
+
'disable-gpu', // on windows disable gpu hw acceleration
|
65
|
+
'disable-extensions', // disable extensions
|
66
|
+
'disable-dev-shm-usage' // disable /dev/shm in CI
|
67
|
+
],
|
61
68
|
}
|
62
69
|
}],
|
63
70
|
//
|
@@ -82,7 +89,7 @@ exports.config = {
|
|
82
89
|
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
83
90
|
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
84
91
|
// gets prepended directly.
|
85
|
-
baseUrl:
|
92
|
+
baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
86
93
|
path: '',
|
87
94
|
//
|
88
95
|
// Default timeout for all waitFor* commands.
|
@@ -99,7 +106,14 @@ exports.config = {
|
|
99
106
|
// Services take over a specific job you don't want to take care of. They enhance
|
100
107
|
// your test setup with almost no effort. Unlike plugins, they don't add new
|
101
108
|
// commands. Instead, they hook themselves up into the test process.
|
102
|
-
services: ['chromedriver'
|
109
|
+
services: ['chromedriver', 'devtools',
|
110
|
+
['static-server', {
|
111
|
+
folders: [
|
112
|
+
{ mount: '/', path: './dist' },
|
113
|
+
],
|
114
|
+
port: '4567',
|
115
|
+
}],
|
116
|
+
],
|
103
117
|
// options
|
104
118
|
chromeDriverArgs: ['--port=9515'], // default
|
105
119
|
// Framework you want to run your specs with.
|
@@ -152,9 +166,9 @@ exports.config = {
|
|
152
166
|
* @param {Array.<Object>} capabilities list of capabilities details
|
153
167
|
* @param {Array.<String>} specs List of spec file paths that are to be run
|
154
168
|
*/
|
155
|
-
before: function (capabilities, specs) {
|
156
|
-
browser.addCommand("isFocusedDeep", function () {
|
157
|
-
return browser.
|
169
|
+
before: async function (capabilities, specs) {
|
170
|
+
await browser.addCommand("isFocusedDeep", async function () {
|
171
|
+
return browser.executeAsync(function (elem, done) {
|
158
172
|
let activeElement = document.activeElement;
|
159
173
|
|
160
174
|
while (activeElement.shadowRoot) {
|
@@ -164,51 +178,80 @@ exports.config = {
|
|
164
178
|
break;
|
165
179
|
}
|
166
180
|
}
|
167
|
-
|
181
|
+
done(elem === activeElement);
|
168
182
|
}, this);
|
169
183
|
}, true);
|
170
184
|
|
171
|
-
browser.addCommand("
|
172
|
-
return browser.
|
173
|
-
|
185
|
+
await browser.addCommand("isFocusedDeepElement", async function (element) {
|
186
|
+
return browser.executeAsync(function (elem, element, done) {
|
187
|
+
let activeElement = document.activeElement;
|
188
|
+
|
189
|
+
while (activeElement.shadowRoot) {
|
190
|
+
if (activeElement.shadowRoot.activeElement) {
|
191
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
192
|
+
} else {
|
193
|
+
break;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
done(element === activeElement);
|
197
|
+
}, this, element);
|
198
|
+
}, true);
|
199
|
+
|
200
|
+
await browser.addCommand("setProperty", async function(property, value) {
|
201
|
+
return browser.executeAsync((elem, property, value, done) => {
|
202
|
+
elem[property] = value;
|
203
|
+
done();
|
174
204
|
}, this, property, value);
|
175
205
|
}, true);
|
176
206
|
|
177
|
-
browser.addCommand("setAttribute", function(attribute, value) {
|
178
|
-
return browser.
|
179
|
-
|
207
|
+
await browser.addCommand("setAttribute", async function(attribute, value) {
|
208
|
+
return browser.executeAsync((elem, attribute, value, done) => {
|
209
|
+
elem.setAttribute(attribute, value);
|
210
|
+
done();
|
180
211
|
}, this, attribute, value);
|
181
212
|
}, true);
|
182
213
|
|
183
|
-
browser.addCommand("removeAttribute", function(attribute) {
|
184
|
-
return browser.
|
185
|
-
|
214
|
+
await browser.addCommand("removeAttribute", async function(attribute) {
|
215
|
+
return browser.executeAsync((elem, attribute, done) => {
|
216
|
+
elem.removeAttribute(attribute);
|
217
|
+
done();
|
186
218
|
}, this, attribute);
|
187
219
|
}, true);
|
188
220
|
|
189
|
-
browser.addCommand("hasClass", function(className) {
|
190
|
-
return browser.
|
191
|
-
|
221
|
+
await browser.addCommand("hasClass", async function(className) {
|
222
|
+
return browser.executeAsync((elem, className, done) => {
|
223
|
+
done(elem.classList.contains(className));
|
192
224
|
}, this, className);
|
193
225
|
}, true);
|
194
226
|
|
195
|
-
browser.addCommand("
|
196
|
-
return browser.
|
227
|
+
await browser.addCommand("hasAttribute", async function(attrName) {
|
228
|
+
return browser.executeAsync((elem, attrName, done) => {
|
229
|
+
done(elem.hasAttribute(attrName));
|
230
|
+
}, this, attrName);
|
231
|
+
}, true);
|
232
|
+
|
233
|
+
await browser.addCommand("getStaticAreaItemClassName", async function(selector) {
|
234
|
+
return browser.executeAsync(async (selector, done) => {
|
197
235
|
const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
|
198
|
-
|
236
|
+
done(staticAreaItem.host.classList[0]);
|
199
237
|
}, selector);
|
200
238
|
}, false);
|
239
|
+
|
240
|
+
await browser.addLocatorStrategy('activeElement', (selector) => {
|
241
|
+
return document.querySelector(selector).shadowRoot.activeElement;
|
242
|
+
});
|
201
243
|
},
|
202
244
|
/**
|
203
245
|
* Runs before a WebdriverIO command gets executed.
|
204
246
|
* @param {String} commandName hook command name
|
205
247
|
* @param {Array} args arguments that command would receive
|
206
248
|
*/
|
207
|
-
beforeCommand: function (commandName, args) {
|
249
|
+
beforeCommand: async function (commandName, args) {
|
208
250
|
const waitFor = [
|
209
251
|
"$",
|
210
252
|
"$$",
|
211
253
|
"getAttribute",
|
254
|
+
"hasAttribute", // custom
|
212
255
|
"getCSSProperty",
|
213
256
|
"getHTML",
|
214
257
|
"getProperty",
|
@@ -223,11 +266,12 @@ exports.config = {
|
|
223
266
|
"isExisting",
|
224
267
|
"isFocused",
|
225
268
|
"isFocusedDeep", // custom
|
269
|
+
"isFocusedDeepElement", // custom
|
226
270
|
"shadow$",
|
227
271
|
"shadow$$",
|
228
272
|
];
|
229
273
|
if (waitFor.includes(commandName)) {
|
230
|
-
browser.executeAsync(function (done) {
|
274
|
+
await browser.executeAsync(function (done) {
|
231
275
|
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
232
276
|
});
|
233
277
|
}
|
@@ -277,12 +321,13 @@ exports.config = {
|
|
277
321
|
* @param {Number} result 0 - command success, 1 - command error
|
278
322
|
* @param {Object} error error object if any
|
279
323
|
*/
|
280
|
-
afterCommand: function (commandName, args, result, error) {
|
324
|
+
afterCommand: async function (commandName, args, result, error) {
|
281
325
|
|
282
326
|
// url -> set configuration first
|
283
327
|
if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
|
284
|
-
browser.
|
328
|
+
await browser.executeAsync(function(done) {
|
285
329
|
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
330
|
+
done();
|
286
331
|
});
|
287
332
|
}
|
288
333
|
|
@@ -292,20 +337,31 @@ exports.config = {
|
|
292
337
|
"click",
|
293
338
|
"doubleClick",
|
294
339
|
"dragAndDrop",
|
295
|
-
"keys",
|
296
340
|
"pause",
|
297
341
|
"removeAttribute", // custom
|
342
|
+
"scrollIntoView",
|
298
343
|
"setAttribute", // custom
|
299
344
|
"setProperty", // custom
|
300
345
|
"setValue",
|
301
346
|
"setWindowSize",
|
302
347
|
"touchAction",
|
303
|
-
"url"
|
348
|
+
"url",
|
304
349
|
];
|
350
|
+
|
351
|
+
const waitForWithDelay = [
|
352
|
+
"keys",
|
353
|
+
];
|
354
|
+
|
305
355
|
if (waitFor.includes(commandName)) {
|
306
|
-
browser.executeAsync(function (done) {
|
356
|
+
await browser.executeAsync(function (done) {
|
307
357
|
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
308
358
|
});
|
359
|
+
} else if (waitForWithDelay.includes(commandName)) {
|
360
|
+
await browser.executeAsync(function (done) {
|
361
|
+
setTimeout(() => {
|
362
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
363
|
+
}, 10);
|
364
|
+
});
|
309
365
|
}
|
310
366
|
},
|
311
367
|
/**
|