@auxcode/auxta 0.5.5 → 0.5.9
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.js +38 -23
- package/build/auxta/helpers/start.helper.js +12 -3
- package/build/auxta/hooks/report.hook.js +50 -37
- package/build/auxta/services/report.service.js +126 -105
- package/build/auxta/utilities/screenshot.helper.js +27 -16
- package/build/auxta/utilities/start-suite.helper.js +22 -11
- package/build/cjs/AuxTA.d.ts +43 -0
- package/build/cjs/AuxTA.js +137 -0
- package/build/cjs/auxta/configs/config.d.ts +51 -0
- package/build/cjs/auxta/configs/config.js +66 -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 +4 -0
- package/build/cjs/auxta/hooks/report.hook.js +66 -0
- package/build/cjs/auxta/models/upload.model.d.ts +20 -0
- package/build/cjs/auxta/models/upload.model.js +47 -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 +162 -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 +1 -0
- package/build/cjs/auxta/utilities/start-suite.helper.js +32 -0
- package/build/cjs/macros/helpers/code.helper.d.ts +22 -0
- package/build/cjs/macros/helpers/code.helper.js +200 -0
- package/build/cjs/puppeteer/puppeteer.d.ts +13 -0
- package/build/cjs/puppeteer/puppeteer.js +160 -0
- package/build/esm/AuxTA.d.ts +43 -0
- package/build/esm/AuxTA.js +97 -0
- package/build/esm/auxta/configs/config.d.ts +51 -0
- package/build/esm/auxta/configs/config.js +61 -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 +15 -0
- package/build/esm/auxta/hooks/report.hook.d.ts +4 -0
- package/build/esm/auxta/hooks/report.hook.js +45 -0
- package/build/esm/auxta/models/upload.model.d.ts +20 -0
- package/build/esm/auxta/models/upload.model.js +43 -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 +127 -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 +18 -0
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +1 -0
- package/build/esm/auxta/utilities/start-suite.helper.js +14 -0
- package/build/esm/macros/helpers/code.helper.d.ts +22 -0
- package/build/esm/macros/helpers/code.helper.js +158 -0
- package/build/esm/puppeteer/puppeteer.d.ts +13 -0
- package/build/esm/puppeteer/puppeteer.js +136 -0
- package/build/macros/helpers/code.helper.js +164 -129
- package/build/puppeteer/puppeteer.js +117 -100
- package/build/tsconfig-cjs.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
}, headers(token));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
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 @@
|
|
|
1
|
+
export declare function startSuite(suites: string[], reportId?: string): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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.startSuite = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const config_1 = require("../configs/config");
|
|
18
|
+
function startSuite(suites, reportId) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (suites.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
const next = suites.shift();
|
|
23
|
+
console.log('Starting next suite: ' + next);
|
|
24
|
+
try {
|
|
25
|
+
yield axios_1.default.post(`${config_1.config.netlifyPath}.netlify/functions/${next}?token=${config_1.config.token}`, { nextSuites: suites, reportId: reportId });
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
yield startSuite(suites, reportId);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.startSuite = startSuite;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
+
export declare class FunctionHelper {
|
|
3
|
+
readonly defaultTimeout: number;
|
|
4
|
+
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
|
+
suggest(name: string): void;
|
|
6
|
+
private getEscapedText;
|
|
7
|
+
clickByText(selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<void>;
|
|
8
|
+
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<void>;
|
|
9
|
+
waitForSelectorWithText(selector: string, text: string, page?: import("puppeteer-core").Page, dotOrText?: string): Promise<boolean>;
|
|
10
|
+
goto(url: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
11
|
+
type(field: string, value: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
12
|
+
waitForNetwork(page?: import("puppeteer-core").Page): Promise<void>;
|
|
13
|
+
timeout(timeout?: number, page?: import("puppeteer-core").Page): Promise<void>;
|
|
14
|
+
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer-core").Page, log_message?: boolean): Promise<void>;
|
|
15
|
+
click(selector: string, logMessages?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
|
|
16
|
+
urlContains(selector: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
17
|
+
pressEnter(page?: import("puppeteer-core").Page): Promise<void>;
|
|
18
|
+
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer-core").Page): Promise<void>;
|
|
19
|
+
closeLastPage(page?: import("puppeteer-core").Page): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
declare const _default: FunctionHelper;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,200 @@
|
|
|
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 config_1 = require("../../auxta/configs/config");
|
|
20
|
+
class FunctionHelper {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.defaultTimeout = config_1.config.timeout;
|
|
23
|
+
}
|
|
24
|
+
log(keyword, name, status) {
|
|
25
|
+
log_service_1.default.push(keyword, name, status);
|
|
26
|
+
}
|
|
27
|
+
suggest(name) {
|
|
28
|
+
log_service_1.default.addSuggestion(name);
|
|
29
|
+
}
|
|
30
|
+
getEscapedText(text) {
|
|
31
|
+
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
32
|
+
return `concat('${splitedQuotes}', '')`;
|
|
33
|
+
}
|
|
34
|
+
clickByText(selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
37
|
+
try {
|
|
38
|
+
const [linkHandlers] = yield page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
39
|
+
if (linkHandlers) {
|
|
40
|
+
yield linkHandlers.click();
|
|
41
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
}
|
|
47
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
48
|
+
throw new Error(message);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
clickByTextWithClass(class_selector, class_name, selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const message = `I click on the '${text}' '${selector}'`;
|
|
54
|
+
try {
|
|
55
|
+
const [linkHandlers] = yield page.$x(`//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
56
|
+
if (linkHandlers) {
|
|
57
|
+
yield linkHandlers.click();
|
|
58
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
}
|
|
64
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
waitForSelectorWithText(selector, text, page = puppeteer_1.default.defaultPage, dotOrText = '.') {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const message = `I check for '${text}' on the current page`;
|
|
71
|
+
try {
|
|
72
|
+
yield page.waitForSelector(selector, {
|
|
73
|
+
timeout: this.defaultTimeout
|
|
74
|
+
});
|
|
75
|
+
const linkHandlers = yield page.$x(`//${selector}[${dotOrText} = ${this.getEscapedText(text)}]`);
|
|
76
|
+
if (linkHandlers.length > 0) {
|
|
77
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
}
|
|
83
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
84
|
+
throw new Error(message);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
goto(url, page = puppeteer_1.default.defaultPage) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
yield page.goto(url);
|
|
90
|
+
log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
type(field, value, page = puppeteer_1.default.defaultPage) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
try {
|
|
96
|
+
yield page.waitForSelector(field, {
|
|
97
|
+
timeout: this.defaultTimeout
|
|
98
|
+
});
|
|
99
|
+
yield page.type(field, value);
|
|
100
|
+
let elementName = yield page.$eval(field, (e) => e.textContent);
|
|
101
|
+
if (!elementName || elementName === ' ')
|
|
102
|
+
elementName = field;
|
|
103
|
+
log_service_1.default.push('Then', `I type '${value}' into the '${elementName}' field`, status_of_step_1.StatusOfStep.PASSED);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
const msg = `I type '${value}' into the '${field}' field`;
|
|
107
|
+
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
108
|
+
throw new Error(msg);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
waitForNetwork(page = puppeteer_1.default.defaultPage) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
let message = 'I wait for the page to load';
|
|
115
|
+
try {
|
|
116
|
+
yield page.waitForNetworkIdle();
|
|
117
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.FAILED);
|
|
121
|
+
throw new Error(message);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
yield page.waitForTimeout(timeout);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const message = `I check for the '${selector}' element to be ${option}`;
|
|
133
|
+
try {
|
|
134
|
+
yield page.waitForSelector(selector, {
|
|
135
|
+
[option]: true,
|
|
136
|
+
timeout: time
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
if (log_message) {
|
|
141
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
142
|
+
}
|
|
143
|
+
throw new Error(message);
|
|
144
|
+
}
|
|
145
|
+
if (log_message) {
|
|
146
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
click(selector, logMessages = true, page = puppeteer_1.default.defaultPage) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
try {
|
|
153
|
+
yield page.waitForSelector(selector, {
|
|
154
|
+
timeout: this.defaultTimeout
|
|
155
|
+
});
|
|
156
|
+
let elementName = yield page.$eval(selector, (e) => e.textContent);
|
|
157
|
+
if (!elementName || elementName === ' ')
|
|
158
|
+
elementName = selector;
|
|
159
|
+
yield page.click(selector);
|
|
160
|
+
log_service_1.default.push('Then', `I click on the '${elementName}'`, status_of_step_1.StatusOfStep.PASSED);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
const msg = `I click on the '${selector}'`;
|
|
164
|
+
log_service_1.default.push('Then', msg, status_of_step_1.StatusOfStep.FAILED);
|
|
165
|
+
throw new Error(msg);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
urlContains(selector, page = puppeteer_1.default.defaultPage) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const url = page.url();
|
|
172
|
+
let message = `I am on the ${selector} page`;
|
|
173
|
+
if (!url.includes(selector)) {
|
|
174
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.FAILED);
|
|
175
|
+
throw new Error(message);
|
|
176
|
+
}
|
|
177
|
+
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
pressEnter(page = puppeteer_1.default.defaultPage) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
yield page.keyboard.press('Enter');
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
clickAndWaitForPageToBeCreated(selector, page = puppeteer_1.default.defaultPage) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const nav = new Promise(res => page.browser().on('targetcreated', res));
|
|
188
|
+
yield this.click(selector);
|
|
189
|
+
yield nav;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
closeLastPage(page = puppeteer_1.default.defaultPage) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const pages = yield page.browser().pages();
|
|
195
|
+
yield pages[pages.length - 1].close();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.FunctionHelper = FunctionHelper;
|
|
200
|
+
exports.default = new FunctionHelper();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UploadModel } from "../auxta/models/upload.model";
|
|
2
|
+
import puppeteer_core from 'puppeteer-core';
|
|
3
|
+
export declare class Puppeteer {
|
|
4
|
+
defaultPage: puppeteer_core.Page;
|
|
5
|
+
private browser;
|
|
6
|
+
startBrowser(): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel, close?: boolean): Promise<void>;
|
|
9
|
+
runRPA(event: any, callback: any, close?: boolean): Promise<any>;
|
|
10
|
+
private static setupHeader;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: Puppeteer;
|
|
13
|
+
export default _default;
|