@ui5/webcomponents-tools 1.24.0-rc.4 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +271 -0
- package/components-package/nps.js +4 -11
- package/components-package/wdio.js +404 -405
- package/icons-collection/nps.js +2 -2
- package/lib/create-new-component/index.js +4 -11
- package/lib/generate-json-imports/i18n.js +3 -35
- package/lib/generate-json-imports/themes.js +2 -29
- package/lib/i18n/defaults.js +1 -1
- package/package.json +2 -3
- package/components-package/wdio.sync.js +0 -368
- package/lib/create-new-component/jsFileContentTemplate.js +0 -73
- package/lib/generate-custom-elements-manifest/index.js +0 -271
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/configTypescript.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2468
- package/lib/jsdoc/preprocess.js +0 -146
- package/lib/jsdoc/template/publish.js +0 -4120
package/icons-collection/nps.js
CHANGED
@@ -41,8 +41,8 @@ const copyIconAssetsCommand = (options) => {
|
|
41
41
|
const getScripts = (options) => {
|
42
42
|
const createJSImportsCmd = createIconImportsCommand(options);
|
43
43
|
const copyAssetsCmd = copyIconAssetsCommand(options);
|
44
|
-
const tsCommand = options.
|
45
|
-
const tsCrossEnv = options.
|
44
|
+
const tsCommand = !options.legacy ? "tsc --build" : "";
|
45
|
+
const tsCrossEnv = !options.legacy ? "cross-env UI5_TS=true" : "";
|
46
46
|
|
47
47
|
const scripts = {
|
48
48
|
clean: "rimraf dist && rimraf src/generated",
|
@@ -58,21 +58,15 @@ const getLibraryName = packageName => {
|
|
58
58
|
return packageName.substr("webcomponents-".length);
|
59
59
|
};
|
60
60
|
|
61
|
-
const generateFiles = (componentName, tagName, library, packageName
|
61
|
+
const generateFiles = (componentName, tagName, library, packageName) => {
|
62
62
|
componentName = capitalizeFirstLetter(componentName);
|
63
63
|
const filePaths = {
|
64
|
-
"main":
|
65
|
-
? `./src/${componentName}.ts`
|
66
|
-
: `./src/${componentName}.js`,
|
64
|
+
"main": `./src/${componentName}.ts`,
|
67
65
|
"css": `./src/themes/${componentName}.css`,
|
68
66
|
"template": `./src/${componentName}.hbs`,
|
69
67
|
};
|
70
68
|
|
71
|
-
|
72
|
-
? tsFileContentTemplate(componentName, tagName, library, packageName)
|
73
|
-
: jsFileContentTemplate(componentName, tagName, library, packageName);
|
74
|
-
|
75
|
-
fs.writeFileSync(filePaths.main, FileContentTemplate, { flag: "wx+" });
|
69
|
+
fs.writeFileSync(filePaths.main, tsFileContentTemplate(componentName, tagName, library, packageName), { flag: "wx+" });
|
76
70
|
fs.writeFileSync(filePaths.css, "", { flag: "wx+" });
|
77
71
|
fs.writeFileSync(filePaths.template, "<div>Hello World</div>", { flag: "wx+" });
|
78
72
|
|
@@ -112,10 +106,9 @@ const createWebComponent = async () => {
|
|
112
106
|
}
|
113
107
|
}
|
114
108
|
|
115
|
-
const isTypeScript = fs.existsSync(path.join(process.cwd(), "tsconfig.json"));
|
116
109
|
const tagName = hyphaneteComponentName(componentName);
|
117
110
|
|
118
|
-
generateFiles(componentName, tagName, library, packageName
|
111
|
+
generateFiles(componentName, tagName, library, packageName);
|
119
112
|
};
|
120
113
|
|
121
114
|
createWebComponent();
|
@@ -9,7 +9,6 @@ const generate = async () => {
|
|
9
9
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
10
10
|
|
11
11
|
const inputFolder = path.normalize(process.argv[2]);
|
12
|
-
const outputFile = path.normalize(`${process.argv[3]}/i18n-static.${ext}`);
|
13
12
|
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
|
14
13
|
|
15
14
|
// All languages present in the file system
|
@@ -19,46 +18,16 @@ const generate = async () => {
|
|
19
18
|
return matches ? matches[1] : undefined;
|
20
19
|
}).filter(key => !!key);
|
21
20
|
|
22
|
-
let
|
21
|
+
let contentDynamic;
|
23
22
|
|
24
23
|
// No i18n - just import dependencies, if any
|
25
24
|
if (languages.length === 0) {
|
26
|
-
contentStatic = "";
|
27
25
|
contentDynamic = "";
|
28
26
|
// There is i18n - generate the full file
|
29
27
|
} else {
|
30
28
|
// Keys for the array
|
31
|
-
const languagesKeysString = languages.map(key => `"${key}": _${key},`).join("\n\t");
|
32
29
|
const languagesKeysStringArray = languages.map(key => `"${key}",`).join("\n\t");
|
33
30
|
|
34
|
-
// Actual imports for json assets
|
35
|
-
const assetsImportsString = languages.map(key => `import _${key} from "../assets/i18n/messagebundle_${key}.json";`).join("\n");
|
36
|
-
|
37
|
-
// static imports
|
38
|
-
contentStatic = `// @ts-nocheck
|
39
|
-
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
40
|
-
|
41
|
-
${assetsImportsString}
|
42
|
-
|
43
|
-
const bundleMap = {
|
44
|
-
${languagesKeysString}
|
45
|
-
};
|
46
|
-
|
47
|
-
const fetchMessageBundle = async (localeId) => {
|
48
|
-
if (typeof bundleMap[localeId] === "object") {
|
49
|
-
// inlined from build
|
50
|
-
throw new Error("[i18n] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs")
|
51
|
-
}
|
52
|
-
return (await fetch(bundleMap[localeId])).json()
|
53
|
-
}
|
54
|
-
|
55
|
-
const localeIds = [${languagesKeysStringArray}];
|
56
|
-
|
57
|
-
localeIds.forEach(localeId => {
|
58
|
-
registerI18nLoader("${packageName}", localeId, fetchMessageBundle);
|
59
|
-
});
|
60
|
-
`;
|
61
|
-
|
62
31
|
// Actual imports for json assets
|
63
32
|
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
64
33
|
|
@@ -76,7 +45,7 @@ import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registrie
|
|
76
45
|
const importAndCheck = async (localeId) => {
|
77
46
|
const data = await importMessageBundle(localeId);
|
78
47
|
if (typeof data === "string" && data.endsWith(".json")) {
|
79
|
-
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build
|
48
|
+
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
80
49
|
}
|
81
50
|
return data;
|
82
51
|
}
|
@@ -91,9 +60,8 @@ import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registrie
|
|
91
60
|
|
92
61
|
}
|
93
62
|
|
94
|
-
await fs.mkdir(path.dirname(
|
63
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
95
64
|
return Promise.all([
|
96
|
-
fs.writeFile(outputFile, contentStatic),
|
97
65
|
fs.writeFile(outputFileDynamic, contentDynamic),
|
98
66
|
]);
|
99
67
|
}
|
@@ -7,7 +7,6 @@ const ext = isTypeScript ? 'ts' : 'js';
|
|
7
7
|
|
8
8
|
const generate = async () => {
|
9
9
|
const inputFolder = path.normalize(process.argv[2]);
|
10
|
-
const outputFile = path.normalize(`${process.argv[3]}/Themes-static.${ext}`);
|
11
10
|
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
|
12
11
|
|
13
12
|
// All supported optional themes
|
@@ -22,34 +21,9 @@ const generate = async () => {
|
|
22
21
|
|
23
22
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
24
23
|
|
25
|
-
const importLines = themesOnFileSystem.map(theme => `import ${theme} from "../assets/themes/${theme}/parameters-bundle.css.json";`).join("\n");
|
26
|
-
const themeUrlsByName = "{\n" + themesOnFileSystem.join(",\n") + "\n}";
|
27
24
|
const availableThemesArray = `[${themesOnFileSystem.map(theme => `"${theme}"`).join(", ")}]`;
|
28
25
|
const dynamicImportLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json")).default;`).join("\n");
|
29
26
|
|
30
|
-
|
31
|
-
// static imports file content
|
32
|
-
const contentStatic = `// @ts-nocheck
|
33
|
-
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
34
|
-
|
35
|
-
${importLines}
|
36
|
-
|
37
|
-
const themeUrlsByName = ${themeUrlsByName};
|
38
|
-
const isInlined = obj => typeof (obj) === "object";
|
39
|
-
|
40
|
-
const loadThemeProperties = async (themeName) => {
|
41
|
-
if (typeof themeUrlsByName[themeName] === "object") {
|
42
|
-
// inlined from build
|
43
|
-
throw new Error("[themes] Inlined JSON not supported with static imports of assets. Use dynamic imports of assets or configure JSON imports as URLs");
|
44
|
-
}
|
45
|
-
return (await fetch(themeUrlsByName[themeName])).json();
|
46
|
-
};
|
47
|
-
|
48
|
-
${availableThemesArray}
|
49
|
-
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadThemeProperties));
|
50
|
-
`;
|
51
|
-
|
52
|
-
|
53
27
|
// dynamic imports file content
|
54
28
|
const contentDynamic = `// @ts-nocheck
|
55
29
|
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
@@ -64,7 +38,7 @@ ${dynamicImportLines}
|
|
64
38
|
const loadAndCheck = async (themeName) => {
|
65
39
|
const data = await loadThemeProperties(themeName);
|
66
40
|
if (typeof data === "string" && data.endsWith(".json")) {
|
67
|
-
throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build
|
41
|
+
throw new Error(\`[themes] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
68
42
|
}
|
69
43
|
return data;
|
70
44
|
};
|
@@ -73,9 +47,8 @@ ${availableThemesArray}
|
|
73
47
|
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadAndCheck));
|
74
48
|
`;
|
75
49
|
|
76
|
-
await fs.mkdir(path.dirname(
|
50
|
+
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
77
51
|
return Promise.all([
|
78
|
-
fs.writeFile(outputFile, contentStatic),
|
79
52
|
fs.writeFile(outputFileDynamic, contentDynamic)
|
80
53
|
]);
|
81
54
|
};
|
package/lib/i18n/defaults.js
CHANGED
@@ -31,7 +31,7 @@ const generate = async () => {
|
|
31
31
|
// (2) as the messagebundle.properties file is always written in English,
|
32
32
|
// it makes sense to consider the messagebundle.properties content only when the default language is "en".
|
33
33
|
if (defaultLanguage === "en") {
|
34
|
-
defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
|
34
|
+
defaultLanguageProperties = Object.assign({}, defaultLanguageProperties, properties);
|
35
35
|
}
|
36
36
|
|
37
37
|
/*
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-rc.0",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -52,7 +52,6 @@
|
|
52
52
|
"globby": "^13.1.1",
|
53
53
|
"handlebars": "^4.7.7",
|
54
54
|
"is-port-reachable": "^3.1.0",
|
55
|
-
"jsdoc": "^3.6.6",
|
56
55
|
"json-beautify": "^1.1.1",
|
57
56
|
"mkdirp": "^1.0.4",
|
58
57
|
"nps": "^5.10.0",
|
@@ -81,5 +80,5 @@
|
|
81
80
|
"esbuild": "^0.19.9",
|
82
81
|
"yargs": "^17.5.1"
|
83
82
|
},
|
84
|
-
"gitHead": "
|
83
|
+
"gitHead": "f07f56dbe228e7d6d5acedeac5284b131acf551a"
|
85
84
|
}
|
@@ -1,368 +0,0 @@
|
|
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: undefined, // 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'],
|
111
|
-
// options
|
112
|
-
chromeDriverArgs: ['--port=9515'], // default
|
113
|
-
// Framework you want to run your specs with.
|
114
|
-
// The following are supported: Mocha, Jasmine, and Cucumber
|
115
|
-
// see also: https://webdriver.io/docs/frameworks.html
|
116
|
-
//
|
117
|
-
// Make sure you have the wdio adapter package for the specific framework installed
|
118
|
-
// before running any tests.
|
119
|
-
framework: 'mocha',
|
120
|
-
//
|
121
|
-
// Test reporter for stdout.
|
122
|
-
// The only one supported by default is 'dot'
|
123
|
-
// see also: https://webdriver.io/docs/dot-reporter.html
|
124
|
-
reporters: ['dot', 'spec'],
|
125
|
-
|
126
|
-
//
|
127
|
-
// Options to be passed to Mocha.
|
128
|
-
// See the full list at http://mochajs.org/
|
129
|
-
mochaOpts: {
|
130
|
-
ui: 'bdd',
|
131
|
-
timeout: 60000
|
132
|
-
},
|
133
|
-
//
|
134
|
-
// =====
|
135
|
-
// Hooks
|
136
|
-
// =====
|
137
|
-
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
138
|
-
// it and to build services around it. You can either apply a single function or an array of
|
139
|
-
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
140
|
-
// resolved to continue.
|
141
|
-
/**
|
142
|
-
* Gets executed once before all workers get launched.
|
143
|
-
* @param {Object} config wdio configuration object
|
144
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
145
|
-
*/
|
146
|
-
// onPrepare: function (config, capabilities) {
|
147
|
-
// },
|
148
|
-
/**
|
149
|
-
* Gets executed just before initialising the webdriver session and test framework. It allows you
|
150
|
-
* to manipulate configurations depending on the capability or spec.
|
151
|
-
* @param {Object} config wdio configuration object
|
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
|
-
// beforeSession: function (config, capabilities, specs) {
|
156
|
-
// },
|
157
|
-
/**
|
158
|
-
* Gets executed before test execution begins. At this point you can access to all global
|
159
|
-
* variables like `browser`. It is the perfect place to define custom commands.
|
160
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
161
|
-
* @param {Array.<String>} specs List of spec file paths that are to be run
|
162
|
-
*/
|
163
|
-
before: function (capabilities, specs) {
|
164
|
-
browser.addCommand("isFocusedDeep", function () {
|
165
|
-
return browser.execute(function (elem) {
|
166
|
-
let activeElement = document.activeElement;
|
167
|
-
|
168
|
-
while (activeElement.shadowRoot) {
|
169
|
-
if (activeElement.shadowRoot.activeElement) {
|
170
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
171
|
-
} else {
|
172
|
-
break;
|
173
|
-
}
|
174
|
-
}
|
175
|
-
return elem === activeElement;
|
176
|
-
}, this);
|
177
|
-
}, true);
|
178
|
-
|
179
|
-
browser.addCommand("isFocusedDeepElement", function (element) {
|
180
|
-
return browser.execute(function (elem, element, done) {
|
181
|
-
let activeElement = document.activeElement;
|
182
|
-
|
183
|
-
while (activeElement.shadowRoot) {
|
184
|
-
if (activeElement.shadowRoot.activeElement) {
|
185
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
186
|
-
} else {
|
187
|
-
break;
|
188
|
-
}
|
189
|
-
}
|
190
|
-
done(element === activeElement);
|
191
|
-
}, this, element);
|
192
|
-
}, true);
|
193
|
-
|
194
|
-
browser.addCommand("setProperty", function(property, value) {
|
195
|
-
return browser.execute((elem, property, value) => {
|
196
|
-
return elem[property] = value;
|
197
|
-
}, this, property, value);
|
198
|
-
}, true);
|
199
|
-
|
200
|
-
browser.addCommand("setAttribute", function(attribute, value) {
|
201
|
-
return browser.execute((elem, attribute, value) => {
|
202
|
-
return elem.setAttribute(attribute, value);
|
203
|
-
}, this, attribute, value);
|
204
|
-
}, true);
|
205
|
-
|
206
|
-
browser.addCommand("removeAttribute", function(attribute) {
|
207
|
-
return browser.execute((elem, attribute) => {
|
208
|
-
return elem.removeAttribute(attribute);
|
209
|
-
}, this, attribute);
|
210
|
-
}, true);
|
211
|
-
|
212
|
-
browser.addCommand("hasClass", function(className) {
|
213
|
-
return browser.execute((elem, className) => {
|
214
|
-
return elem.classList.contains(className);
|
215
|
-
}, this, className);
|
216
|
-
}, true);
|
217
|
-
|
218
|
-
browser.addCommand("getStaticAreaItemClassName", function(selector) {
|
219
|
-
return browser.execute(async (selector) => {
|
220
|
-
const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
|
221
|
-
return staticAreaItem.host.classList[0];
|
222
|
-
}, selector);
|
223
|
-
}, false);
|
224
|
-
},
|
225
|
-
/**
|
226
|
-
* Runs before a WebdriverIO command gets executed.
|
227
|
-
* @param {String} commandName hook command name
|
228
|
-
* @param {Array} args arguments that command would receive
|
229
|
-
*/
|
230
|
-
beforeCommand: function (commandName, args) {
|
231
|
-
const waitFor = [
|
232
|
-
"$",
|
233
|
-
"$$",
|
234
|
-
"getAttribute",
|
235
|
-
"getCSSProperty",
|
236
|
-
"getHTML",
|
237
|
-
"getProperty",
|
238
|
-
"getSize",
|
239
|
-
"getStaticAreaItemClassName", // custom
|
240
|
-
"getText",
|
241
|
-
"getValue",
|
242
|
-
"hasClass", // custom
|
243
|
-
"isDisplayed",
|
244
|
-
"isDisplayedInViewport",
|
245
|
-
"isEnabled",
|
246
|
-
"isExisting",
|
247
|
-
"isFocused",
|
248
|
-
"isFocusedDeep", // custom
|
249
|
-
"isFocusedDeepElement", // custom
|
250
|
-
"shadow$",
|
251
|
-
"shadow$$",
|
252
|
-
];
|
253
|
-
if (waitFor.includes(commandName)) {
|
254
|
-
browser.executeAsync(function (done) {
|
255
|
-
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
256
|
-
});
|
257
|
-
}
|
258
|
-
},
|
259
|
-
|
260
|
-
/**
|
261
|
-
* Hook that gets executed before the suite starts
|
262
|
-
* @param {Object} suite suite details
|
263
|
-
*/
|
264
|
-
// beforeSuite: function (suite) {
|
265
|
-
// },
|
266
|
-
/**
|
267
|
-
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
268
|
-
* @param {Object} test test details
|
269
|
-
*/
|
270
|
-
// beforeTest: function (test) {
|
271
|
-
// },
|
272
|
-
/**
|
273
|
-
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
|
274
|
-
* beforeEach in Mocha)
|
275
|
-
*/
|
276
|
-
// beforeHook: function () {
|
277
|
-
// },
|
278
|
-
/**
|
279
|
-
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
|
280
|
-
* afterEach in Mocha)
|
281
|
-
*/
|
282
|
-
// afterHook: function () {
|
283
|
-
// },
|
284
|
-
/**
|
285
|
-
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
286
|
-
* @param {Object} test test details
|
287
|
-
*/
|
288
|
-
// afterTest: function (test) {
|
289
|
-
// },
|
290
|
-
/**
|
291
|
-
* Hook that gets executed after the suite has ended
|
292
|
-
* @param {Object} suite suite details
|
293
|
-
*/
|
294
|
-
// afterSuite: function (suite) {
|
295
|
-
// },
|
296
|
-
|
297
|
-
/**
|
298
|
-
* Runs after a WebdriverIO command gets executed
|
299
|
-
* @param {String} commandName hook command name
|
300
|
-
* @param {Array} args arguments that command would receive
|
301
|
-
* @param {Number} result 0 - command success, 1 - command error
|
302
|
-
* @param {Object} error error object if any
|
303
|
-
*/
|
304
|
-
afterCommand: function (commandName, args, result, error) {
|
305
|
-
|
306
|
-
// url -> set configuration first
|
307
|
-
if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
|
308
|
-
browser.execute(function() {
|
309
|
-
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
310
|
-
});
|
311
|
-
}
|
312
|
-
|
313
|
-
const waitFor = [
|
314
|
-
"addValue",
|
315
|
-
"clearValue",
|
316
|
-
"click",
|
317
|
-
"doubleClick",
|
318
|
-
"dragAndDrop",
|
319
|
-
"keys",
|
320
|
-
"pause",
|
321
|
-
"removeAttribute", // custom
|
322
|
-
"setAttribute", // custom
|
323
|
-
"setProperty", // custom
|
324
|
-
"setValue",
|
325
|
-
"setWindowSize",
|
326
|
-
"touchAction",
|
327
|
-
"url"
|
328
|
-
];
|
329
|
-
if (waitFor.includes(commandName)) {
|
330
|
-
browser.executeAsync(function (done) {
|
331
|
-
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
332
|
-
});
|
333
|
-
}
|
334
|
-
},
|
335
|
-
/**
|
336
|
-
* Gets executed after all tests are done. You still have access to all global variables from
|
337
|
-
* the test.
|
338
|
-
* @param {Number} result 0 - test pass, 1 - test fail
|
339
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
340
|
-
* @param {Array.<String>} specs List of spec file paths that ran
|
341
|
-
*/
|
342
|
-
// after: function (result, capabilities, specs) {
|
343
|
-
// },
|
344
|
-
/**
|
345
|
-
* Gets executed right after terminating the webdriver session.
|
346
|
-
* @param {Object} config wdio configuration object
|
347
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
348
|
-
* @param {Array.<String>} specs List of spec file paths that ran
|
349
|
-
*/
|
350
|
-
// afterSession: function (config, capabilities, specs) {
|
351
|
-
// },
|
352
|
-
/**
|
353
|
-
* Gets executed after all workers got shut down and the process is about to exit.
|
354
|
-
* @param {Object} exitCode 0 - success, 1 - fail
|
355
|
-
* @param {Object} config wdio configuration object
|
356
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
357
|
-
* @param {<Object>} results object containing test results
|
358
|
-
*/
|
359
|
-
// onComplete: function(exitCode, config, capabilities, results) {
|
360
|
-
// },
|
361
|
-
/**
|
362
|
-
* Gets executed when a refresh happens.
|
363
|
-
* @param {String} oldSessionId session ID of the old session
|
364
|
-
* @param {String} newSessionId session ID of the new session
|
365
|
-
*/
|
366
|
-
//onReload: function(oldSessionId, newSessionId) {
|
367
|
-
//}
|
368
|
-
}
|
@@ -1,73 +0,0 @@
|
|
1
|
-
const jsFileContentTemplate = (componentName, tagName, library, packageName) => {
|
2
|
-
return `import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
3
|
-
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
|
4
|
-
import ${componentName}Template from "./generated/templates/${componentName}Template.lit.js";
|
5
|
-
|
6
|
-
// Styles
|
7
|
-
import ${componentName}Css from "./generated/themes/${componentName}.css.js";
|
8
|
-
|
9
|
-
/**
|
10
|
-
* @public
|
11
|
-
*/
|
12
|
-
const metadata = {
|
13
|
-
tag: "${tagName}",
|
14
|
-
properties: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
|
15
|
-
//
|
16
|
-
},
|
17
|
-
slots: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
|
18
|
-
//
|
19
|
-
},
|
20
|
-
events: /** @lends sap.ui.webc.${library}.${componentName}.prototype */ {
|
21
|
-
//
|
22
|
-
},
|
23
|
-
};
|
24
|
-
|
25
|
-
/**
|
26
|
-
* @class
|
27
|
-
*
|
28
|
-
* <h3 class="comment-api-title">Overview</h3>
|
29
|
-
*
|
30
|
-
*
|
31
|
-
* <h3>Usage</h3>
|
32
|
-
*
|
33
|
-
* For the <code>${tagName}</code>
|
34
|
-
* <h3>ES6 Module Import</h3>
|
35
|
-
*
|
36
|
-
* <code>import "${packageName}/dist/${componentName}.js";</code>
|
37
|
-
*
|
38
|
-
* @constructor
|
39
|
-
* @author SAP SE
|
40
|
-
* @alias sap.ui.webc.${library}.${componentName}
|
41
|
-
* @extends sap.ui.webc.base.UI5Element
|
42
|
-
* @tagname ${tagName}
|
43
|
-
* @public
|
44
|
-
*/
|
45
|
-
class ${componentName} extends UI5Element {
|
46
|
-
static get metadata() {
|
47
|
-
return metadata;
|
48
|
-
}
|
49
|
-
|
50
|
-
static get render() {
|
51
|
-
return litRender;
|
52
|
-
}
|
53
|
-
|
54
|
-
static get styles() {
|
55
|
-
return ${componentName}Css;
|
56
|
-
}
|
57
|
-
|
58
|
-
static get template() {
|
59
|
-
return ${componentName}Template;
|
60
|
-
}
|
61
|
-
|
62
|
-
static get dependencies() {
|
63
|
-
return [];
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
${componentName}.define();
|
68
|
-
|
69
|
-
export default ${componentName};
|
70
|
-
`;
|
71
|
-
};
|
72
|
-
|
73
|
-
module.exports = jsFileContentTemplate;
|