@auxcode/auxta 1.3.132 → 1.3.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/build/AuxTA.d.ts +60 -0
  2. package/build/AuxTA.js +168 -0
  3. package/build/auxta/configs/config.d.ts +63 -0
  4. package/build/auxta/configs/config.js +78 -0
  5. package/build/auxta/enums/status-of.step.d.ts +9 -0
  6. package/build/auxta/enums/status-of.step.js +13 -0
  7. package/build/auxta/helpers/response.helper.d.ts +9 -0
  8. package/build/auxta/helpers/response.helper.js +14 -0
  9. package/build/auxta/helpers/start.helper.d.ts +1 -0
  10. package/build/auxta/helpers/start.helper.js +26 -0
  11. package/build/auxta/hooks/report.hook.d.ts +13 -0
  12. package/build/auxta/hooks/report.hook.js +68 -0
  13. package/build/auxta/models/upload.model.d.ts +41 -0
  14. package/build/auxta/models/upload.model.js +96 -0
  15. package/build/auxta/services/log.service.d.ts +39 -0
  16. package/build/auxta/services/log.service.js +109 -0
  17. package/build/auxta/services/report.service.d.ts +41 -0
  18. package/build/auxta/services/report.service.js +269 -0
  19. package/build/auxta/services/runtime.service.d.ts +16 -0
  20. package/build/auxta/services/runtime.service.js +40 -0
  21. package/build/auxta/utilities/runtime.helper.d.ts +15 -0
  22. package/build/auxta/utilities/runtime.helper.js +19 -0
  23. package/build/auxta/utilities/screenshot.helper.d.ts +3 -0
  24. package/build/auxta/utilities/screenshot.helper.js +100 -0
  25. package/build/auxta/utilities/start-suite.helper.d.ts +17 -0
  26. package/build/auxta/utilities/start-suite.helper.js +30 -0
  27. package/build/macros/helpers/Aux2faAuth.d.ts +7 -0
  28. package/build/macros/helpers/Aux2faAuth.js +29 -0
  29. package/build/macros/helpers/code.helper.d.ts +34 -0
  30. package/build/macros/helpers/code.helper.js +352 -0
  31. package/build/macros/helpers/emailHelper.d.ts +7 -0
  32. package/build/macros/helpers/emailHelper.js +54 -0
  33. package/build/macros/helpers/extend-default-page.d.ts +6 -0
  34. package/build/macros/helpers/extend-default-page.js +92 -0
  35. package/build/puppeteer/puppeteer.d.ts +35 -0
  36. package/build/puppeteer/puppeteer.js +339 -0
  37. package/package.json +1 -1
