@auxcode/auxta 1.3.110 → 1.3.113

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 CHANGED
@@ -1,11 +1,37 @@
1
1
  # AuxTA
2
2
 
3
+ ## Guidelines for the Frontend Programmers
4
+
5
+ Every HTML element on a web page can be a selector, which can be used to create AuxTA scenarios.
6
+
7
+ Of course, not all HTML elemets are used as selectors to create AuxTA scenarios.
8
+
9
+ Those HTML elements, which will be used as selectors for AuxTA scenarios, should have a Unique ID. This way AuxTA scenarios are created the fastest.
10
+
11
+ The best candidate for this is the HTML "id" attribute.
12
+
13
+ The ID value should reflect the functionality of the place.
14
+
15
+ To create a unique ID, make it multipart, beginning with more general parts which are guaranteed to be unique. This way one creates namespaces, which make it easier after that to end up with a unique ID.
16
+
17
+ For expmple:
18
+
19
+ id="shop_cart_button_submit"
20
+
21
+ More than one of the same element, For example several tables on one page, each should have a unique ID.
22
+
23
+ If it has nested elements they can have the same selectors as in the other elements, but it’s not necessary.
24
+
3
25
  ## Implementing
4
26
 
5
27
  The main thing is a `scenario`.
6
28
 
7
29
  `Scenarios` consts of `steps.
8
30
 
31
+ ### Helpers
32
+
33
+ Change so that there is one function per helper file.
34
+
9
35
  ### Clicking
10
36
 
11
37
  All clicks wait for the selector by default and timeout w/ the standard timeout unless different is specified.
@@ -28,6 +54,14 @@ waitforseelctorbytext `depreciated`
28
54
 
29
55
  ### Complex Workflows
30
56
 
57
+ #### Use Bulilding Blocks
58
+
59
+ Building Blocks do one simple thing each and allow you to build State Scripts and Scenrios.
60
+
61
+ #### Use State Scripts
62
+
63
+ State Scripts bring the system to a desired state from which a specific scenario begins.
64
+
31
65
  #### Email
32
66
 
33
67
  * (AuxTA) We do some action on the website.
@@ -106,4 +140,10 @@ control click go to source directory
106
140
 
107
141
  Also some improvements to the platform in general:
108
142
 
109
- * get the console state after a fail, this would increase the value of each failed report.
143
+ * get the console state after a fail, this would increase the value of each failed report.
144
+
145
+ # Backlog
146
+
147
+ ## 13 October 2024
148
+
149
+ Make so that there can be more than one helper file and that we have one function per helper file.
@@ -24,7 +24,7 @@ export declare class LogSteps {
24
24
  };
25
25
  private stepLog;
26
26
  private lastStepTime;
27
- private _tag;
27
+ private _tags;
28
28
  addSuggestion(text: string): void;
29
29
  addPerformanceFail(text: string, screenshot?: ArrayBuffer): void;
30
30
  clear(): void;
@@ -33,6 +33,7 @@ export declare class LogSteps {
33
33
  getStatusCount(status: StatusOfStep): number;
34
34
  get tag(): string;
35
35
  set tag(value: string);
36
+ clearTag(): void;
36
37
  }
37
38
  declare const log: LogSteps;
38
39
  export default log;
@@ -14,12 +14,12 @@ class LogSteps {
14
14
  };
15
15
  this.stepLog = [];
16
16
  this.lastStepTime = new Date().getTime();
17
- this._tag = 'default';
17
+ this._tags = ['default'];
18
18
  }
19
19
  addSuggestion(text) {
20
20
  this.statusCounter[status_of_step_1.StatusOfStep.SUGGESTION]++;
21
21
  this.stepLog.push({
22
- keyword: 'Suggestion', tag: this._tag, name: text, imageCompareKey: '', result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
22
+ keyword: 'Suggestion', tag: this.tag, name: text, imageCompareKey: '', result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
23
23
  });
24
24
  }
25
25
  addPerformanceFail(text, screenshot = new ArrayBuffer(0)) {
@@ -32,7 +32,7 @@ class LogSteps {
32
32
  };
33
33
  this.stepLog.push({
34
34
  keyword: 'PerformanceFail',
35
- tag: this._tag,
35
+ tag: this.tag,
36
36
  name: text,
37
37
  imageCompareKey: '',
38
38
  result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime, embedding: embedding }
@@ -41,7 +41,7 @@ class LogSteps {
41
41
  else {
42
42
  this.stepLog.push({
43
43
  keyword: 'PerformanceFail',
44
- tag: this._tag,
44
+ tag: this.tag,
45
45
  name: text,
46
46
  imageCompareKey: '',
47
47
  result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime }
@@ -95,10 +95,13 @@ class LogSteps {
95
95
  return this.statusCounter[status];
96
96
  }
97
97
  get tag() {
98
- return this._tag;
98
+ return this._tags.length === 1 ? this._tags[0] : this._tags[1];
99
99
  }
100
100
  set tag(value) {
101
- this._tag = value;
101
+ this._tags.push(value);
102
+ }
103
+ clearTag() {
104
+ this._tags.pop();
102
105
  }
103
106
  }
104
107
  exports.LogSteps = LogSteps;
@@ -7,6 +7,7 @@ export declare class FunctionHelper extends ExtendDefaultPage {
7
7
  log(keyword: string, name: string, status: StatusOfStep, screenshot?: ArrayBuffer): void;
8
8
  setTag(tag: string): void;
9
9
  clearTag(): void;
10
+ callREST(method: string, url: string, headers?: object, body?: object): Promise<import("axios").AxiosResponse<any, any>>;
10
11
  screenshot(page?: import("puppeteer").Page): Promise<Buffer | undefined>;
11
12
  screenshotCompare(key: string, threshold?: number, page?: import("puppeteer").Page): Promise<void>;
12
13
  suggest(name: string): void;
@@ -27,6 +28,7 @@ export declare class FunctionHelper extends ExtendDefaultPage {
27
28
  closeLastPage(page?: import("puppeteer").Page): Promise<void>;
28
29
  microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page, newPage?: boolean, staySignIn?: boolean): Promise<void>;
29
30
  private getEscapedText;
31
+ callAPI(url: string, body: {}, token: string): Promise<import("axios").AxiosResponse<any, any>>;
30
32
  }
31
33
  declare const _default: FunctionHelper;
32
34
  export default _default;
@@ -21,17 +21,27 @@ const extend_default_page_1 = require("./extend-default-page");
21
21
  const puppeteer_2 = require("puppeteer");
22
22
  const screenshot_helper_1 = require("../../auxta/utilities/screenshot.helper");
23
23
  const report_service_1 = require("../../auxta/services/report.service");
24
+ const axios_1 = __importDefault(require("axios"));
24
25
  class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
25
26
  log(keyword, name, status, screenshot) {
26
27
  log_service_1.default.push(keyword, log_service_1.default.tag, name, status, screenshot);
27
28
  }
28
29
  setTag(tag) {
29
- if (!log_service_1.default.tag || log_service_1.default.tag === '' || log_service_1.default.tag === 'default') {
30
- log_service_1.default.tag = tag;
31
- }
30
+ log_service_1.default.tag = tag;
32
31
  }
33
32
  clearTag() {
34
- log_service_1.default.tag = '';
33
+ log_service_1.default.clearTag();
34
+ }
35
+ callREST(method, url, headers, body) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const response = yield (0, axios_1.default)({
38
+ method: method,
39
+ url: url,
40
+ headers: headers,
41
+ data: body
42
+ });
43
+ return response;
44
+ });
35
45
  }
36
46
  screenshot(page = puppeteer_1.default.defaultPage) {
37
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -273,6 +283,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
273
283
  const splitedQuotes = text.replace(/'/g, `', "'", '`);
274
284
  return `concat('${splitedQuotes}', '')`;
275
285
  }
286
+ callAPI(url, body, token) {
287
+ return __awaiter(this, void 0, void 0, function* () {
288
+ return yield axios_1.default.post(url, body, {
289
+ headers: {
290
+ 'Content-Type': 'application/json',
291
+ 'Authorization': `Bearer ${token}`
292
+ }
293
+ });
294
+ });
295
+ }
276
296
  }
277
297
  exports.FunctionHelper = FunctionHelper;
278
298
  exports.default = new FunctionHelper();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.110",
3
+ "version": "1.3.113",
4
4
  "description": "",
5
5
  "main": "./build/AuxTA.js",
6
6
  "types": "./build/AuxTA.d.ts",