askui 0.12.1 → 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/cjs/utils/base_64_image/base-64-image.d.ts +6 -9
- package/dist/cjs/utils/base_64_image/base-64-image.js +32 -33
- package/dist/cjs/utils/base_64_image/sharp.d.ts +2 -0
- package/dist/cjs/utils/base_64_image/sharp.js +56 -0
- package/dist/cjs/utils/proxy/proxy-builder.js +3 -1
- package/dist/cjs/utils/transformations.js +4 -2
- 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/esm/utils/base_64_image/base-64-image.d.ts +6 -9
- package/dist/esm/utils/base_64_image/base-64-image.js +32 -33
- package/dist/esm/utils/base_64_image/sharp.d.ts +2 -0
- package/dist/esm/utils/base_64_image/sharp.js +33 -0
- package/dist/esm/utils/proxy/proxy-builder.js +3 -1
- package/dist/esm/utils/transformations.js +4 -2
- 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 +11 -3
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
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 inquirer from 'inquirer';
|
|
11
|
+
import { Command, Option } from 'commander';
|
|
12
|
+
import { CreateExampleProject } from './create-example-project';
|
|
13
|
+
const nonEmpty = (subject) => (input) => (input.trim().length > 0) || `${subject} is required.`;
|
|
14
|
+
const questions = [
|
|
15
|
+
{
|
|
16
|
+
type: 'list',
|
|
17
|
+
name: 'testFramework',
|
|
18
|
+
message: 'Which framework do you prefer',
|
|
19
|
+
choices: ['jest', 'jasmine'],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'workspaceId',
|
|
24
|
+
message: 'Your workspace id',
|
|
25
|
+
validate: nonEmpty('workspace id'),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'password',
|
|
29
|
+
name: 'accessToken',
|
|
30
|
+
message: 'Your access token',
|
|
31
|
+
mask: '*',
|
|
32
|
+
validate: nonEmpty('access token'),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'confirm',
|
|
36
|
+
name: 'usingProxy',
|
|
37
|
+
message: 'Are you using a proxy?',
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'confirm',
|
|
42
|
+
name: 'typescriptConfig',
|
|
43
|
+
message: 'Do you want to add the tsconfig.json file? This action will overwrite the file if it exists. Default True ',
|
|
44
|
+
default: true,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
const options = [
|
|
48
|
+
{
|
|
49
|
+
option: '-f, --test-framework <value>',
|
|
50
|
+
choices: ['jasmine', 'jest'],
|
|
51
|
+
description: 'the test framework to use',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
option: '-w, --workspace-id <value>',
|
|
55
|
+
choices: [],
|
|
56
|
+
description: 'a workspace id',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
option: '-a, --access-token <value>',
|
|
60
|
+
choices: [],
|
|
61
|
+
description: 'an access token for the workspace with the id',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
option: '-p, --using-proxy <value>',
|
|
65
|
+
choices: ['true', 'false'],
|
|
66
|
+
description: 'use a proxy',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
option: '-t, --typescript-config <value>',
|
|
70
|
+
choices: ['true', 'false'],
|
|
71
|
+
description: 'overwrite tsconfig.json flag',
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
const createProgram = () => {
|
|
75
|
+
const program = new Command('askui');
|
|
76
|
+
program.usage('<command> [options]');
|
|
77
|
+
return program;
|
|
78
|
+
};
|
|
79
|
+
export function init(argv) {
|
|
80
|
+
const args = argv || process.argv;
|
|
81
|
+
const program = createProgram();
|
|
82
|
+
const programInit = program.command('init');
|
|
83
|
+
programInit.description('Creates a askui example project');
|
|
84
|
+
// Loop through the options object and register each option with the program
|
|
85
|
+
options.forEach((opt) => {
|
|
86
|
+
const tempOption = new Option(opt.option, opt.description);
|
|
87
|
+
if (opt.choices.length > 0) {
|
|
88
|
+
tempOption.choices(opt.choices);
|
|
89
|
+
}
|
|
90
|
+
programInit.addOption(tempOption);
|
|
91
|
+
});
|
|
92
|
+
programInit.usage('[-f test_framework] [-w workspace_id] [-a access_token] [-p boolean] [-t boolean]');
|
|
93
|
+
programInit
|
|
94
|
+
.action((_opts) => __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const userAnswers = programInit.opts();
|
|
96
|
+
// Check which options are missing and prompt the user for them
|
|
97
|
+
const missingOptions = questions.filter((entry) => !(entry.name in userAnswers));
|
|
98
|
+
if (missingOptions.length > 0) {
|
|
99
|
+
inquirer.prompt(missingOptions).then((answers) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
yield new CreateExampleProject(Object.assign(Object.assign({}, userAnswers), answers)).createExampleProject();
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
yield new CreateExampleProject(userAnswers).createExampleProject();
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
return program.parse(args);
|
|
108
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CliOptions } from './cli-options-interface';
|
|
2
|
+
export declare class CreateExampleProject {
|
|
3
|
+
readonly cliOptions: CliOptions;
|
|
4
|
+
private distexampleFolderPath;
|
|
5
|
+
private exampleFolderName;
|
|
6
|
+
private baseDirPath;
|
|
7
|
+
private proxyDocUrl;
|
|
8
|
+
private remoteDeviceControllerUrl;
|
|
9
|
+
private helperTemplateConfig;
|
|
10
|
+
constructor(cliOptions: CliOptions);
|
|
11
|
+
private copyTemplateProject;
|
|
12
|
+
private copyTestFrameworkConfig;
|
|
13
|
+
private addTestFrameWorkTimeout;
|
|
14
|
+
private addReporterConfig;
|
|
15
|
+
private addAskuiRunCommand;
|
|
16
|
+
private addESLintRunCommand;
|
|
17
|
+
private createAskUIHelperFromTemplate;
|
|
18
|
+
private setupTestFrameWork;
|
|
19
|
+
private installTestFrameworkPackages;
|
|
20
|
+
private addUserCredentails;
|
|
21
|
+
private copyESLintConfigFiles;
|
|
22
|
+
private copyTsConfigFile;
|
|
23
|
+
private installProxy;
|
|
24
|
+
private normalizeCliOptions;
|
|
25
|
+
createExampleProject(): Promise<void>;
|
|
26
|
+
}
|