@auxcode/auxta 1.3.16 → 1.3.17-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/AuxTA.d.ts +57 -0
- package/build/cjs/AuxTA.js +148 -0
- package/build/cjs/auxta/configs/config.d.ts +51 -0
- package/build/cjs/auxta/configs/config.js +63 -0
- package/build/cjs/auxta/enums/status-of.step.d.ts +7 -0
- package/build/cjs/auxta/enums/status-of.step.js +11 -0
- package/build/cjs/auxta/helpers/response.helper.d.ts +10 -0
- package/build/cjs/auxta/helpers/response.helper.js +15 -0
- package/build/cjs/auxta/helpers/start.helper.d.ts +1 -0
- package/build/cjs/auxta/helpers/start.helper.js +26 -0
- package/build/cjs/auxta/hooks/report.hook.d.ts +14 -0
- package/build/cjs/auxta/hooks/report.hook.js +66 -0
- package/build/cjs/auxta/models/upload.model.d.ts +32 -0
- package/build/cjs/auxta/models/upload.model.js +75 -0
- package/build/cjs/auxta/services/log.service.d.ts +26 -0
- package/build/cjs/auxta/services/log.service.js +47 -0
- package/build/cjs/auxta/services/report.service.d.ts +36 -0
- package/build/cjs/auxta/services/report.service.js +164 -0
- package/build/cjs/auxta/services/runtime.service.d.ts +16 -0
- package/build/cjs/auxta/services/runtime.service.js +41 -0
- package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/cjs/auxta/utilities/runtime.helper.js +19 -0
- package/build/cjs/auxta/utilities/screenshot.helper.d.ts +2 -0
- package/build/cjs/auxta/utilities/screenshot.helper.js +36 -0
- package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -0
- package/build/cjs/auxta/utilities/start-suite.helper.js +31 -0
- package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -0
- package/build/cjs/macros/helpers/Aux2faAuth.js +29 -0
- package/build/cjs/macros/helpers/code.helper.d.ts +23 -0
- package/build/cjs/macros/helpers/code.helper.js +166 -0
- package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -0
- package/build/cjs/macros/helpers/extend-default-page.js +88 -0
- package/build/cjs/puppeteer/puppeteer.d.ts +25 -0
- package/build/cjs/puppeteer/puppeteer.js +200 -0
- package/build/esm/AuxTA.d.ts +57 -0
- package/build/esm/AuxTA.js +119 -0
- package/build/esm/auxta/configs/config.d.ts +51 -0
- package/build/esm/auxta/configs/config.js +58 -0
- package/build/esm/auxta/enums/status-of.step.d.ts +7 -0
- package/build/esm/auxta/enums/status-of.step.js +8 -0
- package/build/esm/auxta/helpers/response.helper.d.ts +10 -0
- package/build/esm/auxta/helpers/response.helper.js +11 -0
- package/build/esm/auxta/helpers/start.helper.d.ts +1 -0
- package/build/esm/auxta/helpers/start.helper.js +24 -0
- package/build/esm/auxta/hooks/report.hook.d.ts +14 -0
- package/build/esm/auxta/hooks/report.hook.js +58 -0
- package/build/esm/auxta/models/upload.model.d.ts +32 -0
- package/build/esm/auxta/models/upload.model.js +71 -0
- package/build/esm/auxta/services/log.service.d.ts +26 -0
- package/build/esm/auxta/services/log.service.js +43 -0
- package/build/esm/auxta/services/report.service.d.ts +36 -0
- package/build/esm/auxta/services/report.service.js +150 -0
- package/build/esm/auxta/services/runtime.service.d.ts +16 -0
- package/build/esm/auxta/services/runtime.service.js +37 -0
- package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/esm/auxta/utilities/runtime.helper.js +15 -0
- package/build/esm/auxta/utilities/screenshot.helper.d.ts +2 -0
- package/build/esm/auxta/utilities/screenshot.helper.js +29 -0
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -0
- package/build/esm/auxta/utilities/start-suite.helper.js +26 -0
- package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -0
- package/build/esm/macros/helpers/Aux2faAuth.js +25 -0
- package/build/esm/macros/helpers/code.helper.d.ts +23 -0
- package/build/esm/macros/helpers/code.helper.js +159 -0
- package/build/esm/macros/helpers/extend-default-page.d.ts +6 -0
- package/build/esm/macros/helpers/extend-default-page.js +81 -0
- package/build/esm/puppeteer/puppeteer.d.ts +25 -0
- package/build/esm/puppeteer/puppeteer.js +192 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Step } from "./log.service";
|
|
3
|
+
import { UploadModel } from "../models/upload.model";
|
|
4
|
+
export interface Feature {
|
|
5
|
+
featureId: string;
|
|
6
|
+
featureName: string;
|
|
7
|
+
featureUri: string;
|
|
8
|
+
status: string;
|
|
9
|
+
scenariosCount: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Scenario {
|
|
12
|
+
featureId: string;
|
|
13
|
+
featureName: string;
|
|
14
|
+
featureUri: string;
|
|
15
|
+
status: string;
|
|
16
|
+
scenariosCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Steps {
|
|
19
|
+
failedSteps: number;
|
|
20
|
+
passedSteps: number;
|
|
21
|
+
skippedSteps: number;
|
|
22
|
+
suggestedSteps: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function createEmptyReport(body: any): Promise<string>;
|
|
25
|
+
export declare function uploadScenario(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object): Promise<{
|
|
26
|
+
scenarioRef: any;
|
|
27
|
+
name: any;
|
|
28
|
+
status: any;
|
|
29
|
+
stepsCount: any;
|
|
30
|
+
}[]>;
|
|
31
|
+
export declare function uploadFeature(scenarioId: any[], scenarioName: string, uri: string, hasFailed: boolean): Promise<any>;
|
|
32
|
+
export declare function updateReport(reportId: string, feature: Feature, steps: Steps, isFinal: boolean): Promise<void>;
|
|
33
|
+
export declare function getReport(reportId: string): Promise<any>;
|
|
34
|
+
export declare function getLastDayResults(): Promise<any>;
|
|
35
|
+
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
36
|
+
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.postNotificationsOnFail = exports.postNotifications = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadFeature = exports.uploadScenario = exports.createEmptyReport = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const config_1 = require("../configs/config");
|
|
18
|
+
function headers(token) {
|
|
19
|
+
return {
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'cookie': `authToken=${token}`
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function auth() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.then(({ data }) => {
|
|
34
|
+
return data.token;
|
|
35
|
+
})
|
|
36
|
+
.catch(() => {
|
|
37
|
+
throw new Error("Invalid login credentials");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function createEmptyReport(body) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const token = yield auth();
|
|
44
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "create-empty-report", {
|
|
45
|
+
environment: body.environment,
|
|
46
|
+
digitalProductName: body.digitalProduct,
|
|
47
|
+
start: new Date(),
|
|
48
|
+
url: body.baseUrl
|
|
49
|
+
}, headers(token))).data.reportId;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.createEmptyReport = createEmptyReport;
|
|
53
|
+
function uploadScenario(stepLog, scenarioName, screenshot, errMessage) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
let scenarios = [];
|
|
56
|
+
let token = yield auth();
|
|
57
|
+
let lastStep = stepLog[stepLog.length - 1];
|
|
58
|
+
const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
|
|
59
|
+
stepLogFormat.pop();
|
|
60
|
+
let output = (yield axios_1.default.post(config_1.config.auxtaURL + "create-scenario", {
|
|
61
|
+
json: {
|
|
62
|
+
name: scenarioName,
|
|
63
|
+
steps: [
|
|
64
|
+
...stepLogFormat,
|
|
65
|
+
(lastStep.result.status == 'failed')
|
|
66
|
+
? Object.assign(lastStep, {
|
|
67
|
+
result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
|
|
68
|
+
})
|
|
69
|
+
: lastStep,
|
|
70
|
+
{
|
|
71
|
+
keyword: "After",
|
|
72
|
+
result: {
|
|
73
|
+
status: "passed",
|
|
74
|
+
duration: 2678000000
|
|
75
|
+
},
|
|
76
|
+
embeddings: (screenshot) ? [{
|
|
77
|
+
data: screenshot.toString("base64"),
|
|
78
|
+
mime_type: "image/png"
|
|
79
|
+
}] : undefined,
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
}
|
|
83
|
+
}, headers(token))).data.scenarios;
|
|
84
|
+
scenarios.push({
|
|
85
|
+
scenarioRef: output.scenarioRef,
|
|
86
|
+
name: output.name,
|
|
87
|
+
status: output.status,
|
|
88
|
+
stepsCount: output.stepsCount
|
|
89
|
+
});
|
|
90
|
+
return scenarios;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports.uploadScenario = uploadScenario;
|
|
94
|
+
function uploadFeature(scenarioId, scenarioName, uri, hasFailed) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
let token = yield auth();
|
|
97
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "create-feature", {
|
|
98
|
+
json: {
|
|
99
|
+
name: scenarioName,
|
|
100
|
+
uri: uri
|
|
101
|
+
},
|
|
102
|
+
scenarios: scenarioId,
|
|
103
|
+
hasFailed: hasFailed
|
|
104
|
+
}, headers(token))).data;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.uploadFeature = uploadFeature;
|
|
108
|
+
function updateReport(reportId, feature, steps, isFinal) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
let token = yield auth();
|
|
111
|
+
yield axios_1.default.post(config_1.config.auxtaURL + "update-inprogress-report", {
|
|
112
|
+
reportId: reportId,
|
|
113
|
+
isFinal: isFinal,
|
|
114
|
+
data: Object.assign({ feature: {
|
|
115
|
+
featureRef: feature.featureId,
|
|
116
|
+
name: feature.featureName,
|
|
117
|
+
uri: feature.featureUri,
|
|
118
|
+
status: feature.status,
|
|
119
|
+
scenariosCount: feature.scenariosCount
|
|
120
|
+
} }, steps)
|
|
121
|
+
}, headers(token));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
exports.updateReport = updateReport;
|
|
125
|
+
function getReport(reportId) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
let token = yield auth();
|
|
128
|
+
return (yield axios_1.default.post(config_1.config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.getReport = getReport;
|
|
132
|
+
function getLastDayResults() {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
let token = yield auth();
|
|
135
|
+
return (yield axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
exports.getLastDayResults = getLastDayResults;
|
|
139
|
+
function postNotifications(body) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
let token = yield auth();
|
|
142
|
+
yield axios_1.default.post(`${config_1.config.auxtaURL}post-notification-after-run-background`, {
|
|
143
|
+
environmentName: body.environment,
|
|
144
|
+
digitalProductName: body.digitalProduct,
|
|
145
|
+
organizationName: body.organization,
|
|
146
|
+
reportId: body.reportId,
|
|
147
|
+
}, headers(token));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.postNotifications = postNotifications;
|
|
151
|
+
function postNotificationsOnFail(body) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
let token = yield auth();
|
|
154
|
+
yield axios_1.default.post(`${config_1.config.auxtaURL}post-notifications-after-case-fail-background`, {
|
|
155
|
+
environmentName: body.environment,
|
|
156
|
+
digitalProductName: body.digitalProduct,
|
|
157
|
+
organizationName: body.organization,
|
|
158
|
+
reportId: body.reportId,
|
|
159
|
+
featureName: body.featureName,
|
|
160
|
+
scenarioName: body.scenarioName
|
|
161
|
+
}, headers(token));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
exports.postNotificationsOnFail = postNotificationsOnFail;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RunTime {
|
|
2
|
+
duration: String;
|
|
3
|
+
startTime: Date;
|
|
4
|
+
endTime: Date;
|
|
5
|
+
}
|
|
6
|
+
export declare class Runtime {
|
|
7
|
+
private start;
|
|
8
|
+
private end;
|
|
9
|
+
private runtime;
|
|
10
|
+
constructor(s: Date, e: Date);
|
|
11
|
+
private calculateDuration;
|
|
12
|
+
private splitAtDecimanlMinutes;
|
|
13
|
+
private splitAtDecimanlHours;
|
|
14
|
+
private formatRuntime;
|
|
15
|
+
returnRuntime(): RunTime;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Runtime = void 0;
|
|
4
|
+
class Runtime {
|
|
5
|
+
constructor(s, e) {
|
|
6
|
+
this.start = s;
|
|
7
|
+
this.end = e;
|
|
8
|
+
}
|
|
9
|
+
calculateDuration() {
|
|
10
|
+
let currentTime = new Date;
|
|
11
|
+
let duration = currentTime.getTime() - this.start.getTime();
|
|
12
|
+
return duration;
|
|
13
|
+
}
|
|
14
|
+
splitAtDecimanlMinutes(time) {
|
|
15
|
+
let minutes = time.toFixed(2).toString().split('.');
|
|
16
|
+
return `${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
|
|
17
|
+
}
|
|
18
|
+
splitAtDecimanlHours(time) {
|
|
19
|
+
let hours = time.toFixed(2).toString().split('.');
|
|
20
|
+
let minutes = (Number(hours[1]) / 100 * 60).toFixed(2).toString().split('.');
|
|
21
|
+
return `${hours[0]}h ${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
|
|
22
|
+
}
|
|
23
|
+
formatRuntime(duration) {
|
|
24
|
+
if (duration / 1000 < 60)
|
|
25
|
+
return `${(duration / 1000).toFixed(0)}s`;
|
|
26
|
+
else {
|
|
27
|
+
if (duration / 60000 < 60)
|
|
28
|
+
return this.splitAtDecimanlMinutes(duration / 60000);
|
|
29
|
+
else
|
|
30
|
+
return this.splitAtDecimanlHours(duration / 3600000);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
returnRuntime() {
|
|
34
|
+
let duration = this.formatRuntime(this.calculateDuration());
|
|
35
|
+
let startTime = this.start;
|
|
36
|
+
let endTime = this.end;
|
|
37
|
+
this.runtime = { duration, startTime, endTime };
|
|
38
|
+
return this.runtime;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Runtime = Runtime;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RunTime } from "../services/runtime.service";
|
|
2
|
+
export declare class CalculateRuntime {
|
|
3
|
+
private runtime;
|
|
4
|
+
startTimeSeconds: string;
|
|
5
|
+
startTimeMinutes: string;
|
|
6
|
+
startTimeHours: string;
|
|
7
|
+
startTimeDay: string;
|
|
8
|
+
startTimeMonth: string;
|
|
9
|
+
endTimeSeconds: string;
|
|
10
|
+
endTimeMinutes: string;
|
|
11
|
+
endTimeHours: string;
|
|
12
|
+
endTimeDay: string;
|
|
13
|
+
endTimeMonth: string;
|
|
14
|
+
constructor(r: RunTime);
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalculateRuntime = void 0;
|
|
4
|
+
class CalculateRuntime {
|
|
5
|
+
constructor(r) {
|
|
6
|
+
this.runtime = r;
|
|
7
|
+
this.startTimeSeconds = (this.runtime.startTime.getSeconds() < 10) ? `0${this.runtime.startTime.getSeconds()}` : `${this.runtime.startTime.getSeconds()}`;
|
|
8
|
+
this.startTimeMinutes = (this.runtime.startTime.getMinutes() < 10) ? `0${this.runtime.startTime.getMinutes()}` : `${this.runtime.startTime.getMinutes()}`;
|
|
9
|
+
this.startTimeHours = (this.runtime.startTime.getHours() < 10) ? `0${this.runtime.startTime.getHours()}` : `${this.runtime.startTime.getHours()}`;
|
|
10
|
+
this.startTimeDay = (this.runtime.startTime.getDate() < 10) ? `0${this.runtime.startTime.getDate()}` : `${this.runtime.startTime.getDate()}`;
|
|
11
|
+
this.startTimeMonth = (this.runtime.startTime.getMonth() + 1 < 10) ? `0${this.runtime.startTime.getMonth() + 1}` : `${this.runtime.startTime.getMonth() + 1}`;
|
|
12
|
+
this.endTimeSeconds = (this.runtime.endTime.getSeconds() < 10) ? `0${this.runtime.endTime.getSeconds()}` : `${this.runtime.endTime.getSeconds()}`;
|
|
13
|
+
this.endTimeMinutes = (this.runtime.endTime.getMinutes() < 10) ? `0${this.runtime.endTime.getMinutes()}` : `${this.runtime.endTime.getMinutes()}`;
|
|
14
|
+
this.endTimeHours = (this.runtime.endTime.getHours() < 10) ? `0${this.runtime.endTime.getHours()}` : `${this.runtime.endTime.getHours()}`;
|
|
15
|
+
this.endTimeDay = (this.runtime.endTime.getDate() < 10) ? `0${this.runtime.endTime.getDate()}` : `${this.runtime.endTime.getDate()}`;
|
|
16
|
+
this.endTimeMonth = (this.runtime.endTime.getMonth() + 1 < 10) ? `0${this.runtime.endTime.getMonth() + 1}` : `${this.runtime.endTime.getMonth() + 1}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.CalculateRuntime = CalculateRuntime;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.captureScreenshot = void 0;
|
|
16
|
+
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
17
|
+
function captureScreenshot() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
try {
|
|
20
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
21
|
+
if (!pages.length)
|
|
22
|
+
return undefined;
|
|
23
|
+
const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
|
|
24
|
+
const screenshotBuffer = yield lastPage.screenshot({
|
|
25
|
+
fullPage: true,
|
|
26
|
+
encoding: 'binary'
|
|
27
|
+
});
|
|
28
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
29
|
+
return screenshotBuffer;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.captureScreenshot = captureScreenshot;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function startSuite(suites: string[], reportId?: string): Promise<{
|
|
2
|
+
nextSuites?: undefined;
|
|
3
|
+
reportId?: undefined;
|
|
4
|
+
currentSuite?: undefined;
|
|
5
|
+
retries?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
nextSuites: string[];
|
|
8
|
+
reportId: string | undefined;
|
|
9
|
+
currentSuite: string | undefined;
|
|
10
|
+
retries: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function retrySuite(suites: string[], reportId: string, currentSuite: string, retries: number): Promise<false | {
|
|
13
|
+
nextSuites: string[];
|
|
14
|
+
reportId: string;
|
|
15
|
+
currentSuite: string;
|
|
16
|
+
retries: number;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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.retrySuite = exports.startSuite = void 0;
|
|
13
|
+
function startSuite(suites, reportId) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (suites.length === 0)
|
|
16
|
+
return {};
|
|
17
|
+
const next = suites.shift();
|
|
18
|
+
return { nextSuites: suites, reportId: reportId, currentSuite: next, retries: "0" };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.startSuite = startSuite;
|
|
22
|
+
function retrySuite(suites, reportId, currentSuite, retries) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
console.log('I repeat again the current suite: ' + currentSuite);
|
|
25
|
+
if (retries >= 2) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return { nextSuites: suites, reportId: reportId, currentSuite: currentSuite, retries: retries };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.retrySuite = retrySuite;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Aux2faAuth = void 0;
|
|
4
|
+
const twofactor = require("node-2fa");
|
|
5
|
+
class Aux2faAuth {
|
|
6
|
+
authenticator() {
|
|
7
|
+
const aux2fe_secret = this.getSecret();
|
|
8
|
+
return twofactor.generateToken(aux2fe_secret).token;
|
|
9
|
+
}
|
|
10
|
+
verifyToken(token) {
|
|
11
|
+
const aux2fe_secret = this.getSecret();
|
|
12
|
+
const result = twofactor.verifyToken(aux2fe_secret, token);
|
|
13
|
+
if (result != null) {
|
|
14
|
+
if (result.delta == 0) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
getSecret() {
|
|
21
|
+
const aux2fe_secret = process.env.aux2fe_secret;
|
|
22
|
+
if (!aux2fe_secret) {
|
|
23
|
+
throw new Error('No 2fe secret set');
|
|
24
|
+
}
|
|
25
|
+
return aux2fe_secret;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Aux2faAuth = Aux2faAuth;
|
|
29
|
+
exports.default = new Aux2faAuth();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
+
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { Page } from "puppeteer";
|
|
4
|
+
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
5
|
+
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
6
|
+
suggest(name: string): void;
|
|
7
|
+
private getEscapedText;
|
|
8
|
+
private waitClick;
|
|
9
|
+
clickByText(selector: string, text: string, dotOrText?: string, page?: Page, time?: number, log_message?: boolean): Promise<void>;
|
|
10
|
+
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: Page): Promise<void>;
|
|
11
|
+
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: Page): Promise<void>;
|
|
12
|
+
timeout(timeout?: number, page?: Page): Promise<void>;
|
|
13
|
+
waitForSelector(option: string, selector: string, time?: number, page?: Page, log_message?: boolean): Promise<void>;
|
|
14
|
+
urlContains(selector: string, page?: Page): Promise<void>;
|
|
15
|
+
pressEnter(page?: Page): Promise<void>;
|
|
16
|
+
emulate(phone_name: string, page?: Page): Promise<void>;
|
|
17
|
+
restartBrowser(): Promise<void>;
|
|
18
|
+
clickAndWaitForPageToBeCreated(selector: string, page?: Page): Promise<void>;
|
|
19
|
+
closeLastPage(page?: Page): Promise<void>;
|
|
20
|
+
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: FunctionHelper;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FunctionHelper = void 0;
|
|
16
|
+
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
|
+
const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
|
|
18
|
+
const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
19
|
+
const AuxTA_1 = require("../../AuxTA");
|
|
20
|
+
const extend_default_page_1 = require("./extend-default-page");
|
|
21
|
+
const puppeteer_2 = require("puppeteer");
|
|
22
|
+
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
23
|
+
log(keyword, name, status) {
|
|
24
|
+
log_service_1.default.push(keyword, name, status);
|
|
25
|
+
}
|
|
26
|
+
suggest(name) {
|
|
27
|
+
log_service_1.default.addSuggestion(name);
|
|
28
|
+
}
|
|
29
|
+
getEscapedText(text) {
|
|
30
|
+
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
31
|
+
return `concat('${splitedQuotes}', '')`;
|
|
32
|
+
}
|
|
33
|
+
waitClick(message, xPath, page) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const findElement = yield page.waitForXPath(xPath, { visible: true, timeout: this.defaultTimeout });
|
|
36
|
+
if (findElement) {
|
|
37
|
+
const linkHandlers = yield page.$x(xPath);
|
|
38
|
+
yield linkHandlers.click();
|
|
39
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
log_service_1.default.push('Then', message + ", but it didn't appear in ${time / 1000}", status_of_step_1.StatusOfStep.FAILED);
|
|
43
|
+
throw Error(message + ", but it didn't appear in ${time / 1000}");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
clickByText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const message = `I clicked on the '${text}' '${selector}'`;
|
|
50
|
+
const xPath = `//${selector}[contains(${dotOrText},"${text}")]`;
|
|
51
|
+
yield this.waitClick(message, xPath, page);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
clickByTextWithClass(class_selector, class_name, selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
57
|
+
const xPath = `//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`;
|
|
58
|
+
yield this.waitClick(message, xPath, page);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
waitForSelectorWithText(selector, text, dotOrText = '.', page = puppeteer_1.default.defaultPage) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const message = `I check for '${text}' on the current page`;
|
|
64
|
+
const xPath = `//${selector}[contains(${dotOrText},"${text}")]`;
|
|
65
|
+
yield this.waitClick(message, xPath, page);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
yield page.waitForTimeout(timeout);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const message = `I checked for the '${selector}' element to be ${option}`;
|
|
76
|
+
const findSelector = yield page.waitForSelector(selector, {
|
|
77
|
+
[option]: true,
|
|
78
|
+
timeout: time
|
|
79
|
+
});
|
|
80
|
+
if (findSelector) {
|
|
81
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
log_service_1.default.push('And', `${message}, but it didn't appear in ${time / 1000} seconds.`, status_of_step_1.StatusOfStep.FAILED);
|
|
85
|
+
throw Error(`${message}, but it didn't appear in ${time / 1000} seconds.`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
urlContains(selector, page = puppeteer_1.default.defaultPage) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const url = page.url();
|
|
92
|
+
let message = `I am on the ${selector} page`;
|
|
93
|
+
if (!url.includes(selector)) {
|
|
94
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
95
|
+
throw new Error(message);
|
|
96
|
+
}
|
|
97
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
pressEnter(page = puppeteer_1.default.defaultPage) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
yield page.keyboard.press('Enter');
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
emulate(phone_name, page = puppeteer_1.default.defaultPage) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const phone = puppeteer_2.KnownDevices[phone_name];
|
|
108
|
+
yield page.emulate(phone);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
restartBrowser() {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
yield puppeteer_1.default.close();
|
|
114
|
+
yield puppeteer_1.default.startBrowser();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
120
|
+
yield page.click(selector);
|
|
121
|
+
yield nav;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
closeLastPage(page = puppeteer_1.default.defaultPage) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const pages = yield page.browser().pages();
|
|
127
|
+
yield pages[pages.length - 1].close();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
microsoftLogin(button, email, password) {
|
|
131
|
+
var _a;
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const email_input = 'input[type="email"]';
|
|
134
|
+
const password_input = 'input[type="password"]';
|
|
135
|
+
const next_button = 'input[value="Next"]';
|
|
136
|
+
const sign_in_button = 'input[value="Sign in"]';
|
|
137
|
+
const no_button = 'input.ext-secondary';
|
|
138
|
+
yield this.clickAndWaitForPageToBeCreated(button);
|
|
139
|
+
const pages = yield puppeteer_1.default.defaultPage.browser().pages();
|
|
140
|
+
const loginPage = pages[pages.length - 1];
|
|
141
|
+
yield this.extend_page_functions(loginPage);
|
|
142
|
+
yield loginPage.waitForNetworkIdle();
|
|
143
|
+
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
144
|
+
yield loginPage.type(email_input, email);
|
|
145
|
+
yield loginPage.keyboard.press('Enter');
|
|
146
|
+
yield loginPage.waitForNetworkIdle();
|
|
147
|
+
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
148
|
+
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
149
|
+
try {
|
|
150
|
+
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
151
|
+
yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
|
|
155
|
+
throw new Error(`I type password into the ${password_input}`);
|
|
156
|
+
}
|
|
157
|
+
yield this.timeout(3000);
|
|
158
|
+
yield loginPage.keyboard.press('Enter');
|
|
159
|
+
yield this.waitForSelector('visible', no_button, 60000, loginPage);
|
|
160
|
+
yield loginPage.keyboard.press('Enter');
|
|
161
|
+
yield loginPage.waitForNetworkIdle();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.FunctionHelper = FunctionHelper;
|
|
166
|
+
exports.default = new FunctionHelper();
|