askui 0.12.2 → 0.13.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/README.md +13 -19
- package/bin/askui +1 -1
- package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +75 -0
- package/dist/cjs/core/model/test-case-dto/custom-element-json.js +2 -0
- package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +21 -0
- package/dist/cjs/core/model/test-case-dto/custom-element.js +54 -0
- package/dist/cjs/core/model/test-case-dto/index.d.ts +3 -0
- package/dist/cjs/core/model/test-case-dto/index.js +5 -0
- package/dist/cjs/core/model/test-case-dto/test-step.d.ts +6 -0
- package/dist/cjs/core/model/test-case-dto/test-step.js +2 -0
- package/dist/cjs/core/model/test-case-result-dto/index.d.ts +2 -0
- package/dist/cjs/core/model/test-case-result-dto/index.js +7 -0
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +9 -0
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +16 -0
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +4 -0
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +8 -0
- package/dist/cjs/core/reporting/default-reporter.d.ts +10 -0
- package/dist/cjs/core/reporting/default-reporter.js +12 -0
- package/dist/cjs/execution/annotation-level.d.ts +5 -0
- package/dist/cjs/execution/annotation-level.js +9 -0
- package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
- package/dist/cjs/execution/ui-control-client-error.js +6 -0
- package/dist/cjs/lib/index.d.ts +1 -0
- package/dist/cjs/lib/index.js +3 -1
- package/dist/cjs/lib/interactive_cli/add-script-package-json.d.ts +1 -0
- package/dist/cjs/lib/interactive_cli/add-script-package-json.js +38 -0
- package/dist/cjs/lib/interactive_cli/cli-options-interface.d.ts +8 -0
- package/dist/cjs/lib/interactive_cli/cli-options-interface.js +2 -0
- package/dist/cjs/lib/interactive_cli/cli.d.ts +2 -0
- package/dist/cjs/lib/interactive_cli/cli.js +115 -0
- package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +26 -0
- package/dist/cjs/lib/interactive_cli/create-example-project.js +293 -0
- package/dist/cjs/lib/interactive_cli/index.d.ts +1 -0
- package/dist/cjs/lib/interactive_cli/index.js +5 -0
- package/dist/cjs/lib/interactive_cli/replace-string-in-file.d.ts +1 -0
- package/dist/cjs/lib/interactive_cli/replace-string-in-file.js +31 -0
- package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +75 -0
- package/dist/esm/core/model/test-case-dto/custom-element-json.js +1 -0
- package/dist/esm/core/model/test-case-dto/custom-element.d.ts +21 -0
- package/dist/esm/core/model/test-case-dto/custom-element.js +50 -0
- package/dist/esm/core/model/test-case-dto/index.d.ts +3 -0
- package/dist/esm/core/model/test-case-dto/index.js +1 -0
- package/dist/esm/core/model/test-case-dto/test-step.d.ts +6 -0
- package/dist/esm/core/model/test-case-dto/test-step.js +1 -0
- package/dist/esm/core/model/test-case-result-dto/index.d.ts +2 -0
- package/dist/esm/core/model/test-case-result-dto/index.js +2 -0
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +9 -0
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +12 -0
- package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +4 -0
- package/dist/esm/core/model/test-case-result-dto/test-step-state.js +5 -0
- package/dist/esm/core/reporting/default-reporter.d.ts +10 -0
- package/dist/esm/core/reporting/default-reporter.js +9 -0
- package/dist/esm/execution/annotation-level.d.ts +5 -0
- package/dist/esm/execution/annotation-level.js +6 -0
- package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
- package/dist/esm/execution/ui-control-client-error.js +2 -0
- package/dist/esm/lib/index.d.ts +1 -0
- package/dist/esm/lib/index.js +1 -0
- package/dist/esm/lib/interactive_cli/add-script-package-json.d.ts +1 -0
- package/dist/esm/lib/interactive_cli/add-script-package-json.js +31 -0
- package/dist/esm/lib/interactive_cli/cli-options-interface.d.ts +8 -0
- package/dist/esm/lib/interactive_cli/cli-options-interface.js +1 -0
- package/dist/esm/lib/interactive_cli/cli.d.ts +2 -0
- package/dist/esm/lib/interactive_cli/cli.js +108 -0
- package/dist/esm/lib/interactive_cli/create-example-project.d.ts +26 -0
- package/dist/esm/lib/interactive_cli/create-example-project.js +286 -0
- package/dist/esm/lib/interactive_cli/index.d.ts +1 -0
- package/dist/esm/lib/interactive_cli/index.js +1 -0
- package/dist/esm/lib/interactive_cli/replace-string-in-file.d.ts +1 -0
- package/dist/esm/lib/interactive_cli/replace-string-in-file.js +24 -0
- package/dist/example_projects_templates/configs/jasmine.config.json +12 -0
- package/dist/example_projects_templates/configs/jest.config.ts +13 -0
- package/dist/example_projects_templates/configs/tsconfig.json +7 -0
- package/dist/example_projects_templates/templates/askui-helper-windows.nj +35 -0
- package/dist/example_projects_templates/templates/askui-helper.nj +49 -0
- package/dist/example_projects_templates/typescript/.eslintignore +1 -0
- package/dist/example_projects_templates/typescript/.eslintignore-template +1 -0
- package/dist/example_projects_templates/typescript/.eslintrc.json +20 -0
- package/dist/example_projects_templates/typescript/.eslintrc.json-template +20 -0
- package/dist/example_projects_templates/typescript/askui_example/helpers/askui-helper.ts +39 -0
- package/dist/example_projects_templates/typescript/askui_example/my-first-askui-test-suite.test.ts +21 -0
- package/dist/example_projects_templates/typescript/tsconfig.json +7 -0
- package/package.json +8 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CreateExampleProject = void 0;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const util_1 = require("util");
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
const listr_1 = __importDefault(require("listr"));
|
|
21
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
22
|
+
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
23
|
+
const path_2 = require("../../utils/path");
|
|
24
|
+
const add_script_package_json_1 = require("./add-script-package-json");
|
|
25
|
+
class CreateExampleProject {
|
|
26
|
+
constructor(cliOptions) {
|
|
27
|
+
this.cliOptions = cliOptions;
|
|
28
|
+
this.baseDirPath = process.cwd();
|
|
29
|
+
this.exampleFolderName = 'askui_example';
|
|
30
|
+
this.distexampleFolderPath = path_1.default.join(this.baseDirPath, this.exampleFolderName);
|
|
31
|
+
this.proxyDocUrl = 'https://docs.askui.com/docs/general/Troubleshooting/proxy';
|
|
32
|
+
this.remoteDeviceControllerUrl = 'https://docs.askui.com/docs/api/Remote-Device-Controller';
|
|
33
|
+
this.helperTemplateConfig = {};
|
|
34
|
+
}
|
|
35
|
+
copyTemplateProject() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const exampleProjectPath = path_1.default.join('example_projects_templates', 'typescript', this.exampleFolderName);
|
|
38
|
+
const runCommand = (0, util_1.promisify)(child_process_1.exec);
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
title: 'Detect Operating System',
|
|
42
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (process.platform === 'win32') {
|
|
44
|
+
this.cliOptions.operatingSystem = 'windows';
|
|
45
|
+
}
|
|
46
|
+
else if (process.platform === 'darwin') {
|
|
47
|
+
this.cliOptions.operatingSystem = 'macos';
|
|
48
|
+
}
|
|
49
|
+
else if (process.platform === 'linux'
|
|
50
|
+
|| process.platform === 'freebsd'
|
|
51
|
+
|| process.platform === 'openbsd') {
|
|
52
|
+
this.cliOptions.operatingSystem = 'linux';
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error(`The detected operating system is ${process.platform}. We only support 'windows', 'macos' and 'linux'`);
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: 'Copy project files',
|
|
61
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return fs_extra_1.default.copy(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), exampleProjectPath), this.distexampleFolderPath);
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: 'Install askui dependency',
|
|
67
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm i -D askui '); }),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
copyTestFrameworkConfig() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const frameworkConfigs = {
|
|
75
|
+
jest: 'jest.config.ts',
|
|
76
|
+
jasmine: 'jasmine.config.json',
|
|
77
|
+
};
|
|
78
|
+
const configFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'configs', frameworkConfigs[this.cliOptions.testFramework]);
|
|
79
|
+
yield fs_extra_1.default.copyFile(configFilePath, path_1.default.join(this.distexampleFolderPath, frameworkConfigs[this.cliOptions.testFramework]));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
addTestFrameWorkTimeout() {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const frameworkTimeoutstring = {
|
|
85
|
+
jest: 'jest.setTimeout(60 * 1000 * 60);',
|
|
86
|
+
jasmine: 'jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000 * 60;',
|
|
87
|
+
};
|
|
88
|
+
this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring[this.cliOptions.testFramework];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
addReporterConfig() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (this.cliOptions.testFramework === 'jest') {
|
|
94
|
+
this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
|
|
95
|
+
this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
|
|
96
|
+
this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
|
|
97
|
+
await AskUIAllureStepReporter.attachVideo(video);`;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
addAskuiRunCommand() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const frameworkExecutionCommand = {
|
|
104
|
+
jest: `jest --config ./${this.exampleFolderName}/jest.config.ts --runInBand`,
|
|
105
|
+
jasmine: `jasmine --config=${this.exampleFolderName}/jasmine.config.json`,
|
|
106
|
+
};
|
|
107
|
+
yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand[this.cliOptions.testFramework]);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
addESLintRunCommand() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
createAskUIHelperFromTemplate() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return [{
|
|
118
|
+
title: 'Write askui config',
|
|
119
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return new listr_1.default([
|
|
121
|
+
{
|
|
122
|
+
title: 'Create askui-helper.ts ',
|
|
123
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const askuiHelperTemplateFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'templates');
|
|
125
|
+
let templateFileName = 'askui-helper.nj';
|
|
126
|
+
if (this.cliOptions.operatingSystem === 'windows') {
|
|
127
|
+
templateFileName = 'askui-helper-windows.nj';
|
|
128
|
+
}
|
|
129
|
+
nunjucks_1.default.configure(askuiHelperTemplateFilePath, { autoescape: false });
|
|
130
|
+
const result = nunjucks_1.default.render(templateFileName, this.helperTemplateConfig);
|
|
131
|
+
const filePath = path_1.default.join(this.distexampleFolderPath, 'helpers', 'askui-helper.ts');
|
|
132
|
+
yield fs_extra_1.default.mkdir(path_1.default.join(this.distexampleFolderPath, 'helpers'));
|
|
133
|
+
yield fs_extra_1.default.writeFile(filePath, result, 'utf8');
|
|
134
|
+
}),
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
}),
|
|
138
|
+
}];
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
setupTestFrameWork() {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
return [{
|
|
144
|
+
title: 'Setup Test framework',
|
|
145
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
return new listr_1.default([
|
|
147
|
+
{
|
|
148
|
+
title: `Install ${this.cliOptions.testFramework}`,
|
|
149
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.installTestFrameworkPackages(); }),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
title: 'Copy config file',
|
|
153
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.copyTestFrameworkConfig(); }),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
title: 'Add timeout',
|
|
157
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.addTestFrameWorkTimeout(); }),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
title: 'Add reporter (only Jest)',
|
|
161
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.addReporterConfig(); }),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
title: 'Add askui run command',
|
|
165
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.addAskuiRunCommand(); }),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
title: 'Add eslint run command',
|
|
169
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return this.addESLintRunCommand(); }),
|
|
170
|
+
},
|
|
171
|
+
]);
|
|
172
|
+
}),
|
|
173
|
+
}];
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
installTestFrameworkPackages() {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const runCommand = (0, util_1.promisify)(child_process_1.exec);
|
|
179
|
+
const frameworkDepencies = {
|
|
180
|
+
jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
|
|
181
|
+
jasmine: 'npm i -D @askui/askui-reporters typescript ts-node @types/jasmine jasmine @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
|
|
182
|
+
};
|
|
183
|
+
yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
addUserCredentails() {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
return [{
|
|
189
|
+
title: 'Add user credentails',
|
|
190
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
return new listr_1.default([
|
|
192
|
+
{
|
|
193
|
+
title: 'Add workspace id ',
|
|
194
|
+
task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['workspace_id'] = this.cliOptions.workspaceId; }),
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
title: 'Add access token',
|
|
198
|
+
task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['access_token'] = this.cliOptions.accessToken; }),
|
|
199
|
+
},
|
|
200
|
+
]);
|
|
201
|
+
}),
|
|
202
|
+
}];
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
copyESLintConfigFiles() {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
const esLintRcFilePath = path_1.default.join('example_projects_templates', 'typescript', '.eslintrc.json-template');
|
|
208
|
+
const esLintIgnoreFilePath = path_1.default.join('example_projects_templates', 'typescript', '.eslintignore-template');
|
|
209
|
+
return [{
|
|
210
|
+
title: 'Copy ESLint config files',
|
|
211
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
return new listr_1.default([
|
|
213
|
+
{
|
|
214
|
+
title: 'Add eslintrc.json',
|
|
215
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), esLintRcFilePath), path_1.default.join(this.baseDirPath, '.eslintrc.json'));
|
|
217
|
+
}),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
title: 'Add .eslintignore',
|
|
221
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), esLintIgnoreFilePath), path_1.default.join(this.baseDirPath, '.eslintignore'));
|
|
223
|
+
}),
|
|
224
|
+
},
|
|
225
|
+
]);
|
|
226
|
+
}),
|
|
227
|
+
}];
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
copyTsConfigFile() {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
const tsConfigFilePath = path_1.default.join('example_projects_templates', 'typescript', 'tsconfig.json');
|
|
233
|
+
return [{
|
|
234
|
+
title: 'Copy ts config file',
|
|
235
|
+
enabled: () => this.cliOptions.typescriptConfig,
|
|
236
|
+
task: () => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), tsConfigFilePath), path_1.default.join(this.baseDirPath, 'tsconfig.json'));
|
|
238
|
+
}),
|
|
239
|
+
}];
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
installProxy() {
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
const runCommand = (0, util_1.promisify)(child_process_1.exec);
|
|
245
|
+
return [{
|
|
246
|
+
title: 'Install Proxy',
|
|
247
|
+
enabled: () => this.cliOptions.usingProxy,
|
|
248
|
+
task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm install --save-dev hpagent '); }),
|
|
249
|
+
}];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
normalizeCliOptions() {
|
|
253
|
+
let useProxy = this.cliOptions.usingProxy;
|
|
254
|
+
if (typeof useProxy !== 'boolean') {
|
|
255
|
+
useProxy = (useProxy === 'true');
|
|
256
|
+
}
|
|
257
|
+
this.cliOptions.usingProxy = useProxy;
|
|
258
|
+
let { typescriptConfig } = this.cliOptions;
|
|
259
|
+
if (typeof typescriptConfig !== 'boolean') {
|
|
260
|
+
typescriptConfig = (typescriptConfig === 'true');
|
|
261
|
+
}
|
|
262
|
+
this.cliOptions.typescriptConfig = typescriptConfig;
|
|
263
|
+
}
|
|
264
|
+
createExampleProject() {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
const tasks = new listr_1.default();
|
|
267
|
+
this.normalizeCliOptions();
|
|
268
|
+
tasks.add([
|
|
269
|
+
...yield this.copyTemplateProject(),
|
|
270
|
+
...yield this.setupTestFrameWork(),
|
|
271
|
+
...yield this.copyESLintConfigFiles(),
|
|
272
|
+
...yield this.copyTsConfigFile(),
|
|
273
|
+
...yield this.addUserCredentails(),
|
|
274
|
+
...yield this.createAskUIHelperFromTemplate(),
|
|
275
|
+
...yield this.installProxy(),
|
|
276
|
+
]);
|
|
277
|
+
yield tasks.run();
|
|
278
|
+
/* eslint-disable no-console */
|
|
279
|
+
if (this.cliOptions.usingProxy) {
|
|
280
|
+
console.log(chalk_1.default.redBright('Since you are using a Proxy. Please don\'t forget to configure it!'));
|
|
281
|
+
console.log(chalk_1.default.gray(`You can find more information under ${this.proxyDocUrl}`));
|
|
282
|
+
}
|
|
283
|
+
console.log(chalk_1.default.greenBright('\nCongratulations!'));
|
|
284
|
+
console.log(`askui example was created under ${chalk_1.default.gray(this.distexampleFolderPath)}`);
|
|
285
|
+
if (this.cliOptions.operatingSystem === 'windows') {
|
|
286
|
+
console.log(chalk_1.default.redBright(`\nPlease install and start the Remote Device Controller: ${this.remoteDeviceControllerUrl}\n`));
|
|
287
|
+
}
|
|
288
|
+
console.log(`You can start your automation with this command ${chalk_1.default.green('npm run askui')}`);
|
|
289
|
+
/* eslint-enable no-console */
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.CreateExampleProject = CreateExampleProject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { init } from './cli';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceStringInFile(filePath: string, replace: string, replacement: string): Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.replaceStringInFile = void 0;
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const logger_1 = require("../logger");
|
|
18
|
+
function replaceStringInFile(filePath, replace, replacement) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const data = yield fs_extra_1.default.readFile(filePath, 'utf8');
|
|
22
|
+
const result = data.replace(replace, replacement);
|
|
23
|
+
yield fs_extra_1.default.writeFile(filePath, result, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
logger_1.logger.error(`Could not replace '${replace}' with '${replacement}' in file '${filePath}'`);
|
|
27
|
+
logger_1.logger.error(error.message);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.replaceStringInFile = replaceStringInFile;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines a 'custom element'. This is a UI element which is defined by
|
|
3
|
+
* providing an image and other parameters such as degree of rotation.
|
|
4
|
+
* It allows filtering for a UI element that is not recognized
|
|
5
|
+
* by our machine learning models by default.
|
|
6
|
+
* It can also be used for pixel assertions of elements using classical
|
|
7
|
+
* [template matching](https://en.wikipedia.org/wiki/Template_matching).
|
|
8
|
+
*
|
|
9
|
+
* **Important:** The `CustomElementJson` needs to capture as accurately as possible
|
|
10
|
+
* what the custom element looks like during test execution as otherwise
|
|
11
|
+
* our machine learning models cannot find it, even with the additional data
|
|
12
|
+
* provided. This is especially true for the resolution used while cropping
|
|
13
|
+
* the `CustomElementJson.customImage` which should match the resolution during
|
|
14
|
+
* test execution.
|
|
15
|
+
*
|
|
16
|
+
* Rotated custom elements can be filtered for using
|
|
17
|
+
* `CustomElementJson.rotationDegreePerStep`.
|
|
18
|
+
*/
|
|
19
|
+
export interface CustomElementJson {
|
|
20
|
+
/**
|
|
21
|
+
* An cropped image in form of a base64 string or file path,
|
|
22
|
+
* e.g., "./custom.png".
|
|
23
|
+
*/
|
|
24
|
+
customImage: string;
|
|
25
|
+
/**
|
|
26
|
+
* A unique name which can be used for filtering for the custom element,
|
|
27
|
+
* e.g.,
|
|
28
|
+
* ```typescript
|
|
29
|
+
* ...customElement({
|
|
30
|
+
* name: 'unique-name',
|
|
31
|
+
* // ... (rest of the custom element)
|
|
32
|
+
* }).withText('unique-name')
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* If not set, the text inside the custom element is
|
|
36
|
+
* detected via
|
|
37
|
+
* [OCR](https://en.wikipedia.org/wiki/Optical_character_recognition).
|
|
38
|
+
* It can also be used for filtering for the custom element.
|
|
39
|
+
*/
|
|
40
|
+
name?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* A threshold for how similar UI elements shown during test execution
|
|
43
|
+
* need to be to the custom element as defined by the other fields in
|
|
44
|
+
* `CustomElementJson` to be recognized as such. Takes values between
|
|
45
|
+
* `0.0` (= all elements are recognized as the custom element which is
|
|
46
|
+
* probably not what you want) and `1.0` (= elements need to look exactly
|
|
47
|
+
* like defined by `CustomElementJson` which is unlikely to be achieved
|
|
48
|
+
* as even minor differences count). Defaults to `0.9`.
|
|
49
|
+
*/
|
|
50
|
+
threshold?: number | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* A step size in rotation degree. Rotates the custom image by
|
|
53
|
+
* `rotationDegreePerStep` until 360° is exceeded. Range is between
|
|
54
|
+
* 0° - 360°. Defaults to 0°.
|
|
55
|
+
*
|
|
56
|
+
* **Important**: This increases the prediction time quite a bit. So only use
|
|
57
|
+
* it when absolutely necessary.
|
|
58
|
+
*/
|
|
59
|
+
rotationDegreePerStep?: number | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* A color compare style. Allows matching a custom element by color, e.g.,
|
|
62
|
+
* instead of filtering for all icons (blue and green ones),
|
|
63
|
+
* only the green ones captured by `customImage` are filtered for using 'RGB'.
|
|
64
|
+
* Defaults to 'grayscale'.
|
|
65
|
+
*
|
|
66
|
+
* **Important**: This increases the prediction time quite a bit. So only use
|
|
67
|
+
* it when absolutely necessary.
|
|
68
|
+
*/
|
|
69
|
+
imageCompareFormat?: 'RGB' | 'grayscale' | undefined;
|
|
70
|
+
/** A polygon to match only a certain area of the custom element. */
|
|
71
|
+
mask?: ({
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
})[] | undefined;
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CustomElementJson } from './custom-element-json';
|
|
2
|
+
export declare class CustomElement implements CustomElementJson {
|
|
3
|
+
customImage: string;
|
|
4
|
+
name?: string | undefined;
|
|
5
|
+
threshold?: number | undefined;
|
|
6
|
+
rotationDegreePerStep?: number | undefined;
|
|
7
|
+
imageCompareFormat?: "RGB" | "grayscale" | undefined;
|
|
8
|
+
mask?: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}[] | undefined;
|
|
12
|
+
private static schema;
|
|
13
|
+
constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "RGB" | "grayscale" | undefined, mask?: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}[] | undefined);
|
|
17
|
+
static fromJsonListWithImagePathOrImage(ceJson?: CustomElementJson[]): Promise<CustomElement[]>;
|
|
18
|
+
static fromJsonWithImagePathOrImage(ceJson: CustomElementJson): Promise<CustomElement>;
|
|
19
|
+
static fromJson(ceJson: CustomElementJson): CustomElement;
|
|
20
|
+
validate(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { array, number, object, ValidationError, } from 'yup';
|
|
11
|
+
import { Base64Image } from '../../../utils/base_64_image/base-64-image';
|
|
12
|
+
export class CustomElement {
|
|
13
|
+
constructor(customImage, name, threshold, rotationDegreePerStep, imageCompareFormat, mask) {
|
|
14
|
+
this.customImage = customImage;
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.threshold = threshold;
|
|
17
|
+
this.rotationDegreePerStep = rotationDegreePerStep;
|
|
18
|
+
this.imageCompareFormat = imageCompareFormat;
|
|
19
|
+
this.mask = mask;
|
|
20
|
+
}
|
|
21
|
+
static fromJsonListWithImagePathOrImage(ceJson = []) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return Promise.all(ceJson.map((customElement) => CustomElement.fromJsonWithImagePathOrImage(customElement)));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static fromJsonWithImagePathOrImage(ceJson) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const customImage = (yield Base64Image.fromPathOrString(ceJson.customImage)).toString();
|
|
29
|
+
const customElement = CustomElement.fromJson(Object.assign(Object.assign({}, ceJson), { customImage }));
|
|
30
|
+
customElement.validate();
|
|
31
|
+
return customElement;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
static fromJson(ceJson) {
|
|
35
|
+
return new CustomElement(ceJson.customImage, ceJson.name, ceJson.threshold, ceJson.rotationDegreePerStep, ceJson.imageCompareFormat, ceJson.mask);
|
|
36
|
+
}
|
|
37
|
+
validate() {
|
|
38
|
+
try {
|
|
39
|
+
CustomElement.schema.validateSync(this, { abortEarly: false, strict: true });
|
|
40
|
+
}
|
|
41
|
+
catch (e) { // ValidationError
|
|
42
|
+
throw new ValidationError(e.errors.join(', '));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
CustomElement.schema = object({
|
|
47
|
+
threshold: number().optional().min(0).max(1),
|
|
48
|
+
rotationDegreePerStep: number().optional().min(0).lessThan(360),
|
|
49
|
+
mask: array().optional().min(3, 'mask must contain at least 3 points'),
|
|
50
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CustomElement } from './custom-element';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TestStepState } from './test-step-state';
|
|
2
|
+
export declare class TestStepResultDto {
|
|
3
|
+
state: TestStepState;
|
|
4
|
+
comment: string;
|
|
5
|
+
createDate: Date;
|
|
6
|
+
updateDate: Date;
|
|
7
|
+
constructor(state: TestStepState, comment?: string, createDate?: Date, updateDate?: Date);
|
|
8
|
+
static fromJson(testStepResult: TestStepResultDto): TestStepResultDto;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TestStepState } from './test-step-state';
|
|
2
|
+
export class TestStepResultDto {
|
|
3
|
+
constructor(state, comment = '', createDate = new Date(), updateDate = new Date()) {
|
|
4
|
+
this.state = state;
|
|
5
|
+
this.comment = comment;
|
|
6
|
+
this.createDate = createDate;
|
|
7
|
+
this.updateDate = updateDate;
|
|
8
|
+
}
|
|
9
|
+
static fromJson(testStepResult) {
|
|
10
|
+
return new TestStepResultDto(TestStepState[testStepResult.state], testStepResult.comment, new Date(testStepResult.createDate), new Date(testStepResult.updateDate));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Step } from './step';
|
|
2
|
+
export declare const DEFAULT_REPORTER: {
|
|
3
|
+
config: {
|
|
4
|
+
readonly withScreenshots: "onFailure";
|
|
5
|
+
readonly withDetectedElements: "onFailure";
|
|
6
|
+
};
|
|
7
|
+
onStepBegin: (_step: Step) => Promise<void>;
|
|
8
|
+
onStepRetry: (_step: Step) => Promise<void>;
|
|
9
|
+
onStepEnd: (_step: Step) => Promise<void>;
|
|
10
|
+
};
|
package/dist/esm/lib/index.d.ts
CHANGED
package/dist/esm/lib/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addScript(filePath: string, name: string, command: string): Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import { logger } from '../logger';
|
|
12
|
+
export function addScript(filePath, name, command) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const data = yield fs.readFile(filePath, 'utf8');
|
|
16
|
+
const jsonData = JSON.parse(data);
|
|
17
|
+
if (jsonData.scripts === undefined) {
|
|
18
|
+
jsonData.scripts = { [name]: `${command}` };
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
jsonData.scripts[name] = command;
|
|
22
|
+
}
|
|
23
|
+
const jsonString = JSON.stringify(jsonData, null, 2);
|
|
24
|
+
yield fs.writeFile(filePath, jsonString, 'utf8');
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
logger.error(`Could write script '${command}' in file '${filePath}'`);
|
|
28
|
+
logger.error(error.message);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|