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.
Files changed (102) hide show
  1. package/dist/cjs/core/annotation/template.html +1 -11390
  2. package/dist/cjs/core/model/annotation-result/annotation-interface.d.ts +1 -1
  3. package/dist/cjs/core/model/custom-element-json.d.ts +75 -0
  4. package/dist/cjs/core/model/custom-element-json.js +2 -0
  5. package/dist/cjs/core/model/custom-element.d.ts +21 -0
  6. package/dist/cjs/core/model/custom-element.js +54 -0
  7. package/dist/cjs/core/reporting/default-reporter.d.ts +10 -0
  8. package/dist/cjs/core/reporting/default-reporter.js +12 -0
  9. package/dist/cjs/core/reporting/default-step.d.ts +24 -0
  10. package/dist/cjs/core/reporting/default-step.js +75 -0
  11. package/dist/cjs/core/reporting/index.d.ts +11 -0
  12. package/dist/cjs/core/reporting/index.js +23 -0
  13. package/dist/cjs/core/reporting/instruction.d.ts +7 -0
  14. package/dist/cjs/core/reporting/instruction.js +2 -0
  15. package/dist/cjs/core/reporting/reporter-config.d.ts +13 -0
  16. package/dist/cjs/core/reporting/reporter-config.js +2 -0
  17. package/dist/cjs/core/reporting/reporter.d.ts +14 -0
  18. package/dist/cjs/core/reporting/reporter.js +2 -0
  19. package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +21 -0
  20. package/dist/cjs/core/reporting/snapshot-detail-level.js +2 -0
  21. package/dist/cjs/core/reporting/snapshot.d.ts +6 -0
  22. package/dist/cjs/core/reporting/snapshot.js +2 -0
  23. package/dist/cjs/core/reporting/step-reporter.d.ts +17 -0
  24. package/dist/cjs/core/reporting/step-reporter.js +64 -0
  25. package/dist/cjs/core/reporting/step-run.d.ts +9 -0
  26. package/dist/cjs/core/reporting/step-run.js +2 -0
  27. package/dist/cjs/core/reporting/step-status-end.d.ts +1 -0
  28. package/dist/cjs/core/reporting/step-status-end.js +2 -0
  29. package/dist/cjs/core/reporting/step-status.d.ts +13 -0
  30. package/dist/cjs/core/reporting/step-status.js +2 -0
  31. package/dist/cjs/core/reporting/step.d.ts +36 -0
  32. package/dist/cjs/core/reporting/step.js +2 -0
  33. package/dist/cjs/execution/dsl.d.ts +1 -1
  34. package/dist/cjs/execution/execution-runtime.d.ts +16 -9
  35. package/dist/cjs/execution/execution-runtime.js +79 -33
  36. package/dist/cjs/execution/inference-client.d.ts +1 -1
  37. package/dist/cjs/execution/reporter.d.ts +132 -0
  38. package/dist/cjs/execution/reporter.js +146 -0
  39. package/dist/cjs/execution/ui-control-client-dependency-builder.d.ts +14 -0
  40. package/dist/cjs/execution/ui-control-client-dependency-builder.js +72 -0
  41. package/dist/cjs/execution/ui-control-client.d.ts +27 -15
  42. package/dist/cjs/execution/ui-control-client.js +97 -67
  43. package/dist/cjs/execution/ui-controller-client-interface.d.ts +11 -2
  44. package/dist/cjs/execution/ui-controller-client.d.ts +4 -4
  45. package/dist/cjs/execution/ui-controller-client.js +6 -6
  46. package/dist/cjs/lib/ui-controller-facade.js +1 -1
  47. package/dist/cjs/main.d.ts +2 -1
  48. package/dist/cjs/main.js +2 -2
  49. package/dist/cjs/utils/proxy/proxy-builder.d.ts +1 -1
  50. package/dist/cjs/utils/proxy/proxy-builder.js +3 -3
  51. package/dist/esm/core/annotation/template.html +1 -11390
  52. package/dist/esm/core/model/annotation-result/annotation-interface.d.ts +1 -1
  53. package/dist/esm/core/model/custom-element-json.d.ts +75 -0
  54. package/dist/esm/core/model/custom-element-json.js +1 -0
  55. package/dist/esm/core/model/custom-element.d.ts +21 -0
  56. package/dist/esm/core/model/custom-element.js +50 -0
  57. package/dist/esm/core/reporting/default-reporter.d.ts +10 -0
  58. package/dist/esm/core/reporting/default-reporter.js +9 -0
  59. package/dist/esm/core/reporting/default-step.d.ts +24 -0
  60. package/dist/esm/core/reporting/default-step.js +71 -0
  61. package/dist/esm/core/reporting/index.d.ts +11 -0
  62. package/dist/esm/core/reporting/index.js +11 -0
  63. package/dist/esm/core/reporting/instruction.d.ts +7 -0
  64. package/dist/esm/core/reporting/instruction.js +1 -0
  65. package/dist/esm/core/reporting/reporter-config.d.ts +13 -0
  66. package/dist/esm/core/reporting/reporter-config.js +1 -0
  67. package/dist/esm/core/reporting/reporter.d.ts +14 -0
  68. package/dist/esm/core/reporting/reporter.js +1 -0
  69. package/dist/esm/core/reporting/snapshot-detail-level.d.ts +21 -0
  70. package/dist/esm/core/reporting/snapshot-detail-level.js +1 -0
  71. package/dist/esm/core/reporting/snapshot.d.ts +6 -0
  72. package/dist/esm/core/reporting/snapshot.js +1 -0
  73. package/dist/esm/core/reporting/step-reporter.d.ts +17 -0
  74. package/dist/esm/core/reporting/step-reporter.js +60 -0
  75. package/dist/esm/core/reporting/step-run.d.ts +9 -0
  76. package/dist/esm/core/reporting/step-run.js +1 -0
  77. package/dist/esm/core/reporting/step-status-end.d.ts +1 -0
  78. package/dist/esm/core/reporting/step-status-end.js +1 -0
  79. package/dist/esm/core/reporting/step-status.d.ts +13 -0
  80. package/dist/esm/core/reporting/step-status.js +1 -0
  81. package/dist/esm/core/reporting/step.d.ts +36 -0
  82. package/dist/esm/core/reporting/step.js +1 -0
  83. package/dist/esm/execution/dsl.d.ts +1 -1
  84. package/dist/esm/execution/execution-runtime.d.ts +16 -9
  85. package/dist/esm/execution/execution-runtime.js +77 -31
  86. package/dist/esm/execution/inference-client.d.ts +1 -1
  87. package/dist/esm/execution/reporter.d.ts +132 -0
  88. package/dist/esm/execution/reporter.js +142 -0
  89. package/dist/esm/execution/ui-control-client-dependency-builder.d.ts +14 -0
  90. package/dist/esm/execution/ui-control-client-dependency-builder.js +68 -0
  91. package/dist/esm/execution/ui-control-client.d.ts +27 -15
  92. package/dist/esm/execution/ui-control-client.js +96 -66
  93. package/dist/esm/execution/ui-controller-client-interface.d.ts +11 -2
  94. package/dist/esm/execution/ui-controller-client.d.ts +4 -4
  95. package/dist/esm/execution/ui-controller-client.js +6 -6
  96. package/dist/esm/lib/ui-controller-facade.js +2 -2
  97. package/dist/esm/main.d.ts +2 -1
  98. package/dist/esm/main.js +1 -1
  99. package/dist/esm/utils/proxy/proxy-builder.d.ts +1 -1
  100. package/dist/esm/utils/proxy/proxy-builder.js +1 -1
  101. package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +9 -2
  102. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { CustomElementJson } from '../test-case-dto';
