@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.
Files changed (71) hide show
  1. package/build/cjs/AuxTA.d.ts +57 -0
  2. package/build/cjs/AuxTA.js +148 -0
  3. package/build/cjs/auxta/configs/config.d.ts +51 -0
  4. package/build/cjs/auxta/configs/config.js +63 -0
  5. package/build/cjs/auxta/enums/status-of.step.d.ts +7 -0
  6. package/build/cjs/auxta/enums/status-of.step.js +11 -0
  7. package/build/cjs/auxta/helpers/response.helper.d.ts +10 -0
  8. package/build/cjs/auxta/helpers/response.helper.js +15 -0
  9. package/build/cjs/auxta/helpers/start.helper.d.ts +1 -0
  10. package/build/cjs/auxta/helpers/start.helper.js +26 -0
  11. package/build/cjs/auxta/hooks/report.hook.d.ts +14 -0
  12. package/build/cjs/auxta/hooks/report.hook.js +66 -0
  13. package/build/cjs/auxta/models/upload.model.d.ts +32 -0
  14. package/build/cjs/auxta/models/upload.model.js +75 -0
  15. package/build/cjs/auxta/services/log.service.d.ts +26 -0
  16. package/build/cjs/auxta/services/log.service.js +47 -0
  17. package/build/cjs/auxta/services/report.service.d.ts +36 -0
  18. package/build/cjs/auxta/services/report.service.js +164 -0
  19. package/build/cjs/auxta/services/runtime.service.d.ts +16 -0
  20. package/build/cjs/auxta/services/runtime.service.js +41 -0
  21. package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -0
  22. package/build/cjs/auxta/utilities/runtime.helper.js +19 -0
  23. package/build/cjs/auxta/utilities/screenshot.helper.d.ts +2 -0
  24. package/build/cjs/auxta/utilities/screenshot.helper.js +36 -0
  25. package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -0
  26. package/build/cjs/auxta/utilities/start-suite.helper.js +31 -0
  27. package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -0
  28. package/build/cjs/macros/helpers/Aux2faAuth.js +29 -0
  29. package/build/cjs/macros/helpers/code.helper.d.ts +23 -0
  30. package/build/cjs/macros/helpers/code.helper.js +166 -0
  31. package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -0
  32. package/build/cjs/macros/helpers/extend-default-page.js +88 -0
  33. package/build/cjs/puppeteer/puppeteer.d.ts +25 -0
  34. package/build/cjs/puppeteer/puppeteer.js +200 -0
  35. package/build/esm/AuxTA.d.ts +57 -0
  36. package/build/esm/AuxTA.js +119 -0
  37. package/build/esm/auxta/configs/config.d.ts +51 -0
  38. package/build/esm/auxta/configs/config.js +58 -0
  39. package/build/esm/auxta/enums/status-of.step.d.ts +7 -0
  40. package/build/esm/auxta/enums/status-of.step.js +8 -0
  41. package/build/esm/auxta/helpers/response.helper.d.ts +10 -0
  42. package/build/esm/auxta/helpers/response.helper.js +11 -0
  43. package/build/esm/auxta/helpers/start.helper.d.ts +1 -0
  44. package/build/esm/auxta/helpers/start.helper.js +24 -0
  45. package/build/esm/auxta/hooks/report.hook.d.ts +14 -0
  46. package/build/esm/auxta/hooks/report.hook.js +58 -0
  47. package/build/esm/auxta/models/upload.model.d.ts +32 -0
  48. package/build/esm/auxta/models/upload.model.js +71 -0
  49. package/build/esm/auxta/services/log.service.d.ts +26 -0
  50. package/build/esm/auxta/services/log.service.js +43 -0
  51. package/build/esm/auxta/services/report.service.d.ts +36 -0
  52. package/build/esm/auxta/services/report.service.js +150 -0
  53. package/build/esm/auxta/services/runtime.service.d.ts +16 -0
  54. package/build/esm/auxta/services/runtime.service.js +37 -0
  55. package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -0
  56. package/build/esm/auxta/utilities/runtime.helper.js +15 -0
  57. package/build/esm/auxta/utilities/screenshot.helper.d.ts +2 -0
  58. package/build/esm/auxta/utilities/screenshot.helper.js +29 -0
  59. package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -0
  60. package/build/esm/auxta/utilities/start-suite.helper.js +26 -0
  61. package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -0
  62. package/build/esm/macros/helpers/Aux2faAuth.js +25 -0
  63. package/build/esm/macros/helpers/code.helper.d.ts +23 -0
  64. package/build/esm/macros/helpers/code.helper.js +159 -0
  65. package/build/esm/macros/helpers/extend-default-page.d.ts +6 -0
  66. package/build/esm/macros/helpers/extend-default-page.js +81 -0
  67. package/build/esm/puppeteer/puppeteer.d.ts +25 -0
  68. package/build/esm/puppeteer/puppeteer.js +192 -0
  69. package/build/tsconfig-cjs.tsbuildinfo +1 -0
  70. package/build/tsconfig.tsbuildinfo +1 -0
  71. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import { UploadModel } from "../models/upload.model";
