@auxcode/auxta 1.3.120 → 1.3.122
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/build/AuxTA.d.ts +2 -0
- package/build/AuxTA.js +0 -2
- package/build/auxta/hooks/report.hook.js +1 -22
- package/build/auxta/models/upload.model.d.ts +1 -4
- package/build/auxta/models/upload.model.js +1 -8
- package/build/auxta/services/log.service.d.ts +3 -3
- package/build/auxta/services/log.service.js +4 -4
- package/build/auxta/services/report.service.d.ts +2 -2
- package/build/auxta/services/report.service.js +2 -2
- package/build/auxta/utilities/screenshot.helper.d.ts +2 -2
- package/build/auxta/utilities/screenshot.helper.js +0 -10
- package/build/macros/helpers/code.helper.d.ts +18 -18
- package/build/macros/helpers/code.helper.js +2 -2
- package/build/puppeteer/puppeteer.d.ts +2 -3
- package/build/puppeteer/puppeteer.js +25 -89
- package/package.json +4 -4
- package/build/auxta/helpers/console-debug.helper.d.ts +0 -14
- package/build/auxta/helpers/console-debug.helper.js +0 -58
package/build/AuxTA.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ declare class AuxTA extends FunctionHelper {
|
|
|
50
50
|
reportId: string | undefined;
|
|
51
51
|
currentSuite: string | undefined;
|
|
52
52
|
retries: string;
|
|
53
|
+
} | {
|
|
54
|
+
statusCode: number;
|
|
53
55
|
} | undefined>;
|
|
54
56
|
startBrowserRPA(event: any, callback: any, baseURL: string, fileName?: string): Promise<any>;
|
|
55
57
|
getUploadModel(): UploadModel;
|
package/build/AuxTA.js
CHANGED
|
@@ -157,8 +157,6 @@ class AuxTA extends code_helper_1.FunctionHelper {
|
|
|
157
157
|
this.uploadModel.bucket = overrideConfig.bucket;
|
|
158
158
|
if (overrideConfig.isOfficial !== undefined)
|
|
159
159
|
this.uploadModel.isOfficial = overrideConfig.isOfficial;
|
|
160
|
-
if (overrideConfig.toRetry !== undefined)
|
|
161
|
-
this.uploadModel.toRetry = overrideConfig.toRetry;
|
|
162
160
|
this.config = (0, config_1.setupOverrideConfig)(overrideConfig);
|
|
163
161
|
}
|
|
164
162
|
}
|
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
13
|
};
|
|
@@ -32,22 +21,12 @@ const start_suite_helper_1 = require("../utilities/start-suite.helper");
|
|
|
32
21
|
const status_of_step_1 = require("../enums/status-of.step");
|
|
33
22
|
function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
|
|
34
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
var _a, _b;
|
|
36
24
|
let isFinal = false;
|
|
37
25
|
if (process.env.ENVIRONMENT == "LIVE") {
|
|
38
26
|
console.log('--- Uploading scenario and feature for AUXTA report ---');
|
|
39
27
|
const stepsArr = log_service_1.default.returnScenarioReport();
|
|
40
28
|
try {
|
|
41
|
-
const
|
|
42
|
-
let errorPayload = restErrors;
|
|
43
|
-
const failed = statusCode !== 200;
|
|
44
|
-
const hasScreenshot = !!(screenshotBuffer &&
|
|
45
|
-
((typeof Buffer !== 'undefined' && ((_b = (_a = Buffer).isBuffer) === null || _b === void 0 ? void 0 : _b.call(_a, screenshotBuffer)) && screenshotBuffer.length > 0) ||
|
|
46
|
-
(typeof screenshotBuffer.byteLength === 'number' && screenshotBuffer.byteLength > 0)));
|
|
47
|
-
if (failed && hasScreenshot && Array.isArray(debugCandidate) && debugCandidate.length) {
|
|
48
|
-
errorPayload = Object.assign(Object.assign({}, restErrors), { debug: debugCandidate });
|
|
49
|
-
}
|
|
50
|
-
const stepRes = yield (0, report_service_1.uploadStep)(stepsArr, scenarioName, screenshotBuffer, errorPayload);
|
|
29
|
+
const stepRes = yield (0, report_service_1.uploadStep)(stepsArr, scenarioName, screenshotBuffer, errMessage);
|
|
51
30
|
const scenarioRes = yield (0, report_service_1.uploadScenario)(stepRes, featureName, (0, path_1.basename)(__filename), (statusCode != 200));
|
|
52
31
|
const scenario = {
|
|
53
32
|
scenarioId: scenarioRes.scenarioRef,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class UploadModel {
|
|
2
2
|
private readonly _organization;
|
|
3
|
-
constructor(org: string, baseUrl: string, digitalProduct: string, environment: string, bucket: string, isOfficial: boolean
|
|
3
|
+
constructor(org: string, baseUrl: string, digitalProduct: string, environment: string, bucket: string, isOfficial: boolean);
|
|
4
4
|
private _reportId;
|
|
5
5
|
get reportId(): string;
|
|
6
6
|
set reportId(value: string);
|
|
@@ -34,8 +34,5 @@ export declare class UploadModel {
|
|
|
34
34
|
private _isOfficial;
|
|
35
35
|
get isOfficial(): boolean;
|
|
36
36
|
set isOfficial(value: boolean);
|
|
37
|
-
private _toRetry;
|
|
38
|
-
get toRetry(): boolean;
|
|
39
|
-
set toRetry(value: boolean);
|
|
40
37
|
get organization(): string;
|
|
41
38
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UploadModel = void 0;
|
|
4
4
|
class UploadModel {
|
|
5
|
-
constructor(org, baseUrl, digitalProduct, environment, bucket, isOfficial
|
|
5
|
+
constructor(org, baseUrl, digitalProduct, environment, bucket, isOfficial) {
|
|
6
6
|
this._reportId = '';
|
|
7
7
|
this._nextSuites = [];
|
|
8
8
|
this._currentSuite = '';
|
|
@@ -15,7 +15,6 @@ class UploadModel {
|
|
|
15
15
|
this._featureName = '';
|
|
16
16
|
this._scenarioName = '';
|
|
17
17
|
this._isOfficial = isOfficial;
|
|
18
|
-
this._toRetry = toRetry;
|
|
19
18
|
}
|
|
20
19
|
get reportId() {
|
|
21
20
|
return this._reportId;
|
|
@@ -83,12 +82,6 @@ class UploadModel {
|
|
|
83
82
|
set isOfficial(value) {
|
|
84
83
|
this._isOfficial = value;
|
|
85
84
|
}
|
|
86
|
-
get toRetry() {
|
|
87
|
-
return this._toRetry;
|
|
88
|
-
}
|
|
89
|
-
set toRetry(value) {
|
|
90
|
-
this._toRetry = value;
|
|
91
|
-
}
|
|
92
85
|
get organization() {
|
|
93
86
|
return this._organization;
|
|
94
87
|
}
|
|
@@ -8,7 +8,7 @@ export interface Step {
|
|
|
8
8
|
status: StatusOfStep;
|
|
9
9
|
duration: number;
|
|
10
10
|
embedding?: {
|
|
11
|
-
data: Buffer;
|
|
11
|
+
data: Uint8Array | Buffer;
|
|
12
12
|
mime_type: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -26,9 +26,9 @@ export declare class LogSteps {
|
|
|
26
26
|
private lastStepTime;
|
|
27
27
|
private _tags;
|
|
28
28
|
addSuggestion(text: string): void;
|
|
29
|
-
addPerformanceFail(text: string, screenshot?: Buffer): void;
|
|
29
|
+
addPerformanceFail(text: string, screenshot?: Uint8Array | Buffer): void;
|
|
30
30
|
clear(): void;
|
|
31
|
-
push(keyword: string, tag: string, name: string, status: StatusOfStep, screenshot?: Buffer, imageCompareKey?: string): void;
|
|
31
|
+
push(keyword: string, tag: string, name: string, status: StatusOfStep, screenshot?: Uint8Array | Buffer, imageCompareKey?: string): void;
|
|
32
32
|
returnScenarioReport(): Step[];
|
|
33
33
|
getStatusCount(status: StatusOfStep): number;
|
|
34
34
|
get tag(): string;
|
|
@@ -22,7 +22,7 @@ class LogSteps {
|
|
|
22
22
|
keyword: 'Suggestion', tag: this.tag, name: text, imageCompareKey: '', result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
addPerformanceFail(text, screenshot =
|
|
25
|
+
addPerformanceFail(text, screenshot = new Uint8Array()) {
|
|
26
26
|
this.statusCounter[status_of_step_1.StatusOfStep.PERFORMANCE_FAIL]++;
|
|
27
27
|
const currentStep = new Date().getTime();
|
|
28
28
|
if (screenshot.byteLength != 0) {
|
|
@@ -35,7 +35,7 @@ class LogSteps {
|
|
|
35
35
|
tag: this.tag,
|
|
36
36
|
name: text,
|
|
37
37
|
imageCompareKey: '',
|
|
38
|
-
result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime, embedding
|
|
38
|
+
result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime, embedding }
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
@@ -60,7 +60,7 @@ class LogSteps {
|
|
|
60
60
|
[status_of_step_1.StatusOfStep.LOG]: 0
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
push(keyword, tag, name, status, screenshot =
|
|
63
|
+
push(keyword, tag, name, status, screenshot = new Uint8Array(), imageCompareKey = '') {
|
|
64
64
|
console.log(`System log -- status: ${status} -- tag: ${tag} -- : ${name} `);
|
|
65
65
|
this.statusCounter[status]++;
|
|
66
66
|
const currentStep = new Date().getTime();
|
|
@@ -74,7 +74,7 @@ class LogSteps {
|
|
|
74
74
|
tag,
|
|
75
75
|
name,
|
|
76
76
|
imageCompareKey,
|
|
77
|
-
result: { status, duration: currentStep - this.lastStepTime, embedding
|
|
77
|
+
result: { status, duration: currentStep - this.lastStepTime, embedding }
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
@@ -29,7 +29,7 @@ export declare function uploadScenario(stepRes: any[], scenarioName: string, uri
|
|
|
29
29
|
export declare function updateReport(reportId: string, scenario: Scenarios, steps: Steps, isFinal: boolean): Promise<void>;
|
|
30
30
|
export declare function getReport(reportId: string): Promise<any>;
|
|
31
31
|
export declare function getLastDayResults(): Promise<any>;
|
|
32
|
-
export declare function compareScreenshots(key: string, screenshot
|
|
32
|
+
export declare function compareScreenshots(key: string, screenshot?: Uint8Array | Buffer): Promise<any>;
|
|
33
33
|
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
34
34
|
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|
|
35
|
-
export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
35
|
+
export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
@@ -179,8 +179,8 @@ function getLastDayResults() {
|
|
|
179
179
|
return (yield axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
-
function compareScreenshots(
|
|
183
|
-
return __awaiter(this,
|
|
182
|
+
function compareScreenshots(key_1) {
|
|
183
|
+
return __awaiter(this, arguments, void 0, function* (key, screenshot = new Uint8Array()) {
|
|
184
184
|
let token = yield auth();
|
|
185
185
|
const embedding = {
|
|
186
186
|
data: screenshot,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Page } from "puppeteer";
|
|
2
|
-
export declare function captureScreenshot(): Promise<Buffer | undefined>;
|
|
3
|
-
export declare function captureScreenshotPage(page: Page): Promise<Buffer | undefined>;
|
|
2
|
+
export declare function captureScreenshot(): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
|
|
3
|
+
export declare function captureScreenshotPage(page: Page): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
|
|
@@ -20,7 +20,6 @@ const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
|
|
|
20
20
|
const RETRY_NUMBERS = 10;
|
|
21
21
|
function captureScreenshot() {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshot started`, status_of_step_1.default.PASSED);
|
|
24
23
|
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
25
24
|
if (!pages.length)
|
|
26
25
|
return undefined;
|
|
@@ -31,12 +30,10 @@ function captureScreenshot() {
|
|
|
31
30
|
while (count <= RETRY_NUMBERS) {
|
|
32
31
|
try {
|
|
33
32
|
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
34
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Just before retry ${count}. Pages: ${pages.length}. Is last page closed?: ${lastPage.isClosed()}`, status_of_step_1.default.PASSED);
|
|
35
33
|
const screenshotBuffer = yield lastPage.screenshot({
|
|
36
34
|
captureBeyondViewport: false,
|
|
37
35
|
encoding: 'binary'
|
|
38
36
|
});
|
|
39
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Successfull try ${count}`, status_of_step_1.default.PASSED);
|
|
40
37
|
if (Buffer.isBuffer(screenshotBuffer))
|
|
41
38
|
return screenshotBuffer;
|
|
42
39
|
}
|
|
@@ -51,7 +48,6 @@ function captureScreenshot() {
|
|
|
51
48
|
}
|
|
52
49
|
else {
|
|
53
50
|
let count = 0;
|
|
54
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Failed try ${count}`, status_of_step_1.default.FAILED);
|
|
55
51
|
while (count <= RETRY_NUMBERS) {
|
|
56
52
|
try {
|
|
57
53
|
const screenshotBuffer = yield page.screenshot({
|
|
@@ -73,17 +69,14 @@ function captureScreenshot() {
|
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
|
-
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshot ended`, status_of_step_1.default.PASSED);
|
|
77
72
|
return undefined;
|
|
78
73
|
});
|
|
79
74
|
}
|
|
80
75
|
function captureScreenshotPage(page) {
|
|
81
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshotPage started`, status_of_step_1.default.PASSED);
|
|
83
77
|
let count = 0;
|
|
84
78
|
while (count <= RETRY_NUMBERS) {
|
|
85
79
|
try {
|
|
86
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Just before retry ${count}`, status_of_step_1.default.PASSED);
|
|
87
80
|
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
88
81
|
log_service_1.default.push('When', log_service_1.default.tag, `Before the screenshot the number of pages are ${pages.length}`, status_of_step_1.default.PASSED);
|
|
89
82
|
const screenshotBuffer = yield page.screenshot({
|
|
@@ -91,12 +84,10 @@ function captureScreenshotPage(page) {
|
|
|
91
84
|
captureBeyondViewport: false,
|
|
92
85
|
encoding: 'binary'
|
|
93
86
|
});
|
|
94
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Successfull try ${count}`, status_of_step_1.default.PASSED);
|
|
95
87
|
if (Buffer.isBuffer(screenshotBuffer))
|
|
96
88
|
return screenshotBuffer;
|
|
97
89
|
}
|
|
98
90
|
catch (e) {
|
|
99
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Failed try ${count}`, status_of_step_1.default.FAILED);
|
|
100
91
|
if (count == RETRY_NUMBERS) {
|
|
101
92
|
log_service_1.default.push('When', log_service_1.default.tag, e.toString(), status_of_step_1.default.FAILED);
|
|
102
93
|
return undefined;
|
|
@@ -104,7 +95,6 @@ function captureScreenshotPage(page) {
|
|
|
104
95
|
}
|
|
105
96
|
count++;
|
|
106
97
|
}
|
|
107
|
-
log_service_1.default.push('When', log_service_1.default.tag, `captureScreenshotPage ended`, status_of_step_1.default.PASSED);
|
|
108
98
|
return undefined;
|
|
109
99
|
});
|
|
110
100
|
}
|
|
@@ -3,31 +3,31 @@ import { ExtendDefaultPage } from "./extend-default-page";
|
|
|
3
3
|
import { CDPSession } from "puppeteer";
|
|
4
4
|
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
5
5
|
cdp: CDPSession | undefined;
|
|
6
|
-
log(keyword: string, name: string, status: StatusOfStep, screenshot?: Buffer): void;
|
|
6
|
+
log(keyword: string, name: string, status: StatusOfStep, screenshot?: Uint8Array | Buffer): void;
|
|
7
7
|
setTag(tag: string): void;
|
|
8
8
|
clearTag(): void;
|
|
9
|
-
callREST(method: string, url: string, headers?: object, body?: object): Promise<import("axios").AxiosResponse<any, any>>;
|
|
10
|
-
screenshot(page?: import("puppeteer").Page): Promise<Buffer | undefined>;
|
|
11
|
-
screenshotCompare(key: string, threshold?: number, page?: import("puppeteer").Page): Promise<void>;
|
|
9
|
+
callREST(method: string, url: string, headers?: object, body?: object): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
10
|
+
screenshot(page?: import("puppeteer-core").Page): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
|
|
11
|
+
screenshotCompare(key: string, threshold?: number, page?: import("puppeteer-core").Page): Promise<void>;
|
|
12
12
|
suggest(name: string): void;
|
|
13
|
-
performanceFail(name: string, screenshot?: boolean, page?: import("puppeteer").Page): Promise<void>;
|
|
14
|
-
clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer").Page, time?: number, log_message?: boolean): Promise<void>;
|
|
15
|
-
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<void>;
|
|
16
|
-
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<boolean>;
|
|
13
|
+
performanceFail(name: string, screenshot?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
|
|
14
|
+
clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer-core").Page, time?: number, log_message?: boolean): Promise<void>;
|
|
15
|
+
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
16
|
+
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer-core").Page): Promise<boolean>;
|
|
17
17
|
timeout(timeout?: number): Promise<void>;
|
|
18
|
-
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer").Page, log_message?: boolean): Promise<void>;
|
|
19
|
-
urlContains(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
20
|
-
forceState(selector: string, state: string, index?: number, page?: import("puppeteer").Page): Promise<void>;
|
|
18
|
+
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer-core").Page, log_message?: boolean): Promise<void>;
|
|
19
|
+
urlContains(selector: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
20
|
+
forceState(selector: string, state: string, index?: number, page?: import("puppeteer-core").Page): Promise<void>;
|
|
21
21
|
endForceState(): Promise<void>;
|
|
22
|
-
pressEnter(page?: import("puppeteer").Page): Promise<void>;
|
|
23
|
-
emulate(phone_name: string, page?: import("puppeteer").Page): Promise<void>;
|
|
22
|
+
pressEnter(page?: import("puppeteer-core").Page): Promise<void>;
|
|
23
|
+
emulate(phone_name: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
24
24
|
restartBrowser(): Promise<void>;
|
|
25
|
-
clickAndWaitForPageToBeCreated(selector: string, page: import("puppeteer").Page | undefined, newPage: boolean): Promise<void>;
|
|
26
|
-
waitForResponse(name: string, wait?: boolean, page?: import("puppeteer").Page): Promise<void>;
|
|
27
|
-
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
28
|
-
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page, newPage?: boolean, staySignIn?: boolean): Promise<void>;
|
|
25
|
+
clickAndWaitForPageToBeCreated(selector: string, page: import("puppeteer-core").Page | undefined, newPage: boolean): Promise<void>;
|
|
26
|
+
waitForResponse(name: string, wait?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
|
|
27
|
+
closeLastPage(page?: import("puppeteer-core").Page): Promise<void>;
|
|
28
|
+
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer-core").Page, newPage?: boolean, staySignIn?: boolean): Promise<void>;
|
|
29
29
|
private getEscapedText;
|
|
30
|
-
callAPI(url: string, body: {}, token: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
30
|
+
callAPI(url: string, body: {}, token: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
31
31
|
}
|
|
32
32
|
declare const _default: FunctionHelper;
|
|
33
33
|
export default _default;
|
|
@@ -23,7 +23,7 @@ const screenshot_helper_1 = require("../../auxta/utilities/screenshot.helper");
|
|
|
23
23
|
const report_service_1 = require("../../auxta/services/report.service");
|
|
24
24
|
const axios_1 = __importDefault(require("axios"));
|
|
25
25
|
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
26
|
-
log(keyword, name, status, screenshot) {
|
|
26
|
+
log(keyword, name, status, screenshot = new Uint8Array()) {
|
|
27
27
|
log_service_1.default.push(keyword, log_service_1.default.tag, name, status, screenshot);
|
|
28
28
|
}
|
|
29
29
|
setTag(tag) {
|
|
@@ -172,7 +172,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
172
172
|
const url = page.url();
|
|
173
173
|
let message = `I am on the ${selector} page`;
|
|
174
174
|
if (!url.includes(selector)) {
|
|
175
|
-
log_service_1.default.push('And', log_service_1.default.tag,
|
|
175
|
+
log_service_1.default.push('And', log_service_1.default.tag, message, status_of_step_1.StatusOfStep.FAILED);
|
|
176
176
|
throw new Error(message);
|
|
177
177
|
}
|
|
178
178
|
log_service_1.default.push('And', log_service_1.default.tag, message, status_of_step_1.StatusOfStep.PASSED);
|
|
@@ -3,12 +3,9 @@ import puppeteer = require("puppeteer");
|
|
|
3
3
|
export declare class Puppeteer {
|
|
4
4
|
defaultPage: puppeteer.Page;
|
|
5
5
|
private browser;
|
|
6
|
-
private userConsoleMessages;
|
|
7
6
|
private static setupHeader;
|
|
8
7
|
startBrowser(): Promise<void>;
|
|
9
8
|
close(): Promise<void>;
|
|
10
|
-
private initiateBrowser;
|
|
11
|
-
private logFail;
|
|
12
9
|
run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel): Promise<{
|
|
13
10
|
nextSuites?: undefined;
|
|
14
11
|
reportId?: undefined;
|
|
@@ -19,6 +16,8 @@ export declare class Puppeteer {
|
|
|
19
16
|
reportId: string | undefined;
|
|
20
17
|
currentSuite: string | undefined;
|
|
21
18
|
retries: string;
|
|
19
|
+
} | {
|
|
20
|
+
statusCode: number;
|
|
22
21
|
} | undefined>;
|
|
23
22
|
runRPA(event: any, callback: any, uploadModel?: UploadModel, close?: boolean): Promise<any>;
|
|
24
23
|
}
|
|
@@ -21,11 +21,7 @@ const status_of_step_1 = require("../auxta/enums/status-of.step");
|
|
|
21
21
|
const config_1 = require("../auxta/configs/config");
|
|
22
22
|
const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
|
|
23
23
|
const puppeteer = require("puppeteer");
|
|
24
|
-
const console_debug_helper_1 = require("../auxta/helpers/console-debug.helper");
|
|
25
24
|
class Puppeteer {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.userConsoleMessages = [];
|
|
28
|
-
}
|
|
29
25
|
static setupHeader(event, uploadModel) {
|
|
30
26
|
let close = true;
|
|
31
27
|
if (process.env.ENVIRONMENT !== 'LOCAL' && event) {
|
|
@@ -83,62 +79,6 @@ class Puppeteer {
|
|
|
83
79
|
}
|
|
84
80
|
});
|
|
85
81
|
}
|
|
86
|
-
initiateBrowser(consoleMessage, httpsMessage) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
yield this.startBrowser();
|
|
89
|
-
this.browser.on('targetcreated', (target) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
try {
|
|
91
|
-
if (target.type() !== 'page')
|
|
92
|
-
return;
|
|
93
|
-
const page = yield target.page();
|
|
94
|
-
if (!page)
|
|
95
|
-
return;
|
|
96
|
-
(0, console_debug_helper_1.attachUserConsoleCapture)(page, (entry) => {
|
|
97
|
-
this.userConsoleMessages.push(entry);
|
|
98
|
-
if (this.userConsoleMessages.length > 300)
|
|
99
|
-
this.userConsoleMessages.shift();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
catch (_a) { }
|
|
103
|
-
}));
|
|
104
|
-
this.defaultPage.on('console', (msg) => {
|
|
105
|
-
var _a;
|
|
106
|
-
const t = typeof msg.type === 'function' ? msg.type() : (msg.type || '');
|
|
107
|
-
if (t !== 'error')
|
|
108
|
-
return;
|
|
109
|
-
let loc = '';
|
|
110
|
-
try {
|
|
111
|
-
const l = typeof msg.location === 'function' ? msg.location() : undefined;
|
|
112
|
-
if (l) {
|
|
113
|
-
const at = `${l.url || ''}` +
|
|
114
|
-
`${l.lineNumber != null ? ':' + l.lineNumber : ''}` +
|
|
115
|
-
`${l.columnNumber != null ? ':' + l.columnNumber : ''}`;
|
|
116
|
-
loc = at ? ` @ ${at}` : '';
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (_b) { }
|
|
120
|
-
const text = typeof msg.text === 'function' ? msg.text() : String((_a = msg.text) !== null && _a !== void 0 ? _a : '');
|
|
121
|
-
if (text === 'pages' || /^\d+$/.test(text))
|
|
122
|
-
return;
|
|
123
|
-
consoleMessage.push(`${String(t).toUpperCase()} ${text}${loc}`);
|
|
124
|
-
})
|
|
125
|
-
.on('pageerror', ({ message }) => consoleMessage.push(message))
|
|
126
|
-
.on('response', (response) => httpsMessage.push(`${response.status()} ${response.url()}`))
|
|
127
|
-
.on('requestfailed', (request) => { var _a; return httpsMessage.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
128
|
-
(0, console_debug_helper_1.attachUserConsoleCapture)(this.defaultPage, (entry) => {
|
|
129
|
-
this.userConsoleMessages.push(entry);
|
|
130
|
-
if (this.userConsoleMessages.length > 300)
|
|
131
|
-
this.userConsoleMessages.shift();
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
logFail(consoleMessage) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const pages = yield this.defaultPage.browser().pages();
|
|
138
|
-
consoleMessage.push('pages');
|
|
139
|
-
consoleMessage.push(pages.length);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
82
|
run(event_1, callback_1) {
|
|
143
83
|
return __awaiter(this, arguments, void 0, function* (event, callback, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel) {
|
|
144
84
|
let close;
|
|
@@ -155,59 +95,55 @@ class Puppeteer {
|
|
|
155
95
|
let statusCode = 200;
|
|
156
96
|
let consoleMessage = [];
|
|
157
97
|
let httpsMessage = [];
|
|
158
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
159
98
|
try {
|
|
160
|
-
|
|
99
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
100
|
+
yield this.startBrowser();
|
|
101
|
+
this.defaultPage.on('console', (message) => consoleMessage.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
102
|
+
.on('pageerror', ({ message }) => consoleMessage.push(message))
|
|
103
|
+
.on('response', (response) => httpsMessage.push(`${response.status()} ${response.url()}`))
|
|
104
|
+
.on('requestfailed', (request) => { var _a; return httpsMessage.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
161
105
|
yield callback(event);
|
|
162
106
|
log_service_1.default.push('When', log_service_1.default.tag, `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
163
107
|
}
|
|
164
108
|
catch (err) {
|
|
165
109
|
console.log("Error message: \n", err);
|
|
166
110
|
if (process.env.ENVIRONMENT !== 'LOCAL') {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
yield
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
statusCode = 500;
|
|
181
|
-
screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshot)();
|
|
182
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Failed puppeteer process from the 2nd try`, status_of_step_1.StatusOfStep.FAILED);
|
|
111
|
+
let browser_start_retry = err.toString().includes("Failed to launch the browser process!");
|
|
112
|
+
const pages = yield this.defaultPage.browser().pages();
|
|
113
|
+
consoleMessage.push('pages');
|
|
114
|
+
consoleMessage.push(pages.length);
|
|
115
|
+
if (browser_start_retry) {
|
|
116
|
+
const result = yield (0, start_suite_helper_1.retrySuite)(uploadModel.nextSuites, uploadModel.reportId, uploadModel.currentSuite, uploadModel.retries);
|
|
117
|
+
if (!result) {
|
|
118
|
+
return yield (0, report_hook_1.onTestEnd)(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
119
|
+
currentPageUrl: 'undefined',
|
|
120
|
+
console: consoleMessage,
|
|
121
|
+
https: httpsMessage,
|
|
122
|
+
error: 'Browser did not open'
|
|
123
|
+
});
|
|
183
124
|
}
|
|
125
|
+
return { statusCode: 204 };
|
|
184
126
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshot)();
|
|
190
|
-
log_service_1.default.push('When', log_service_1.default.tag, `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
191
|
-
}
|
|
127
|
+
errMessage = err;
|
|
128
|
+
statusCode = 500;
|
|
129
|
+
screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshot)();
|
|
130
|
+
log_service_1.default.push('When', log_service_1.default.tag, `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
192
131
|
}
|
|
193
132
|
}
|
|
194
133
|
let url = this.defaultPage.url();
|
|
195
134
|
if (close)
|
|
196
135
|
yield this.close();
|
|
197
|
-
const debugCandidate = this.userConsoleMessages.slice(-150);
|
|
198
136
|
return yield (0, report_hook_1.onTestEnd)(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
199
137
|
currentPageUrl: url,
|
|
200
138
|
console: consoleMessage,
|
|
201
139
|
https: httpsMessage,
|
|
202
|
-
error: errMessage
|
|
203
|
-
debugCandidate
|
|
140
|
+
error: errMessage
|
|
204
141
|
});
|
|
205
142
|
}
|
|
206
143
|
catch (e) {
|
|
207
144
|
console.log("Lib error:", e);
|
|
208
145
|
}
|
|
209
146
|
finally {
|
|
210
|
-
this.userConsoleMessages = [];
|
|
211
147
|
log_service_1.default.clear();
|
|
212
148
|
}
|
|
213
149
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auxcode/auxta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.122",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/AuxTA.js",
|
|
6
6
|
"types": "./build/AuxTA.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@types/node": "^17.0.9",
|
|
19
|
-
"axios": "1.
|
|
19
|
+
"axios": "1.12.2",
|
|
20
20
|
"dotenv": "^10.0.0",
|
|
21
21
|
"dotenv-extended": "^2.9.0",
|
|
22
22
|
"fs": "^0.0.1-security",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"moment-timezone": "^0.5.45",
|
|
26
26
|
"node-2fa": "^2.0.3",
|
|
27
27
|
"nodemailer": "^6.9.9",
|
|
28
|
-
"puppeteer": "
|
|
28
|
+
"puppeteer": "24.21.0",
|
|
29
29
|
"readline": "^1.3.0",
|
|
30
|
-
"typescript": "
|
|
30
|
+
"typescript": "5.9.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/preset-typescript": "^7.23.3"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import puppeteer = require("puppeteer");
|
|
2
|
-
export type UserConsoleEntry = {
|
|
3
|
-
level: puppeteer.ConsoleMessageType;
|
|
4
|
-
text: string;
|
|
5
|
-
args: string[];
|
|
6
|
-
location?: {
|
|
7
|
-
url?: string;
|
|
8
|
-
lineNumber?: number;
|
|
9
|
-
columnNumber?: number;
|
|
10
|
-
};
|
|
11
|
-
pageUrl: string;
|
|
12
|
-
ts: number;
|
|
13
|
-
};
|
|
14
|
-
export declare function attachUserConsoleCapture(page: puppeteer.Page, push: (e: UserConsoleEntry) => void): void;
|
|
@@ -1,58 +0,0 @@
|
|
|
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.attachUserConsoleCapture = attachUserConsoleCapture;
|
|
13
|
-
function safeStringify(v) {
|
|
14
|
-
if (typeof v === "string")
|
|
15
|
-
return v;
|
|
16
|
-
try {
|
|
17
|
-
return JSON.stringify(v);
|
|
18
|
-
}
|
|
19
|
-
catch (_a) {
|
|
20
|
-
return String(v);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function attachUserConsoleCapture(page, push) {
|
|
24
|
-
page.on("console", (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const level = msg.type();
|
|
26
|
-
if (!["debug", "log", "info", "warning", "error"].includes(level))
|
|
27
|
-
return;
|
|
28
|
-
const loc = typeof msg.location === "function" ? msg.location() : undefined;
|
|
29
|
-
const args = [];
|
|
30
|
-
try {
|
|
31
|
-
const handles = msg.args();
|
|
32
|
-
for (let i = 0; i < Math.min(handles.length, 5); i++) {
|
|
33
|
-
try {
|
|
34
|
-
const val = yield handles[i].jsonValue();
|
|
35
|
-
args.push(safeStringify(val));
|
|
36
|
-
}
|
|
37
|
-
catch (_a) {
|
|
38
|
-
try {
|
|
39
|
-
const s = yield handles[i].evaluate((x) => Object.prototype.toString.call(x));
|
|
40
|
-
args.push(String(s));
|
|
41
|
-
}
|
|
42
|
-
catch (_b) {
|
|
43
|
-
args.push(String(handles[i]));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (_c) { }
|
|
49
|
-
push({
|
|
50
|
-
level: level,
|
|
51
|
-
text: msg.text(),
|
|
52
|
-
args,
|
|
53
|
-
location: loc,
|
|
54
|
-
pageUrl: page.url(),
|
|
55
|
-
ts: Date.now(),
|
|
56
|
-
});
|
|
57
|
-
}));
|
|
58
|
-
}
|