1
+ import { CustomElementJson } from '../custom-element-json';
2
2
  export interface AnnotationRequest {
3
3
  imagePath?: string;
4
4
  outputPath?: string;
@@ -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,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,9 @@
1
+ export const DEFAULT_REPORTER = {
2
+ config: {
3
+ withScreenshots: 'onFailure',
4
+ withDetectedElements: 'onFailure',
5
+ },
6
+ onStepBegin: (_step) => Promise.resolve(),
7
+ onStepRetry: (_step) => Promise.resolve(),
8
+ onStepEnd: (_step) => Promise.resolve(),
9
+ };
@@ -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,71 @@
1
+ export class DefaultStep {
2
+ constructor(instruction) {
3
+ this.instruction = instruction;
4
+ this.runs = [];
5
+ }
6
+ get status() {
7
+ var _a, _b;
8
+ return (_b = (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 'pending';
9
+ }
10
+ get begin() {
11
+ var _a;
12
+ return (_a = this.firstRun) === null || _a === void 0 ? void 0 : _a.begin;
13
+ }
14
+ get end() {
15
+ var _a;
16
+ return (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.end;
17
+ }
18
+ get error() {
19
+ var _a;
20
+ return (_a = this.lastRun) === null || _a === void 0 ? void 0 : _a.error;
21
+ }
22
+ get retries() {
23
+ var _a, _b;
24
+ return (_b = (_a = this.runs) === null || _a === void 0 ? void 0 : _a.slice(1)) !== null && _b !== void 0 ? _b : [];
25
+ }
26
+ get retryCount() {
27
+ var _a, _b;
28
+ return (_b = (_a = this.retries) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
29
+ }
30
+ get firstRun() {
31
+ var _a;
32
+ return (_a = this.runs) === null || _a === void 0 ? void 0 : _a[0];
33
+ }
34
+ get lastRun() {
35
+ var _a;
36
+ return (_a = this.runs) === null || _a === void 0 ? void 0 : _a[this.runs.length - 1];
37
+ }
38
+ get flaky() {
39
+ return this.retryCount > 0;
40
+ }
41
+ get duration() {
42
+ if (this.begin !== undefined && this.end !== undefined) {
43
+ return this.end.createdAt.getTime() - this.begin.createdAt.getTime();
44
+ }
45
+ return undefined;
46
+ }
47
+ onBegin(snapshot) {
48
+ this.runs = [...this.runs, {
49
+ status: 'running',
50
+ begin: snapshot,
51
+ }];
52
+ return this;
53
+ }
54
+ onRetry(snapshot, error) {
55
+ this.onEnd(snapshot, error);
56
+ this.onBegin(snapshot);
57
+ return this;
58
+ }
59
+ onEnd(snapshot, error) {
60
+ this.runs = [...this.runs.slice(0, -1), Object.assign(Object.assign({}, this.lastRun), { status: DefaultStep.determineLastRunStatus(error), end: snapshot, error,
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
+ duration: snapshot.createdAt.getTime() - this.lastRun.begin.createdAt.getTime() })];
63
+ return this;
64
+ }
65
+ static determineLastRunStatus(error) {
66
+ if (error !== undefined) {
67
+ return 'failed';
68
+ }
69
+ return 'passed';
70
+ }
71
+ }
@@ -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,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,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 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { DetectedElement } from '../model/annotation-result/detected-element';
2
+ export interface Snapshot {
3
+ readonly createdAt: Date;
4
+ readonly screenshot?: string | undefined;
5
+ readonly detectedElements?: Readonly<Readonly<DetectedElement>>[] | undefined;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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,60 @@
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 { DefaultStep } from './default-step';
11
+ export class StepReporter {
12
+ constructor(reporter) {
13
+ this.reporter = reporter;
14
+ }
15
+ get config() {
16
+ return this.reporter.config;
17
+ }
18
+ resetStep(instruction) {
19
+ this.currentStep = new DefaultStep(instruction);
20
+ }
21
+ onStepBegin(snapshot) {
22
+ var _a, _b;
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ if (this.currentStep === undefined) {
25
+ throw new Error('Cannot begin step if step is undefined.');
26
+ }
27
+ if (this.currentStep.status !== 'pending') {
28
+ throw new Error('Cannot begin step that is not pending.');
29
+ }
30
+ this.currentStep.onBegin(snapshot);
31
+ yield ((_b = (_a = this.reporter).onStepBegin) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
32
+ });
33
+ }
34
+ onStepRetry(snapshot, error) {
35
+ var _a, _b;
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (this.currentStep === undefined) {
38
+ throw new Error('Cannot retry step if step is undefined.');
39
+ }
40
+ if (this.currentStep.status !== 'running') {
41
+ throw new Error('Cannot retry step that has not been running.');
42
+ }
43
+ this.currentStep.onRetry(snapshot, error);
44
+ yield ((_b = (_a = this.reporter).onStepRetry) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
45
+ });
46
+ }
47
+ onStepEnd(snapshot, error) {
48
+ var _a, _b;
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ if (this.currentStep === undefined) {
51
+ throw new Error('Cannot end step if step is undefined.');
52
+ }
53
+ if (this.currentStep.status !== 'running') {
54
+ throw new Error('Cannot end step that has not been running.');
55
+ }
56
+ this.currentStep.onEnd(snapshot, error);
57
+ yield ((_b = (_a = this.reporter).onStepEnd) === null || _b === void 0 ? void 0 : _b.call(_a, this.currentStep));
58
+ });
59
+ }
60
+ }
@@ -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 {};
@@ -0,0 +1 @@
1
+ export declare type StepStatusEnd = 'passed' | 'failed' | 'erroneous';
@@ -0,0 +1 @@
1
+ export {};
@@ -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 @@
1
+ export {};
@@ -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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { CustomElementJson } from '../core/model/test-case-dto';
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/test-case-dto/custom-element-json';
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
- constructor(uiControllerClient: UiControllerClient, inferenceClient: InferenceClient);
11
- executeTestStep(step: TestStep): Promise<void>;
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 getImageIfRequired;
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>;