3
+ export declare function onTestEnd(body: any, featureName: string, scenarioName: string, statusCode: number, screenshotBuffer?: Buffer, errMessage?: object): Promise<{
4
+ nextSuites?: undefined;
5
+ reportId?: undefined;
6
+ currentSuite?: undefined;
7
+ retries?: undefined;
8
+ } | {
9
+ nextSuites: string[];
10
+ reportId: string | undefined;
11
+ currentSuite: string | undefined;
12
+ retries: string;
13
+ } | undefined>;
14
+ export declare function afterComplete(body: UploadModel): Promise<void>;
@@ -0,0 +1,58 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { basename } from 'path';
11
+ import log from "../services/log.service";
12
+ import { postNotifications, updateReport, uploadFeature, uploadScenario } from '../services/report.service';
13
+ import { startSuite } from '../utilities/start-suite.helper';
14
+ import { StatusOfStep } from "../enums/status-of.step";
15
+ export function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ let isFinal = false;
18
+ if (process.env.ENVIRONMENT == "LIVE") {
19
+ console.log('--- Uploading scenario and feature for AUXTA report ---');
20
+ const stepsArr = log.returnScenarioReport();
21
+ try {
22
+ const scenarioRes = yield uploadScenario(stepsArr, scenarioName, screenshotBuffer, errMessage);
23
+ const featureRes = yield uploadFeature(scenarioRes, featureName, basename(__filename), (statusCode != 200));
24
+ const feature = {
25
+ featureId: featureRes.featureRef,
26
+ featureName: featureRes.name,
27
+ featureUri: featureRes.uri,
28
+ status: featureRes.status,
29
+ scenariosCount: featureRes.scenariosCount
30
+ };
31
+ const stepCounts = {
32
+ failedSteps: log.getStatusCount(StatusOfStep.FAILED),
33
+ passedSteps: log.getStatusCount(StatusOfStep.PASSED),
34
+ skippedSteps: log.getStatusCount(StatusOfStep.SKIPPED),
35
+ suggestedSteps: log.getStatusCount(StatusOfStep.SUGGESTION)
36
+ };
37
+ isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
38
+ yield updateReport(body.reportId, feature, stepCounts, isFinal);
39
+ console.log('--- Finished uploading report data to AUXTA ---');
40
+ }
41
+ catch (error) {
42
+ console.log('--- Failed to update report in AUXTA ---');
43
+ console.log(error);
44
+ }
45
+ }
46
+ if (isFinal)
47
+ yield afterComplete(body);
48
+ else if (body && body.nextSuites) {
49
+ return yield startSuite(body.nextSuites, body.reportId);
50
+ }
51
+ });
52
+ }
53
+ export function afterComplete(body) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (process.env.ENVIRONMENT == "LIVE")
56
+ yield postNotifications(body);
57
+ });
58
+ }
@@ -0,0 +1,32 @@
1
+ export declare class UploadModel {
2
+ private _reportId;
3
+ private _nextSuites;
4
+ private _digitalProduct;
5
+ private _baseUrl;
6
+ private readonly _organization;
7
+ private _environment;
8
+ private _currentSuite;
9
+ private _retries;
10
+ private _featureName;
11
+ private _scenarioName;
12
+ constructor(org: string, baseUrl: string, digitalProduct: string, environment: string);
13
+ set currentSuite(value: string);
14
+ set retries(value: number);
15
+ get currentSuite(): string;
16
+ get retries(): number;
17
+ get reportId(): string;
18
+ set reportId(value: string);
19
+ get nextSuites(): [];
20
+ set nextSuites(value: []);
21
+ get digitalProduct(): string;
22
+ set digitalProduct(value: string);
23
+ get organization(): string;
24
+ get baseUrl(): string;
25
+ set baseUrl(value: string);
26
+ get environment(): string;
27
+ set environment(value: string);
28
+ get featureName(): string;
29
+ set featureName(value: string);
30
+ get scenarioName(): string;
31
+ set scenarioName(value: string);
32
+ }
@@ -0,0 +1,71 @@
1
+ export class UploadModel {
2
+ constructor(org, baseUrl, digitalProduct, environment) {
3
+ this._reportId = '';
4
+ this._nextSuites = [];
5
+ this._currentSuite = '';
6
+ this._retries = 0;
7
+ this._organization = org;
8
+ this._digitalProduct = digitalProduct;
9
+ this._environment = environment;
10
+ this._baseUrl = baseUrl;
11
+ this._featureName = '';
12
+ this._scenarioName = '';
13
+ }
14
+ set currentSuite(value) {
15
+ this._currentSuite = value;
16
+ }
17
+ set retries(value) {
18
+ this._retries = value;
19
+ }
20
+ get currentSuite() {
21
+ return this._currentSuite;
22
+ }
23
+ get retries() {
24
+ return this._retries;
25
+ }
26
+ get reportId() {
27
+ return this._reportId;
28
+ }
29
+ set reportId(value) {
30
+ this._reportId = value;
31
+ }
32
+ get nextSuites() {
33
+ return this._nextSuites;
34
+ }
35
+ set nextSuites(value) {
36
+ this._nextSuites = value;
37
+ }
38
+ get digitalProduct() {
39
+ return this._digitalProduct;
40
+ }
41
+ set digitalProduct(value) {
42
+ this._digitalProduct = value;
43
+ }
44
+ get organization() {
45
+ return this._organization;
46
+ }
47
+ get baseUrl() {
48
+ return this._baseUrl;
49
+ }
50
+ set baseUrl(value) {
51
+ this._baseUrl = value;
52
+ }
53
+ get environment() {
54
+ return this._environment;
55
+ }
56
+ set environment(value) {
57
+ this._environment = value;
58
+ }
59
+ get featureName() {
60
+ return this._featureName;
61
+ }
62
+ set featureName(value) {
63
+ this._featureName = value;
64
+ }
65
+ get scenarioName() {
66
+ return this._scenarioName;
67
+ }
68
+ set scenarioName(value) {
69
+ this._scenarioName = value;
70
+ }
71
+ }
@@ -0,0 +1,26 @@
1
+ import { StatusOfStep } from "../enums/status-of.step";
2
+ export interface Step {
3
+ keyword: string;
4
+ name: string;
5
+ result: {
6
+ status: StatusOfStep;
7
+ duration: number;
8
+ };
9
+ }
10
+ export declare class LogSteps {
11
+ private stepLog;
12
+ private lastStepTime;
13
+ statusCounter: {
14
+ passed: number;
15
+ failed: number;
16
+ skipped: number;
17
+ suggestion: number;
18
+ };
19
+ addSuggestion(text: string): void;
20
+ clear(): void;
21
+ push(keyword: string, name: string, status: StatusOfStep): void;
22
+ returnScenarioReport(): Step[];
23
+ getStatusCount(status: StatusOfStep): number;
24
+ }
25
+ declare const log: LogSteps;
26
+ export default log;
@@ -0,0 +1,43 @@
1
+ import { StatusOfStep } from "../enums/status-of.step";
2
+ export class LogSteps {
3
+ constructor() {
4
+ this.stepLog = [];
5
+ this.lastStepTime = new Date().getTime();
6
+ this.statusCounter = {
7
+ [StatusOfStep.PASSED]: 0,
8
+ [StatusOfStep.FAILED]: 0,
9
+ [StatusOfStep.SKIPPED]: 0,
10
+ [StatusOfStep.SUGGESTION]: 0,
11
+ };
12
+ }
13
+ addSuggestion(text) {
14
+ this.statusCounter[StatusOfStep.SUGGESTION]++;
15
+ this.stepLog.push({
16
+ keyword: 'Suggestion', name: text, result: { status: StatusOfStep.SUGGESTION, duration: 0 }
17
+ });
18
+ }
19
+ clear() {
20
+ this.stepLog = [];
21
+ this.statusCounter = {
22
+ [StatusOfStep.PASSED]: 0,
23
+ [StatusOfStep.FAILED]: 0,
24
+ [StatusOfStep.SKIPPED]: 0,
25
+ [StatusOfStep.SUGGESTION]: 0,
26
+ };
27
+ }
28
+ push(keyword, name, status) {
29
+ console.log(`System log -- status: ${status} -- : ${name} `);
30
+ this.statusCounter[status]++;
31
+ const currentStep = new Date().getTime();
32
+ this.stepLog.push({ keyword, name, result: { status, duration: currentStep - this.lastStepTime } });
33
+ this.lastStepTime = currentStep;
34
+ }
35
+ returnScenarioReport() {
36
+ return this.stepLog;
37
+ }
38
+ getStatusCount(status) {
39
+ return this.statusCounter[status];
40
+ }
41
+ }
42
+ const log = new LogSteps();
43
+ export default log;
@@ -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,150 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import axios from "axios";
11
+ import { config } from "../configs/config";
12
+ function headers(token) {
13
+ return {
14
+ headers: {
15
+ 'Content-Type': 'application/json',
16
+ 'cookie': `authToken=${token}`
17
+ }
18
+ };
19
+ }
20
+ function auth() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ return axios.post(config.auxtaURL + 'login', config.auxtaCredentials, {
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ }
26
+ })
27
+ .then(({ data }) => {
28
+ return data.token;
29
+ })
30
+ .catch(() => {
31
+ throw new Error("Invalid login credentials");
32
+ });
33
+ });
34
+ }
35
+ export function createEmptyReport(body) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const token = yield auth();
38
+ return (yield axios.post(config.auxtaURL + "create-empty-report", {
39
+ environment: body.environment,
40
+ digitalProductName: body.digitalProduct,
41
+ start: new Date(),
42
+ url: body.baseUrl
43
+ }, headers(token))).data.reportId;
44
+ });
45
+ }
46
+ export function uploadScenario(stepLog, scenarioName, screenshot, errMessage) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ let scenarios = [];
49
+ let token = yield auth();
50
+ let lastStep = stepLog[stepLog.length - 1];
51
+ const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
52
+ stepLogFormat.pop();
53
+ let output = (yield axios.post(config.auxtaURL + "create-scenario", {
54
+ json: {
55
+ name: scenarioName,
56
+ steps: [
57
+ ...stepLogFormat,
58
+ (lastStep.result.status == 'failed')
59
+ ? Object.assign(lastStep, {
60
+ result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
61
+ })
62
+ : lastStep,
63
+ {
64
+ keyword: "After",
65
+ result: {
66
+ status: "passed",
67
+ duration: 2678000000
68
+ },
69
+ embeddings: (screenshot) ? [{
70
+ data: screenshot.toString("base64"),
71
+ mime_type: "image/png"
72
+ }] : undefined,
73
+ }
74
+ ],
75
+ }
76
+ }, headers(token))).data.scenarios;
77
+ scenarios.push({
78
+ scenarioRef: output.scenarioRef,
79
+ name: output.name,
80
+ status: output.status,
81
+ stepsCount: output.stepsCount
82
+ });
83
+ return scenarios;
84
+ });
85
+ }
86
+ export function uploadFeature(scenarioId, scenarioName, uri, hasFailed) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ let token = yield auth();
89
+ return (yield axios.post(config.auxtaURL + "create-feature", {
90
+ json: {
91
+ name: scenarioName,
92
+ uri: uri
93
+ },
94
+ scenarios: scenarioId,
95
+ hasFailed: hasFailed
96
+ }, headers(token))).data;
97
+ });
98
+ }
99
+ export function updateReport(reportId, feature, steps, isFinal) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ let token = yield auth();
102
+ yield axios.post(config.auxtaURL + "update-inprogress-report", {
103
+ reportId: reportId,
104
+ isFinal: isFinal,
105
+ data: Object.assign({ feature: {
106
+ featureRef: feature.featureId,
107
+ name: feature.featureName,
108
+ uri: feature.featureUri,
109
+ status: feature.status,
110
+ scenariosCount: feature.scenariosCount
111
+ } }, steps)
112
+ }, headers(token));
113
+ });
114
+ }
115
+ export function getReport(reportId) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ let token = yield auth();
118
+ return (yield axios.post(config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
119
+ });
120
+ }
121
+ export function getLastDayResults() {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ let token = yield auth();
124
+ return (yield axios.get(config.auxtaURL + `get-last-day-results?url=${config.baseURL}`, headers(token))).data.results;
125
+ });
126
+ }
127
+ export function postNotifications(body) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ let token = yield auth();
130
+ yield axios.post(`${config.auxtaURL}post-notification-after-run-background`, {
131
+ environmentName: body.environment,
132
+ digitalProductName: body.digitalProduct,
133
+ organizationName: body.organization,
134
+ reportId: body.reportId,
135
+ }, headers(token));
136
+ });
137
+ }
138
+ export function postNotificationsOnFail(body) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ let token = yield auth();
141
+ yield axios.post(`${config.auxtaURL}post-notifications-after-case-fail-background`, {
142
+ environmentName: body.environment,
143
+ digitalProductName: body.digitalProduct,
144
+ organizationName: body.organization,
145
+ reportId: body.reportId,
146
+ featureName: body.featureName,
147
+ scenarioName: body.scenarioName
148
+ }, headers(token));
149
+ });
150
+ }
@@ -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,37 @@
1
+ export class Runtime {
2
+ constructor(s, e) {
3
+ this.start = s;
4
+ this.end = e;
5
+ }
6
+ calculateDuration() {
7
+ let currentTime = new Date;
8
+ let duration = currentTime.getTime() - this.start.getTime();
9
+ return duration;
10
+ }
11
+ splitAtDecimanlMinutes(time) {
12
+ let minutes = time.toFixed(2).toString().split('.');
13
+ return `${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
14
+ }
15
+ splitAtDecimanlHours(time) {
16
+ let hours = time.toFixed(2).toString().split('.');
17
+ let minutes = (Number(hours[1]) / 100 * 60).toFixed(2).toString().split('.');
18
+ return `${hours[0]}h ${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
19
+ }
20
+ formatRuntime(duration) {
21
+ if (duration / 1000 < 60)
22
+ return `${(duration / 1000).toFixed(0)}s`;
23
+ else {
24
+ if (duration / 60000 < 60)
25
+ return this.splitAtDecimanlMinutes(duration / 60000);
26
+ else
27
+ return this.splitAtDecimanlHours(duration / 3600000);
28
+ }
29
+ }
30
+ returnRuntime() {
31
+ let duration = this.formatRuntime(this.calculateDuration());
32
+ let startTime = this.start;
33
+ let endTime = this.end;
34
+ this.runtime = { duration, startTime, endTime };
35
+ return this.runtime;
36
+ }
37
+ }
@@ -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,15 @@
1
+ export class CalculateRuntime {
2
+ constructor(r) {
3
+ this.runtime = r;
4
+ this.startTimeSeconds = (this.runtime.startTime.getSeconds() < 10) ? `0${this.runtime.startTime.getSeconds()}` : `${this.runtime.startTime.getSeconds()}`;
5
+ this.startTimeMinutes = (this.runtime.startTime.getMinutes() < 10) ? `0${this.runtime.startTime.getMinutes()}` : `${this.runtime.startTime.getMinutes()}`;
6
+ this.startTimeHours = (this.runtime.startTime.getHours() < 10) ? `0${this.runtime.startTime.getHours()}` : `${this.runtime.startTime.getHours()}`;
7
+ this.startTimeDay = (this.runtime.startTime.getDate() < 10) ? `0${this.runtime.startTime.getDate()}` : `${this.runtime.startTime.getDate()}`;
8
+ this.startTimeMonth = (this.runtime.startTime.getMonth() + 1 < 10) ? `0${this.runtime.startTime.getMonth() + 1}` : `${this.runtime.startTime.getMonth() + 1}`;
9
+ this.endTimeSeconds = (this.runtime.endTime.getSeconds() < 10) ? `0${this.runtime.endTime.getSeconds()}` : `${this.runtime.endTime.getSeconds()}`;
10
+ this.endTimeMinutes = (this.runtime.endTime.getMinutes() < 10) ? `0${this.runtime.endTime.getMinutes()}` : `${this.runtime.endTime.getMinutes()}`;
11
+ this.endTimeHours = (this.runtime.endTime.getHours() < 10) ? `0${this.runtime.endTime.getHours()}` : `${this.runtime.endTime.getHours()}`;
12
+ this.endTimeDay = (this.runtime.endTime.getDate() < 10) ? `0${this.runtime.endTime.getDate()}` : `${this.runtime.endTime.getDate()}`;
13
+ this.endTimeMonth = (this.runtime.endTime.getMonth() + 1 < 10) ? `0${this.runtime.endTime.getMonth() + 1}` : `${this.runtime.endTime.getMonth() + 1}`;
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function captureScreenshot(): Promise<Buffer | undefined>;
@@ -0,0 +1,29 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import puppeteer from "../../puppeteer/puppeteer";
11
+ export function captureScreenshot() {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const pages = yield puppeteer.defaultPage.browser().pages();
15
+ if (!pages.length)
16
+ return undefined;
17
+ const lastPage = pages[pages.length - 1] || puppeteer.defaultPage;
18
+ const screenshotBuffer = yield lastPage.screenshot({
19
+ fullPage: true,
20
+ encoding: 'binary'
21
+ });
22
+ if (Buffer.isBuffer(screenshotBuffer))
23
+ return screenshotBuffer;
24
+ }
25
+ catch (e) {
26
+ }
27
+ return undefined;
28
+ });
29
+ }
@@ -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,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export function startSuite(suites, reportId) {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ if (suites.length === 0)
13
+ return {};
14
+ const next = suites.shift();
15
+ return { nextSuites: suites, reportId: reportId, currentSuite: next, retries: "0" };
16
+ });
17
+ }
18
+ export function retrySuite(suites, reportId, currentSuite, retries) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ console.log('I repeat again the current suite: ' + currentSuite);
21
+ if (retries >= 2) {
22
+ return false;
23
+ }
24
+ return { nextSuites: suites, reportId: reportId, currentSuite: currentSuite, retries: retries };
25
+ });
26
+ }
@@ -0,0 +1,7 @@
1
+ export declare class Aux2faAuth {
2
+ authenticator(): any;
3
+ verifyToken(token: string): boolean;
4
+ private getSecret;
5
+ }
6
+ declare const _default: Aux2faAuth;
7
+ export default _default;
@@ -0,0 +1,25 @@
1
+ const twofactor = require("node-2fa");
2
+ export class Aux2faAuth {
3
+ authenticator() {
4
+ const aux2fe_secret = this.getSecret();
5
+ return twofactor.generateToken(aux2fe_secret).token;
6
+ }
7
+ verifyToken(token) {
8
+ const aux2fe_secret = this.getSecret();
9
+ const result = twofactor.verifyToken(aux2fe_secret, token);
10
+ if (result != null) {
11
+ if (result.delta == 0) {
12
+ return true;
13
+ }
14
+ }
15
+ return false;
16
+ }
17
+ getSecret() {
18
+ const aux2fe_secret = process.env.aux2fe_secret;
19
+ if (!aux2fe_secret) {
20
+ throw new Error('No 2fe secret set');
21
+ }
22
+ return aux2fe_secret;
23
+ }
24
+ }
25
+ export 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;