@@ -0,0 +1,39 @@
1
+ import { StatusOfStep } from "../enums/status-of.step";
2
+ export interface Step {
3
+ keyword: string;
4
+ tag: string;
5
+ name: string;
6
+ imageCompareKey: string;
7
+ result: {
8
+ status: StatusOfStep;
9
+ duration: number;
10
+ embedding?: {
11
+ data: Uint8Array | Buffer;
12
+ mime_type: string;
13
+ };
14
+ };
15
+ }
16
+ export declare class LogSteps {
17
+ statusCounter: {
18
+ passed: number;
19
+ failed: number;
20
+ skipped: number;
21
+ suggestion: number;
22
+ performanceFailure: number;
23
+ log: number;
24
+ };
25
+ private stepLog;
26
+ private lastStepTime;
27
+ private _tags;
28
+ addSuggestion(text: string): void;
29
+ addPerformanceFail(text: string, screenshot?: Uint8Array | Buffer): void;
30
+ clear(): void;
31
+ push(keyword: string, tag: string, name: string, status: StatusOfStep, screenshot?: Uint8Array | Buffer, imageCompareKey?: string): void;
32
+ returnScenarioReport(): Step[];
33
+ getStatusCount(status: StatusOfStep): number;
34
+ get tag(): string;
35
+ set tag(value: string);
36
+ clearTag(): void;
37
+ }
38
+ declare const log: LogSteps;
39
+ export default log;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogSteps = void 0;
4
+ const status_of_step_1 = require("../enums/status-of.step");
5
+ class LogSteps {
6
+ constructor() {
7
+ this.statusCounter = {
8
+ [status_of_step_1.StatusOfStep.PASSED]: 0,
9
+ [status_of_step_1.StatusOfStep.FAILED]: 0,
10
+ [status_of_step_1.StatusOfStep.SKIPPED]: 0,
11
+ [status_of_step_1.StatusOfStep.SUGGESTION]: 0,
12
+ [status_of_step_1.StatusOfStep.PERFORMANCE_FAIL]: 0,
13
+ [status_of_step_1.StatusOfStep.LOG]: 0
14
+ };
15
+ this.stepLog = [];
16
+ this.lastStepTime = new Date().getTime();
17
+ this._tags = ['default'];
18
+ }
19
+ addSuggestion(text) {
20
+ this.statusCounter[status_of_step_1.StatusOfStep.SUGGESTION]++;
21
+ this.stepLog.push({
22
+ keyword: 'Suggestion', tag: this.tag, name: text, imageCompareKey: '', result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
23
+ });
24
+ }
25
+ addPerformanceFail(text, screenshot = new Uint8Array()) {
26
+ this.statusCounter[status_of_step_1.StatusOfStep.PERFORMANCE_FAIL]++;
27
+ const currentStep = new Date().getTime();
28
+ if (screenshot.byteLength != 0) {
29
+ const embedding = {
30
+ data: screenshot,
31
+ mime_type: "image/png"
32
+ };
33
+ this.stepLog.push({
34
+ keyword: 'PerformanceFail',
35
+ tag: this.tag,
36
+ name: text,
37
+ imageCompareKey: '',
38
+ result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime, embedding }
39
+ });
40
+ }
41
+ else {
42
+ this.stepLog.push({
43
+ keyword: 'PerformanceFail',
44
+ tag: this.tag,
45
+ name: text,
46
+ imageCompareKey: '',
47
+ result: { status: status_of_step_1.StatusOfStep.PERFORMANCE_FAIL, duration: currentStep - this.lastStepTime }
48
+ });
49
+ }
50
+ this.lastStepTime = currentStep;
51
+ }
52
+ clear() {
53
+ this.stepLog = [];
54
+ this.statusCounter = {
55
+ [status_of_step_1.StatusOfStep.PASSED]: 0,
56
+ [status_of_step_1.StatusOfStep.FAILED]: 0,
57
+ [status_of_step_1.StatusOfStep.SKIPPED]: 0,
58
+ [status_of_step_1.StatusOfStep.SUGGESTION]: 0,
59
+ [status_of_step_1.StatusOfStep.PERFORMANCE_FAIL]: 0,
60
+ [status_of_step_1.StatusOfStep.LOG]: 0
61
+ };
62
+ }
63
+ push(keyword, tag, name, status, screenshot = new Uint8Array(), imageCompareKey = '') {
64
+ console.log(`System log -- status: ${status} -- tag: ${tag} -- : ${name} `);
65
+ this.statusCounter[status]++;
66
+ const currentStep = new Date().getTime();
67
+ if (screenshot.byteLength != 0) {
68
+ const embedding = {
69
+ data: screenshot,
70
+ mime_type: "image/png"
71
+ };
72
+ this.stepLog.push({
73
+ keyword,
74
+ tag,
75
+ name,
76
+ imageCompareKey,
77
+ result: { status, duration: currentStep - this.lastStepTime, embedding }
78
+ });
79
+ }
80
+ else {
81
+ this.stepLog.push({
82
+ keyword,
83
+ tag,
84
+ name,
85
+ imageCompareKey,
86
+ result: { status, duration: currentStep - this.lastStepTime }
87
+ });
88
+ }
89
+ this.lastStepTime = currentStep;
90
+ }
91
+ returnScenarioReport() {
92
+ return this.stepLog;
93
+ }
94
+ getStatusCount(status) {
95
+ return this.statusCounter[status];
96
+ }
97
+ get tag() {
98
+ return this._tags.length === 1 ? this._tags[0] : this._tags[1];
99
+ }
100
+ set tag(value) {
101
+ this._tags.push(value);
102
+ }
103
+ clearTag() {
104
+ this._tags.pop();
105
+ }
106
+ }
107
+ exports.LogSteps = LogSteps;
108
+ const log = new LogSteps();
109
+ exports.default = log;
@@ -0,0 +1,41 @@
1
+ import { Step } from "./log.service";
2
+ import { UploadModel } from "../models/upload.model";
3
+ export interface Scenarios {
4
+ scenarioId: string;
5
+ scenarioName: string;
6
+ scenarioUri: string;
7
+ status: string;
8
+ scenariosCount: number;
9
+ lastTag: string;
10
+ }
11
+ export interface Steps {
12
+ failedSteps: number;
13
+ passedSteps: number;
14
+ skippedSteps: number;
15
+ suggestedSteps: number;
16
+ performanceFailure: number;
17
+ log: number;
18
+ }
19
+ export declare function setTimeZone(): Promise<any>;
20
+ export declare function setEmailProvider(): Promise<any>;
21
+ export declare function createEmptyReport(body: any): Promise<string>;
22
+ export declare function uploadStep(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object): Promise<{
23
+ stepRef: any;
24
+ name: any;
25
+ status: any;
26
+ stepsCount: any;
27
+ }[]>;
28
+ export declare function uploadScenario(stepRes: any[], scenarioName: string, uri: string, hasFailed: boolean): Promise<any>;
29
+ export declare function updateReport(reportId: string, scenario: Scenarios, steps: Steps, isFinal: boolean): Promise<void>;
30
+ export declare function getReport(reportId: string): Promise<any>;
31
+ export declare function getLastDayResults(): Promise<any>;
32
+ export declare function compareScreenshots(key: string, screenshot?: Uint8Array | Buffer): Promise<any>;
33
+ export declare function postNotifications(body: UploadModel): Promise<void>;
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, {
36
+ from_name: string;
37
+ from_email: string;
38
+ subject: string;
39
+ body: string;
40
+ link: boolean;
41
+ }, {}, any>>;
@@ -0,0 +1,269 @@
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.setTimeZone = setTimeZone;
16
+ exports.setEmailProvider = setEmailProvider;
17
+ exports.createEmptyReport = createEmptyReport;
18
+ exports.uploadStep = uploadStep;
19
+ exports.uploadScenario = uploadScenario;
20
+ exports.updateReport = updateReport;
21
+ exports.getReport = getReport;
22
+ exports.getLastDayResults = getLastDayResults;
23
+ exports.compareScreenshots = compareScreenshots;
24
+ exports.postNotifications = postNotifications;
25
+ exports.postNotificationsOnFail = postNotificationsOnFail;
26
+ exports.getVerifyReceivedEmail = getVerifyReceivedEmail;
27
+ const axios_1 = __importDefault(require("axios"));
28
+ const config_1 = require("../configs/config");
29
+ function headers(token) {
30
+ return {
31
+ headers: {
32
+ 'Content-Type': 'application/json',
33
+ 'cookie': `authToken=${token}`
34
+ }
35
+ };
36
+ }
37
+ function auth() {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ let token = yield axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
40
+ headers: {
41
+ 'Content-Type': 'application/json',
42
+ }
43
+ })
44
+ .then(({ data }) => {
45
+ return data.token;
46
+ })
47
+ .catch(() => {
48
+ return false;
49
+ });
50
+ if (token == false) {
51
+ token = axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ }
55
+ })
56
+ .then(({ data }) => {
57
+ return data.token;
58
+ })
59
+ .catch(() => {
60
+ throw new Error("Invalid login credentials");
61
+ });
62
+ }
63
+ return token;
64
+ });
65
+ }
66
+ function setTimeZone() {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const token = yield auth();
69
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "set-timezone-organization", {
70
+ organization: config_1.config.organization,
71
+ timezone: config_1.config.timezone
72
+ }, headers(token))).data;
73
+ });
74
+ }
75
+ function setEmailProvider() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const token = yield auth();
78
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "set-email-provider-organization", {
79
+ organization: config_1.config.organization,
80
+ emailProvider: config_1.config.emailProvider
81
+ }, headers(token))).data;
82
+ });
83
+ }
84
+ function createEmptyReport(body) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const token = yield auth();
87
+ const moment = require('moment-timezone');
88
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "create-empty-report", {
89
+ environment: body.environment,
90
+ digitalProductToken: body.digitalProduct,
91
+ bucket: body.bucket,
92
+ start: moment().tz(config_1.config.timezone),
93
+ emailProvider: config_1.config.emailProvider,
94
+ url: body.baseUrl
95
+ }, headers(token))).data.reportId;
96
+ });
97
+ }
98
+ function uploadStep(stepLog, scenarioName, screenshot, errMessage) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ var _a;
101
+ let scenarios = [];
102
+ let token = yield auth();
103
+ let lastStep = stepLog[stepLog.length - 1];
104
+ const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
105
+ stepLogFormat.pop();
106
+ try {
107
+ for (let i = 0; i < stepLogFormat.length; i++) {
108
+ const st = stepLogFormat[i];
109
+ const emb = (_a = st === null || st === void 0 ? void 0 : st.result) === null || _a === void 0 ? void 0 : _a.embedding;
110
+ if (emb && typeof st.embeddings === 'undefined') {
111
+ st.embeddings = [emb];
112
+ }
113
+ }
114
+ }
115
+ catch (_b) { }
116
+ try {
117
+ const byTab = (errMessage === null || errMessage === void 0 ? void 0 : errMessage.byTab) || undefined;
118
+ if (byTab) {
119
+ for (let idx = 0; idx < stepLogFormat.length; idx++) {
120
+ const step = stepLogFormat[idx];
121
+ if (typeof (step === null || step === void 0 ? void 0 : step.name) === 'string') {
122
+ const m = step.name.match(/^(\d+)\s+Image/i);
123
+ if (m) {
124
+ const tabNum = Number(m[1]);
125
+ const tabErr = byTab[String(tabNum)] || byTab[tabNum];
126
+ if (tabErr) {
127
+ stepLogFormat[idx] = Object.assign({}, step, {
128
+ result: Object.assign({}, step.result, {
129
+ error_message: JSON.stringify(tabErr)
130
+ })
131
+ });
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ catch (_c) { }
139
+ let output = (yield axios_1.default.post(config_1.config.auxtaURL + "create-steps", {
140
+ json: {
141
+ name: scenarioName,
142
+ steps: [
143
+ ...stepLogFormat,
144
+ (lastStep.result.status == 'failed')
145
+ ? Object.assign(lastStep, {
146
+ result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
147
+ })
148
+ : lastStep,
149
+ {
150
+ keyword: "After",
151
+ result: {
152
+ status: "passed",
153
+ duration: 2678000000
154
+ },
155
+ embeddings: (screenshot) ? [{
156
+ data: screenshot,
157
+ mime_type: "image/png"
158
+ }] : undefined,
159
+ }
160
+ ],
161
+ }
162
+ }, headers(token))).data.scenarios;
163
+ scenarios.push({
164
+ stepRef: output.stepRef,
165
+ name: output.name,
166
+ status: output.status,
167
+ stepsCount: output.stepsCount
168
+ });
169
+ return scenarios;
170
+ });
171
+ }
172
+ function uploadScenario(stepRes, scenarioName, uri, hasFailed) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ let token = yield auth();
175
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "create-scenario", {
176
+ json: {
177
+ name: scenarioName,
178
+ uri: uri
179
+ },
180
+ scenarios: stepRes,
181
+ hasFailed: hasFailed
182
+ }, headers(token))).data;
183
+ });
184
+ }
185
+ function updateReport(reportId, scenario, steps, isFinal) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ let token = yield auth();
188
+ const moment = require('moment-timezone');
189
+ yield axios_1.default.post(config_1.config.auxtaURL + "update-inprogress-report", {
190
+ reportId: reportId,
191
+ isFinal: isFinal,
192
+ end: moment().tz(config_1.config.timezone),
193
+ data: Object.assign({ scenario: {
194
+ scenarioRef: scenario.scenarioId,
195
+ name: scenario.scenarioName,
196
+ uri: scenario.scenarioUri,
197
+ status: scenario.status,
198
+ scenariosCount: scenario.scenariosCount,
199
+ lastTag: scenario.lastTag
200
+ } }, steps)
201
+ }, headers(token));
202
+ });
203
+ }
204
+ function getReport(reportId) {
205
+ return __awaiter(this, void 0, void 0, function* () {
206
+ let token = yield auth();
207
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
208
+ });
209
+ }
210
+ function getLastDayResults() {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ let token = yield auth();
213
+ return (yield axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
214
+ });
215
+ }
216
+ function compareScreenshots(key_1) {
217
+ return __awaiter(this, arguments, void 0, function* (key, screenshot = new Uint8Array()) {
218
+ let token = yield auth();
219
+ const embedding = {
220
+ data: screenshot,
221
+ mime_type: "image/png"
222
+ };
223
+ return (yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
224
+ organization: config_1.config.organization,
225
+ key: key,
226
+ embedding: embedding,
227
+ }, headers(token))).data;
228
+ });
229
+ }
230
+ function postNotifications(body) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ let token = yield auth();
233
+ yield axios_1.default.post(`${config_1.config.auxtaURL}post-notification-after-run-background`, {
234
+ environmentName: body.environment,
235
+ digitalProductToken: body.digitalProduct,
236
+ organizationName: body.organization,
237
+ bucketName: body.bucket,
238
+ reportId: body.reportId,
239
+ isOfficial: body.isOfficial
240
+ }, headers(token));
241
+ });
242
+ }
243
+ function postNotificationsOnFail(body) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ let token = yield auth();
246
+ yield axios_1.default.post(`${config_1.config.auxtaURL}post-notifications-after-case-fail-background`, {
247
+ environmentName: body.environment,
248
+ digitalProductToken: body.digitalProduct,
249
+ organizationName: body.organization,
250
+ bucketName: body.bucket,
251
+ reportId: body.reportId,
252
+ featureName: body.featureName,
253
+ scenarioName: body.scenarioName,
254
+ isOfficial: body.isOfficial
255
+ }, headers(token));
256
+ });
257
+ }
258
+ function getVerifyReceivedEmail(from_name, from_email, subject, body, link) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ let token = yield auth();
261
+ return yield axios_1.default.post(`${config_1.config.auxtaURL}get-verify-received-email`, {
262
+ from_name: from_name,
263
+ from_email: from_email,
264
+ subject: subject,
265
+ body: body,
266
+ link: link
267
+ }, headers(token));
268
+ });
269
+ }
@@ -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
+ returnRuntime(): RunTime;
12
+ private calculateDuration;
13
+ private splitAtDecimanlMinutes;
14
+ private splitAtDecimanlHours;
15
+ private formatRuntime;
16
+ }
@@ -0,0 +1,40 @@
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
+ returnRuntime() {
10
+ let duration = this.formatRuntime(this.calculateDuration());
11
+ let startTime = this.start;
12
+ let endTime = this.end;
13
+ this.runtime = { duration, startTime, endTime };
14
+ return this.runtime;
15
+ }
16
+ calculateDuration() {
17
+ let currentTime = new Date;
18
+ return currentTime.getTime() - this.start.getTime();
19
+ }
20
+ splitAtDecimanlMinutes(time) {
21
+ let minutes = time.toFixed(2).toString().split('.');
22
+ return `${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
23
+ }
24
+ splitAtDecimanlHours(time) {
25
+ let hours = time.toFixed(2).toString().split('.');
26
+ let minutes = (Number(hours[1]) / 100 * 60).toFixed(2).toString().split('.');
27
+ return `${hours[0]}h ${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
28
+ }
29
+ formatRuntime(duration) {
30
+ if (duration / 1000 < 60)
31
+ return `${(duration / 1000).toFixed(0)}s`;
32
+ else {
33
+ if (duration / 60000 < 60)
34
+ return this.splitAtDecimanlMinutes(duration / 60000);
35
+ else
36
+ return this.splitAtDecimanlHours(duration / 3600000);
37
+ }
38
+ }
39
+ }
40
+ exports.Runtime = Runtime;
@@ -0,0 +1,15 @@
1
+ import { RunTime } from "../services/runtime.service";
2
+ export declare class CalculateRuntime {
3
+ startTimeSeconds: string;
4
+ startTimeMinutes: string;
5
+ startTimeHours: string;
6
+ startTimeDay: string;
7
+ startTimeMonth: string;
8
+ endTimeSeconds: string;
9
+ endTimeMinutes: string;
10
+ endTimeHours: string;
11
+ endTimeDay: string;
12
+ endTimeMonth: string;
13
+ private runtime;
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,3 @@
1
+ import { Page } from "puppeteer";
2
+ export declare function captureScreenshot(): Promise<Buffer<ArrayBufferLike> | undefined>;
3
+ export declare function captureScreenshotPage(page: Page): Promise<Buffer<ArrayBufferLike> | undefined>;
@@ -0,0 +1,100 @@
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 = captureScreenshot;
16
+ exports.captureScreenshotPage = captureScreenshotPage;
17
+ const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
18
+ const log_service_1 = __importDefault(require("../services/log.service"));
19
+ const status_of_step_1 = __importDefault(require("../enums/status-of.step"));
20
+ const RETRY_NUMBERS = 10;
21
+ function captureScreenshot() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const pages = yield puppeteer_1.default.defaultPage.browser().pages();
24
+ if (!pages.length)
25
+ return undefined;
26
+ for (let i = 0; i < pages.length; i++) {
27
+ const page = pages[i];
28
+ if ((pages.length - 1) == i || pages.length == 1) {
29
+ let count = 0;
30
+ while (count <= RETRY_NUMBERS) {
31
+ try {
32
+ const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
33
+ const screenshotBuffer = yield lastPage.screenshot({
34
+ captureBeyondViewport: false,
35
+ encoding: 'binary'
36
+ });
37
+ if (Buffer.isBuffer(screenshotBuffer))
38
+ return screenshotBuffer;
39
+ }
40
+ catch (e) {
41
+ if (count == RETRY_NUMBERS) {
42
+ log_service_1.default.push('When', log_service_1.default.tag, e.toString(), status_of_step_1.default.FAILED);
43
+ return undefined;
44
+ }
45
+ }
46
+ count++;
47
+ }
48
+ }
49
+ else {
50
+ let count = 0;
51
+ while (count <= RETRY_NUMBERS) {
52
+ try {
53
+ const screenshotBuffer = yield page.screenshot({
54
+ captureBeyondViewport: false,
55
+ encoding: 'binary'
56
+ });
57
+ if (Buffer.isBuffer(screenshotBuffer)) {
58
+ log_service_1.default.push("When", log_service_1.default.tag, `${i} Image`, status_of_step_1.default.FAILED, screenshotBuffer);
59
+ break;
60
+ }
61
+ }
62
+ catch (e) {
63
+ if (count == RETRY_NUMBERS) {
64
+ log_service_1.default.push('When', log_service_1.default.tag, e.toString(), status_of_step_1.default.FAILED);
65
+ return undefined;
66
+ }
67
+ }
68
+ count++;
69
+ }
70
+ }
71
+ }
72
+ return undefined;
73
+ });
74
+ }
75
+ function captureScreenshotPage(page) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ let count = 0;
78
+ while (count <= RETRY_NUMBERS) {
79
+ try {
80
+ const pages = yield puppeteer_1.default.defaultPage.browser().pages();
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);
82
+ const screenshotBuffer = yield page.screenshot({
83
+ fullPage: true,
84
+ captureBeyondViewport: false,
85
+ encoding: 'binary'
86
+ });
87
+ if (Buffer.isBuffer(screenshotBuffer))
88
+ return screenshotBuffer;
89
+ }
90
+ catch (e) {
91
+ if (count == RETRY_NUMBERS) {
92
+ log_service_1.default.push('When', log_service_1.default.tag, e.toString(), status_of_step_1.default.FAILED);
93
+ return undefined;
94
+ }
95
+ }
96
+ count++;
97
+ }
98
+ return undefined;
99
+ });
100
+ }
@@ -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
+ }>;