askui 0.10.0 → 0.10.2
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/dist/cjs/core/annotation/template.html +1 -11390
- package/dist/cjs/core/model/annotation-result/annotation-interface.d.ts +1 -1
- package/dist/cjs/core/model/custom-element-json.d.ts +75 -0
- package/dist/cjs/core/model/custom-element-json.js +2 -0
- package/dist/cjs/core/model/custom-element.d.ts +21 -0
- package/dist/cjs/core/model/custom-element.js +54 -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/core/reporting/default-step.d.ts +24 -0
- package/dist/cjs/core/reporting/default-step.js +75 -0
- package/dist/cjs/core/reporting/index.d.ts +11 -0
- package/dist/cjs/core/reporting/index.js +23 -0
- package/dist/cjs/core/reporting/instruction.d.ts +7 -0
- package/dist/cjs/core/reporting/instruction.js +2 -0
- package/dist/cjs/core/reporting/reporter-config.d.ts +13 -0
- package/dist/cjs/core/reporting/reporter-config.js +2 -0
- package/dist/cjs/core/reporting/reporter.d.ts +14 -0
- package/dist/cjs/core/reporting/reporter.js +2 -0
- package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +21 -0
- package/dist/cjs/core/reporting/snapshot-detail-level.js +2 -0
- package/dist/cjs/core/reporting/snapshot.d.ts +6 -0
- package/dist/cjs/core/reporting/snapshot.js +2 -0
- package/dist/cjs/core/reporting/step-reporter.d.ts +17 -0
- package/dist/cjs/core/reporting/step-reporter.js +64 -0
- package/dist/cjs/core/reporting/step-run.d.ts +9 -0
- package/dist/cjs/core/reporting/step-run.js +2 -0
- package/dist/cjs/core/reporting/step-status-end.d.ts +1 -0
- package/dist/cjs/core/reporting/step-status-end.js +2 -0
- package/dist/cjs/core/reporting/step-status.d.ts +13 -0
- package/dist/cjs/core/reporting/step-status.js +2 -0
- package/dist/cjs/core/reporting/step.d.ts +36 -0
- package/dist/cjs/core/reporting/step.js +2 -0
- package/dist/cjs/execution/dsl.d.ts +1 -1
- package/dist/cjs/execution/execution-runtime.d.ts +16 -9
- package/dist/cjs/execution/execution-runtime.js +79 -33
- package/dist/cjs/execution/inference-client.d.ts +1 -1
- package/dist/cjs/execution/reporter.d.ts +132 -0
- package/dist/cjs/execution/reporter.js +146 -0
- package/dist/cjs/execution/ui-control-client-dependency-builder.d.ts +14 -0
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +72 -0
- package/dist/cjs/execution/ui-control-client.d.ts +27 -15
- package/dist/cjs/execution/ui-control-client.js +97 -67
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +11 -2
- package/dist/cjs/execution/ui-controller-client.d.ts +4 -4
- package/dist/cjs/execution/ui-controller-client.js +6 -6
- package/dist/cjs/lib/ui-controller-facade.js +1 -1
- package/dist/cjs/main.d.ts +2 -1
- package/dist/cjs/main.js +2 -2
- package/dist/cjs/utils/proxy/proxy-builder.d.ts +1 -1
- package/dist/cjs/utils/proxy/proxy-builder.js +3 -3
- package/dist/esm/core/annotation/template.html +1 -11390
- package/dist/esm/core/model/annotation-result/annotation-interface.d.ts +1 -1
- package/dist/esm/core/model/custom-element-json.d.ts +75 -0
- package/dist/esm/core/model/custom-element-json.js +1 -0
- package/dist/esm/core/model/custom-element.d.ts +21 -0
- package/dist/esm/core/model/custom-element.js +50 -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/core/reporting/default-step.d.ts +24 -0
- package/dist/esm/core/reporting/default-step.js +71 -0
- package/dist/esm/core/reporting/index.d.ts +11 -0
- package/dist/esm/core/reporting/index.js +11 -0
- package/dist/esm/core/reporting/instruction.d.ts +7 -0
- package/dist/esm/core/reporting/instruction.js +1 -0
- package/dist/esm/core/reporting/reporter-config.d.ts +13 -0
- package/dist/esm/core/reporting/reporter-config.js +1 -0
- package/dist/esm/core/reporting/reporter.d.ts +14 -0
- package/dist/esm/core/reporting/reporter.js +1 -0
- package/dist/esm/core/reporting/snapshot-detail-level.d.ts +21 -0
- package/dist/esm/core/reporting/snapshot-detail-level.js +1 -0
- package/dist/esm/core/reporting/snapshot.d.ts +6 -0
- package/dist/esm/core/reporting/snapshot.js +1 -0
- package/dist/esm/core/reporting/step-reporter.d.ts +17 -0
- package/dist/esm/core/reporting/step-reporter.js +60 -0
- package/dist/esm/core/reporting/step-run.d.ts +9 -0
- package/dist/esm/core/reporting/step-run.js +1 -0
- package/dist/esm/core/reporting/step-status-end.d.ts +1 -0
- package/dist/esm/core/reporting/step-status-end.js +1 -0
- package/dist/esm/core/reporting/step-status.d.ts +13 -0
- package/dist/esm/core/reporting/step-status.js +1 -0
- package/dist/esm/core/reporting/step.d.ts +36 -0
- package/dist/esm/core/reporting/step.js +1 -0
- package/dist/esm/execution/dsl.d.ts +1 -1
- package/dist/esm/execution/execution-runtime.d.ts +16 -9
- package/dist/esm/execution/execution-runtime.js +77 -31
- package/dist/esm/execution/inference-client.d.ts +1 -1
- package/dist/esm/execution/reporter.d.ts +132 -0
- package/dist/esm/execution/reporter.js +142 -0
- package/dist/esm/execution/ui-control-client-dependency-builder.d.ts +14 -0
- package/dist/esm/execution/ui-control-client-dependency-builder.js +68 -0
- package/dist/esm/execution/ui-control-client.d.ts +27 -15
- package/dist/esm/execution/ui-control-client.js +96 -66
- package/dist/esm/execution/ui-controller-client-interface.d.ts +11 -2
- package/dist/esm/execution/ui-controller-client.d.ts +4 -4
- package/dist/esm/execution/ui-controller-client.js +6 -6
- package/dist/esm/lib/ui-controller-facade.js +2 -2
- package/dist/esm/main.d.ts +2 -1
- package/dist/esm/main.js +1 -1
- package/dist/esm/utils/proxy/proxy-builder.d.ts +1 -1
- package/dist/esm/utils/proxy/proxy-builder.js +1 -1
- package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +9 -2
- package/package.json +1 -1
|
@@ -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,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,54 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CustomElement = void 0;
|
|
13
|
+
const yup_1 = require("yup");
|
|
14
|
+
const base_64_image_1 = require("../../utils/base_64_image/base-64-image");
|
|
15
|
+
class CustomElement {
|
|
16
|
+
constructor(customImage, name, threshold, rotationDegreePerStep, imageCompareFormat, mask) {
|
|
17
|
+
this.customImage = customImage;
|
|
18
|
+
this.name = name;
|
|
19
|
+
this.threshold = threshold;
|
|
20
|
+
this.rotationDegreePerStep = rotationDegreePerStep;
|
|
21
|
+
this.imageCompareFormat = imageCompareFormat;
|
|
22
|
+
this.mask = mask;
|
|
23
|
+
}
|
|
24
|
+
static fromJsonListWithImagePathOrImage(ceJson = []) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return Promise.all(ceJson.map((customElement) => CustomElement.fromJsonWithImagePathOrImage(customElement)));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
static fromJsonWithImagePathOrImage(ceJson) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const customImage = (yield base_64_image_1.Base64Image.fromPathOrString(ceJson.customImage)).toString();
|
|
32
|
+
const customElement = CustomElement.fromJson(Object.assign(Object.assign({}, ceJson), { customImage }));
|
|
33
|
+
customElement.validate();
|
|
34
|
+
return customElement;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
static fromJson(ceJson) {
|
|
38
|
+
return new CustomElement(ceJson.customImage, ceJson.name, ceJson.threshold, ceJson.rotationDegreePerStep, ceJson.imageCompareFormat, ceJson.mask);
|
|
39
|
+
}
|
|
40
|
+
validate() {
|
|
41
|
+
try {
|
|
42
|
+
CustomElement.schema.validateSync(this, { abortEarly: false, strict: true });
|
|
43
|
+
}
|
|
44
|
+
catch (e) { // ValidationError
|
|
45
|
+
throw new yup_1.ValidationError(e.errors.join(', '));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.CustomElement = CustomElement;
|
|
50
|
+
CustomElement.schema = (0, yup_1.object)({
|
|
51
|
+
threshold: (0, yup_1.number)().optional().min(0).max(1),
|
|
52
|
+
rotationDegreePerStep: (0, yup_1.number)().optional().min(0).lessThan(360),
|
|
53
|
+
mask: (0, yup_1.array)().optional().min(3, 'mask must contain at least 3 points'),
|
|
54
|
+
});
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_REPORTER = void 0;
|
|
4
|
+
exports.DEFAULT_REPORTER = {
|
|
5
|
+
config: {
|
|
6
|
+
withScreenshots: 'onFailure',
|
|
7
|
+
withDetectedElements: 'onFailure',
|
|
8
|
+
},
|
|
9
|
+
onStepBegin: (_step) => Promise.resolve(),
|
|
10
|
+
onStepRetry: (_step) => Promise.resolve(),
|
|
11
|
+
onStepEnd: (_step) => Promise.resolve(),
|
|
12
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Instruction } from './instruction';
|
|
2
|
+
import { Snapshot } from './snapshot';
|
|
3
|
+
import { Step } from './step';
|
|
4
|
+
import { StepRun } from './step-run';
|
|
5
|
+
import { StepStatus } from './step-status';
|
|
6
|
+
export declare class DefaultStep implements Step {
|
|
7
|
+
instruction: Instruction;
|
|
8
|
+
runs: Readonly<StepRun[]>;
|
|
9
|
+
constructor(instruction: Instruction);
|
|
10
|
+
get status(): StepStatus;
|
|
11
|
+
get begin(): Snapshot | undefined;
|
|
12
|
+
get end(): Snapshot | undefined;
|
|
13
|
+
get error(): Error | undefined;
|
|
14
|
+
get retries(): StepRun[];
|
|
15
|
+
get retryCount(): number;
|
|
16
|
+
get firstRun(): StepRun | undefined;
|
|
17
|
+
get lastRun(): StepRun | undefined;
|
|
18
|
+
get flaky(): boolean;
|
|
19
|
+
get duration(): number | undefined;
|
|
20
|
+
onBegin(snapshot: Snapshot): DefaultStep;
|
|
21
|
+
onRetry(snapshot: Snapshot, error: Error): DefaultStep;
|
|
22
|
+
onEnd(snapshot: Snapshot, error?: Error): DefaultStep;
|
|
23
|
+
private static determineLastRunStatus;
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultStep = void 0;
|
|
4
|
+
class DefaultStep {
|
|
5
|
+
constructor(instruction) {
|
|
6
|
+
this.instruction = instruction;
|
|
7
|
+
this.runs = [];
|
|
8
|
+
}
|
|
9
|
+
get status() {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
return (_b = (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'pending';
|
|
12
|
+
}
|
|
13
|
+
get begin() {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = this.firstRun) === null || _a === void 0 ? void 0 : _a.begin;
|
|
16
|
+
}
|
|
17
|
+
get end() {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.end;
|
|
20
|
+
}
|
|
21
|
+
get error() {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.error;
|
|
24
|
+
}
|
|
25
|
+
get retries() {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return (_b = (_a = this.runs) === null || _a === void 0 ? void 0 : _a.slice(1)) !== null && _b !== void 0 ? _b : [];
|
|
28
|
+
}
|
|
29
|
+
get retryCount() {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return (_b = (_a = this.retries) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
32
|
+
}
|
|
33
|
+
get firstRun() {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = this.runs) === null || _a === void 0 ? void 0 : _a[0];
|
|
36
|
+
}
|
|
37
|
+
get lastRun() {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = this.runs) === null || _a === void 0 ? void 0 : _a[this.runs.length - 1];
|
|
40
|
+
}
|
|
41
|
+
get flaky() {
|
|
42
|
+
return this.retryCount > 0;
|
|
43
|
+
}
|
|
44
|
+
get duration() {
|
|
45
|
+
if (this.begin !== undefined && this.end !== undefined) {
|
|
46
|
+
return this.end.createdAt.getTime() - this.begin.createdAt.getTime();
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
onBegin(snapshot) {
|
|
51
|
+
this.runs = [...this.runs, {
|
|
52
|
+
status: 'running',
|
|
53
|
+
begin: snapshot,
|
|
54
|
+
}];
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
onRetry(snapshot, error) {
|
|
58
|
+
this.onEnd(snapshot, error);
|
|
59
|
+
this.onBegin(snapshot);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
onEnd(snapshot, error) {
|
|
63
|
+
this.runs = [...this.runs.slice(0, -1), Object.assign(Object.assign({}, this.lastRun), { status: DefaultStep.determineLastRunStatus(error), end: snapshot, error,
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
|
+
duration: snapshot.createdAt.getTime() - this.lastRun.begin.createdAt.getTime() })];
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
static determineLastRunStatus(error) {
|
|
69
|
+
if (error !== undefined) {
|
|
70
|
+
return 'failed';
|
|
71
|
+
}
|
|
72
|
+
return 'passed';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.DefaultStep = DefaultStep;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './default-reporter';
|
|
2
|
+
export * from './instruction';
|
|
3
|
+
export * from './reporter-config';
|
|
4
|
+
export * from './reporter';
|
|
5
|
+
export * from './snapshot-detail-level';
|
|
6
|
+
export * from './snapshot';
|
|
7
|
+
export * from './step-reporter';
|
|
8
|
+
export * from './step-run';
|
|
9
|
+
export * from './step-status-end';
|
|
10
|
+
export * from './step-status';
|
|
11
|
+
export * from './step';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./default-reporter"), exports);
|
|
14
|
+
__exportStar(require("./instruction"), exports);
|
|
15
|
+
__exportStar(require("./reporter-config"), exports);
|
|
16
|
+
__exportStar(require("./reporter"), exports);
|
|
17
|
+
__exportStar(require("./snapshot-detail-level"), exports);
|
|
18
|
+
__exportStar(require("./snapshot"), exports);
|
|
19
|
+
__exportStar(require("./step-reporter"), exports);
|
|
20
|
+
__exportStar(require("./step-run"), exports);
|
|
21
|
+
__exportStar(require("./step-status-end"), exports);
|
|
22
|
+
__exportStar(require("./step-status"), exports);
|
|
23
|
+
__exportStar(require("./step"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomElement } from '@/core/model/custom-element';
|
|
2
|
+
export interface Instruction {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
readonly valueHumanReadable: string;
|
|
5
|
+
readonly customElements?: Readonly<Readonly<CustomElement>>[];
|
|
6
|
+
readonly secretText?: string | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SnapshotDetailLevel } from './snapshot-detail-level';
|
|
2
|
+
export interface ReporterConfig {
|
|
3
|
+
/**
|
|
4
|
+
* default: onFailure; makes step run slower
|
|
5
|
+
*/
|
|
6
|
+
withScreenshots?: SnapshotDetailLevel;
|
|
7
|
+
/**
|
|
8
|
+
* overrides withScreenshot if higher level of detail as screenshot
|
|
9
|
+
* is required for detecting elements;
|
|
10
|
+
* incurres additional cost; default: onFailure; makes step run slower
|
|
11
|
+
*/
|
|
12
|
+
withDetectedElements?: SnapshotDetailLevel;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Step } from './step';
|
|
2
|
+
import { ReporterConfig } from './reporter-config';
|
|
3
|
+
/**
|
|
4
|
+
* Can be used to report on a step run.
|
|
5
|
+
*
|
|
6
|
+
* The reporter is an interface (instead of a class) so that the it may be implemented by a class
|
|
7
|
+
* that already extends another class, e.g., the reporter of a test framework.
|
|
8
|
+
*/
|
|
9
|
+
export interface Reporter {
|
|
10
|
+
config?: ReporterConfig;
|
|
11
|
+
onStepBegin?(step: Step): Promise<void>;
|
|
12
|
+
onStepRetry?(step: Step): Promise<void>;
|
|
13
|
+
onStepEnd?(step: Step): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare type SnapshotDetailLevel =
|
|
2
|
+
/**
|
|
3
|
+
* Details of snapshot, e.g., screenshot or detected elements, may or may not be available
|
|
4
|
+
* depending on if they are required by the step. There are not guarantees made.
|
|
5
|
+
*/
|
|
6
|
+
'required' |
|
|
7
|
+
/**
|
|
8
|
+
* Details are available when the step fails, e.g., for debugging.
|
|
9
|
+
* Includes everything of required.
|
|
10
|
+
*/
|
|
11
|
+
'onFailure' |
|
|
12
|
+
/**
|
|
13
|
+
* Details are available also when the command is started, e.g.,
|
|
14
|
+
* for detecting why a certain element was interacted with. Includes everything of onFailure.
|
|
15
|
+
*/
|
|
16
|
+
'begin' |
|
|
17
|
+
/**
|
|
18
|
+
* Details are available always, e.g.,
|
|
19
|
+
* before and after a step has been run no matter if it failed or not for debugging.
|
|
20
|
+
*/
|
|
21
|
+
'always';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Snapshot } from './snapshot';
|
|
2
|
+
import { Instruction } from './instruction';
|
|
3
|
+
import { Reporter } from './reporter';
|
|
4
|
+
import { ReporterConfig } from './reporter-config';
|
|
5
|
+
import { DefaultStep } from './default-step';
|
|
6
|
+
export declare class StepReporter {
|
|
7
|
+
private reporter;
|
|
8
|
+
currentStep?: DefaultStep | undefined;
|
|
9
|
+
constructor(reporter: Required<Reporter> & {
|
|
10
|
+
config: Required<ReporterConfig>;
|
|
11
|
+
});
|
|
12
|
+
get config(): Required<ReporterConfig>;
|
|
13
|
+
resetStep(instruction: Instruction): void;
|
|
14
|
+
onStepBegin(snapshot: Snapshot): Promise<void>;
|
|
15
|
+
onStepRetry(snapshot: Snapshot, error: Error): Promise<void>;
|
|
16
|
+
onStepEnd(snapshot: Snapshot, error?: Error): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StepReporter = void 0;
|
|
13
|
+
const default_step_1 = require("./default-step");
|
|
14
|
+
class StepReporter {
|
|
15
|
+
constructor(reporter) {
|
|
16
|
+
this.reporter = reporter;
|
|
17
|
+
}
|
|
18
|
+
get config() {
|
|
19
|
+
return this.reporter.config;
|
|
20
|
+
}
|
|
21
|
+
resetStep(instruction) {
|
|
22
|
+
this.currentStep = new default_step_1.DefaultStep(instruction);
|
|
23
|
+
}
|
|
24
|
+
onStepBegin(snapshot) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (this.currentStep === undefined) {
|
|
28
|
+
throw new Error('Cannot begin step if step is undefined.');
|
|
29
|
+
}
|
|
30
|
+
if (this.currentStep.status !== 'pending') {
|
|
31
|
+
throw new Error('Cannot begin step that is not pending.');
|
|
32
|
+
}
|
|
33
|
+
this.currentStep.onBegin(snapshot);
|
|
34
|
+
yield ((_b = (_a = this.reporter).onStepBegin) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
onStepRetry(snapshot, error) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (this.currentStep === undefined) {
|
|
41
|
+
throw new Error('Cannot retry step if step is undefined.');
|
|
42
|
+
}
|
|
43
|
+
if (this.currentStep.status !== 'running') {
|
|
44
|
+
throw new Error('Cannot retry step that has not been running.');
|
|
45
|
+
}
|
|
46
|
+
this.currentStep.onRetry(snapshot, error);
|
|
47
|
+
yield ((_b = (_a = this.reporter).onStepRetry) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
onStepEnd(snapshot, error) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (this.currentStep === undefined) {
|
|
54
|
+
throw new Error('Cannot end step if step is undefined.');
|
|
55
|
+
}
|
|
56
|
+
if (this.currentStep.status !== 'running') {
|
|
57
|
+
throw new Error('Cannot end step that has not been running.');
|
|
58
|
+
}
|
|
59
|
+
this.currentStep.onEnd(snapshot, error);
|
|
60
|
+
yield ((_b = (_a = this.reporter).onStepEnd) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.StepReporter = StepReporter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StepStatus } from './step-status';
|
|
2
|
+
import { Snapshot } from './snapshot';
|
|
3
|
+
export interface StepRun {
|
|
4
|
+
readonly status: StepStatus;
|
|
5
|
+
readonly begin?: Snapshot | undefined;
|
|
6
|
+
readonly end?: Snapshot | undefined;
|
|
7
|
+
readonly duration?: number | undefined;
|
|
8
|
+
readonly error?: Error | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type StepStatusEnd = 'passed' | 'failed' | 'erroneous';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - `passed`: the step passed
|
|
3
|
+
* - `failed`: the step failed because of a failed (implicit/explicit) assertion,
|
|
4
|
+
* e.g., an element could not be found
|
|
5
|
+
* - `pending`: the step is waiting for a previous step to pass
|
|
6
|
+
* - `running`: the step is currently running (including retries)
|
|
7
|
+
* - `skipped`: the step was skipped, e.g., because a previous step failed or
|
|
8
|
+
* because workflow was skipped
|
|
9
|
+
* - `erroneous`: the step could not be run because of a runtime error,
|
|
10
|
+
* e.g., the user has no usage left, response of inference backend cannot be processed,
|
|
11
|
+
* e.g., because lib version is outdated, etc. (currently not supported, everything "failed")
|
|
12
|
+
*/
|
|
13
|
+
export declare type StepStatus = 'passed' | 'failed' | 'pending' | 'running' | 'erroneous';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StepStatus } from './step-status';
|
|
2
|
+
import { Snapshot } from './snapshot';
|
|
3
|
+
import { Instruction } from './instruction';
|
|
4
|
+
import { StepRun } from './step-run';
|
|
5
|
+
export interface Step {
|
|
6
|
+
readonly instruction: Readonly<Instruction>;
|
|
7
|
+
readonly status: StepStatus;
|
|
8
|
+
/**
|
|
9
|
+
* A snapshot of the state of the screen before the step is
|
|
10
|
+
* ran which is nearly immediately after the call to `.exec()`
|
|
11
|
+
*/
|
|
12
|
+
readonly begin?: Snapshot | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The duration of the step in milliseconds based on the start
|
|
15
|
+
* and end time. If the step is still running, this property is undefined.
|
|
16
|
+
*/
|
|
17
|
+
readonly duration?: number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A snapshot of the state of the screen after the step has been run.
|
|
20
|
+
* If the step is still running or still pending, this property is undefined.
|
|
21
|
+
*/
|
|
22
|
+
readonly end?: Snapshot | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* When a step failed or is erroneous, this property contains the error.
|
|
25
|
+
*/
|
|
26
|
+
readonly error?: Error | undefined;
|
|
27
|
+
readonly runs: Readonly<StepRun[]>;
|
|
28
|
+
readonly retries: Readonly<StepRun[]>;
|
|
29
|
+
readonly retryCount: number;
|
|
30
|
+
readonly firstRun?: StepRun | undefined;
|
|
31
|
+
readonly lastRun?: StepRun | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* retryCount > 0.
|
|
34
|
+
*/
|
|
35
|
+
readonly flaky: boolean;
|
|
36
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomElementJson } from '../core/model/
|
|
1
|
+
import { CustomElementJson } from '../core/model/custom-element-json';
|
|
2
2
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
3
3
|
export declare enum Separators {
|
|
4
4
|
STRING = "<|string|>"
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { TestStep } from '../core/model/test-case-dto';
|
|
2
1
|
import { UiControllerClient } from './ui-controller-client';
|
|
3
2
|
import { InferenceClient } from './inference-client';
|
|
4
3
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
|
-
import { CustomElementJson } from '../core/model/
|
|
4
|
+
import { CustomElementJson } from '../core/model/custom-element-json';
|
|
6
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
|
+
import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
|
|
7
|
+
import { Instruction, StepReporter } from '../core/reporting';
|
|
7
8
|
export declare class ExecutionRuntime {
|
|
8
9
|
private uiControllerClient;
|
|
9
10
|
private inferenceClient;
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
private stepReporter;
|
|
12
|
+
constructor(uiControllerClient: UiControllerClient, inferenceClient: InferenceClient, stepReporter: StepReporter);
|
|
13
|
+
connect(): Promise<UiControllerClientConnectionState>;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
startVideoRecording(): Promise<void>;
|
|
16
|
+
stopVideoRecording(): Promise<void>;
|
|
17
|
+
readVideoRecording(): Promise<string>;
|
|
12
18
|
private requestControl;
|
|
13
|
-
|
|
14
|
-
* @param {TestStep} step - Test step used for predicting command.
|
|
15
|
-
*/
|
|
16
|
-
private executeCommand;
|
|
19
|
+
executeInstruction(instruction: Instruction): Promise<void>;
|
|
17
20
|
private readonly EXEC_REPETITION_COUNT;
|
|
18
21
|
private executeCommandRepeatedly;
|
|
19
22
|
private readonly PREDICT_COMMAND_RETRY_COUNT;
|
|
@@ -22,7 +25,11 @@ export declare class ExecutionRuntime {
|
|
|
22
25
|
* --> retry with linear back-off
|
|
23
26
|
*/
|
|
24
27
|
private predictCommandWithRetry;
|
|
25
|
-
private
|
|
28
|
+
private isImageRequiredByConfig;
|
|
29
|
+
private isImageRequired;
|
|
30
|
+
private isAnnotationRequired;
|
|
31
|
+
getScreenshot(): Promise<string>;
|
|
32
|
+
private buildSnapshot;
|
|
26
33
|
private predictCommand;
|
|
27
34
|
annotateInteractively(): Promise<void>;
|
|
28
35
|
takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
|