@auxcode/auxta 1.3.51-beta.15 → 1.3.51-beta.16
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/package.json +2 -3
- package/build/esm/AuxTA.d.ts +0 -62
- package/build/esm/AuxTA.js +0 -125
- package/build/esm/auxta/configs/config.d.ts +0 -57
- package/build/esm/auxta/configs/config.js +0 -64
- package/build/esm/auxta/enums/status-of.step.d.ts +0 -7
- package/build/esm/auxta/enums/status-of.step.js +0 -8
- package/build/esm/auxta/helpers/response.helper.d.ts +0 -10
- package/build/esm/auxta/helpers/response.helper.js +0 -11
- package/build/esm/auxta/helpers/start.helper.d.ts +0 -1
- package/build/esm/auxta/helpers/start.helper.js +0 -24
- package/build/esm/auxta/hooks/report.hook.d.ts +0 -14
- package/build/esm/auxta/hooks/report.hook.js +0 -59
- package/build/esm/auxta/models/upload.model.d.ts +0 -35
- package/build/esm/auxta/models/upload.model.js +0 -78
- package/build/esm/auxta/services/log.service.d.ts +0 -31
- package/build/esm/auxta/services/log.service.js +0 -57
- package/build/esm/auxta/services/report.service.d.ts +0 -31
- package/build/esm/auxta/services/report.service.js +0 -168
- package/build/esm/auxta/services/runtime.service.d.ts +0 -16
- package/build/esm/auxta/services/runtime.service.js +0 -37
- package/build/esm/auxta/utilities/runtime.helper.d.ts +0 -15
- package/build/esm/auxta/utilities/runtime.helper.js +0 -15
- package/build/esm/auxta/utilities/screenshot.helper.d.ts +0 -4
- package/build/esm/auxta/utilities/screenshot.helper.js +0 -51
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +0 -17
- package/build/esm/auxta/utilities/start-suite.helper.js +0 -26
- package/build/esm/macros/helpers/Aux2faAuth.d.ts +0 -7
- package/build/esm/macros/helpers/Aux2faAuth.js +0 -25
- package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +0 -22
- package/build/esm/macros/helpers/AuxGoogleAuth.js +0 -188
- package/build/esm/macros/helpers/code.helper.d.ts +0 -23
- package/build/esm/macros/helpers/code.helper.js +0 -218
- package/build/esm/macros/helpers/emailHelper.d.ts +0 -19
- package/build/esm/macros/helpers/emailHelper.js +0 -170
- package/build/esm/macros/helpers/extend-default-page.d.ts +0 -6
- package/build/esm/macros/helpers/extend-default-page.js +0 -82
- package/build/esm/puppeteer/puppeteer.d.ts +0 -25
- package/build/esm/puppeteer/puppeteer.js +0 -205
- package/build/tsconfig-cjs.tsbuildinfo +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- /package/build/{cjs/AuxTA.d.ts → AuxTA.d.ts} +0 -0
- /package/build/{cjs/AuxTA.js → AuxTA.js} +0 -0
- /package/build/{cjs/auxta → auxta}/configs/config.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/configs/config.js +0 -0
- /package/build/{cjs/auxta → auxta}/enums/status-of.step.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/enums/status-of.step.js +0 -0
- /package/build/{cjs/auxta → auxta}/helpers/response.helper.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/helpers/response.helper.js +0 -0
- /package/build/{cjs/auxta → auxta}/helpers/start.helper.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/helpers/start.helper.js +0 -0
- /package/build/{cjs/auxta → auxta}/hooks/report.hook.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/hooks/report.hook.js +0 -0
- /package/build/{cjs/auxta → auxta}/models/upload.model.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/models/upload.model.js +0 -0
- /package/build/{cjs/auxta → auxta}/services/log.service.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/services/log.service.js +0 -0
- /package/build/{cjs/auxta → auxta}/services/report.service.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/services/report.service.js +0 -0
- /package/build/{cjs/auxta → auxta}/services/runtime.service.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/services/runtime.service.js +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/runtime.helper.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/runtime.helper.js +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/screenshot.helper.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/screenshot.helper.js +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/start-suite.helper.d.ts +0 -0
- /package/build/{cjs/auxta → auxta}/utilities/start-suite.helper.js +0 -0
- /package/build/{cjs/macros → macros}/helpers/Aux2faAuth.d.ts +0 -0
- /package/build/{cjs/macros → macros}/helpers/Aux2faAuth.js +0 -0
- /package/build/{cjs/macros → macros}/helpers/AuxGoogleAuth.d.ts +0 -0
- /package/build/{cjs/macros → macros}/helpers/AuxGoogleAuth.js +0 -0
- /package/build/{cjs/macros → macros}/helpers/code.helper.d.ts +0 -0
- /package/build/{cjs/macros → macros}/helpers/code.helper.js +0 -0
- /package/build/{cjs/macros → macros}/helpers/emailHelper.d.ts +0 -0
- /package/build/{cjs/macros → macros}/helpers/emailHelper.js +0 -0
- /package/build/{cjs/macros → macros}/helpers/extend-default-page.d.ts +0 -0
- /package/build/{cjs/macros → macros}/helpers/extend-default-page.js +0 -0
- /package/build/{cjs/puppeteer → puppeteer}/puppeteer.d.ts +0 -0
- /package/build/{cjs/puppeteer → puppeteer}/puppeteer.js +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Step } from "./log.service";
|
|
3
|
-
import { UploadModel } from "../models/upload.model";
|
|
4
|
-
export interface Scenarios {
|
|
5
|
-
scenarioId: string;
|
|
6
|
-
scenarioName: string;
|
|
7
|
-
scenarioUri: string;
|
|
8
|
-
status: string;
|
|
9
|
-
scenariosCount: number;
|
|
10
|
-
lastFiveStepsHash: number;
|
|
11
|
-
}
|
|
12
|
-
export interface Steps {
|
|
13
|
-
failedSteps: number;
|
|
14
|
-
passedSteps: number;
|
|
15
|
-
skippedSteps: number;
|
|
16
|
-
suggestedSteps: number;
|
|
17
|
-
}
|
|
18
|
-
export declare function createEmptyReport(body: any): Promise<string>;
|
|
19
|
-
export declare function uploadStep(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object): Promise<{
|
|
20
|
-
stepRef: any;
|
|
21
|
-
name: any;
|
|
22
|
-
status: any;
|
|
23
|
-
stepsCount: any;
|
|
24
|
-
}[]>;
|
|
25
|
-
export declare function uploadScenario(stepRes: any[], scenarioName: string, uri: string, hasFailed: boolean): Promise<any>;
|
|
26
|
-
export declare function updateReport(reportId: string, scenario: Scenarios, steps: Steps, isFinal: boolean): Promise<void>;
|
|
27
|
-
export declare function getReport(reportId: string): Promise<any>;
|
|
28
|
-
export declare function getLastDayResults(): Promise<any>;
|
|
29
|
-
export declare function compareScreenshots(key: string, screenshot: string): Promise<any>;
|
|
30
|
-
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
31
|
-
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|
|
@@ -1,168 +0,0 @@
|
|
|
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
|
-
digitalProductToken: body.digitalProduct,
|
|
41
|
-
bucket: body.bucket,
|
|
42
|
-
start: new Date(),
|
|
43
|
-
url: body.baseUrl
|
|
44
|
-
}, headers(token))).data.reportId;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
export function uploadStep(stepLog, scenarioName, screenshot, errMessage) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
let scenarios = [];
|
|
50
|
-
let token = yield auth();
|
|
51
|
-
let lastStep = stepLog[stepLog.length - 1];
|
|
52
|
-
const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
|
|
53
|
-
stepLogFormat.pop();
|
|
54
|
-
let output = (yield axios.post(config.auxtaURL + "create-steps", {
|
|
55
|
-
json: {
|
|
56
|
-
name: scenarioName,
|
|
57
|
-
steps: [
|
|
58
|
-
...stepLogFormat,
|
|
59
|
-
(lastStep.result.status == 'failed')
|
|
60
|
-
? Object.assign(lastStep, {
|
|
61
|
-
result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
|
|
62
|
-
})
|
|
63
|
-
: lastStep,
|
|
64
|
-
{
|
|
65
|
-
keyword: "After",
|
|
66
|
-
result: {
|
|
67
|
-
status: "passed",
|
|
68
|
-
duration: 2678000000
|
|
69
|
-
},
|
|
70
|
-
embeddings: (screenshot) ? [{
|
|
71
|
-
data: screenshot.toString("base64"),
|
|
72
|
-
mime_type: "image/png"
|
|
73
|
-
}] : undefined,
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
}
|
|
77
|
-
}, headers(token))).data.scenarios;
|
|
78
|
-
scenarios.push({
|
|
79
|
-
stepRef: output.stepRef,
|
|
80
|
-
name: output.name,
|
|
81
|
-
status: output.status,
|
|
82
|
-
stepsCount: output.stepsCount
|
|
83
|
-
});
|
|
84
|
-
return scenarios;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
export function uploadScenario(stepRes, scenarioName, uri, hasFailed) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
let token = yield auth();
|
|
90
|
-
return (yield axios.post(config.auxtaURL + "create-scenario", {
|
|
91
|
-
json: {
|
|
92
|
-
name: scenarioName,
|
|
93
|
-
uri: uri
|
|
94
|
-
},
|
|
95
|
-
scenarios: stepRes,
|
|
96
|
-
hasFailed: hasFailed
|
|
97
|
-
}, headers(token))).data;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
export function updateReport(reportId, scenario, steps, isFinal) {
|
|
101
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
let token = yield auth();
|
|
103
|
-
yield axios.post(config.auxtaURL + "update-inprogress-report", {
|
|
104
|
-
reportId: reportId,
|
|
105
|
-
isFinal: isFinal,
|
|
106
|
-
data: Object.assign({ scenario: {
|
|
107
|
-
scenarioRef: scenario.scenarioId,
|
|
108
|
-
name: scenario.scenarioName,
|
|
109
|
-
uri: scenario.scenarioUri,
|
|
110
|
-
status: scenario.status,
|
|
111
|
-
scenariosCount: scenario.scenariosCount,
|
|
112
|
-
lastFiveStepsHash: scenario.lastFiveStepsHash
|
|
113
|
-
} }, steps)
|
|
114
|
-
}, headers(token));
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
export function getReport(reportId) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
let token = yield auth();
|
|
120
|
-
return (yield axios.post(config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
export function getLastDayResults() {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
let token = yield auth();
|
|
126
|
-
return (yield axios.get(config.auxtaURL + `get-last-day-results?url=${config.baseURL}`, headers(token))).data.results;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
export function compareScreenshots(key, screenshot) {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
let token = yield auth();
|
|
132
|
-
const embedding = {
|
|
133
|
-
data: screenshot,
|
|
134
|
-
mime_type: "image/png"
|
|
135
|
-
};
|
|
136
|
-
return yield axios.post(`${config.auxtaURL}save-compared-screenshot`, {
|
|
137
|
-
organization: config.organization,
|
|
138
|
-
key: key,
|
|
139
|
-
embedding: embedding,
|
|
140
|
-
}, headers(token));
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
export function postNotifications(body) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
let token = yield auth();
|
|
146
|
-
yield axios.post(`${config.auxtaURL}post-notification-after-run-background`, {
|
|
147
|
-
environmentName: body.environment,
|
|
148
|
-
digitalProductToken: body.digitalProduct,
|
|
149
|
-
organizationName: body.organization,
|
|
150
|
-
bucketName: body.bucket,
|
|
151
|
-
reportId: body.reportId,
|
|
152
|
-
}, headers(token));
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
export function postNotificationsOnFail(body) {
|
|
156
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
let token = yield auth();
|
|
158
|
-
yield axios.post(`${config.auxtaURL}post-notifications-after-case-fail-background`, {
|
|
159
|
-
environmentName: body.environment,
|
|
160
|
-
digitalProductToken: body.digitalProduct,
|
|
161
|
-
organizationName: body.organization,
|
|
162
|
-
bucketName: body.bucket,
|
|
163
|
-
reportId: body.reportId,
|
|
164
|
-
featureName: body.featureName,
|
|
165
|
-
scenarioName: body.scenarioName
|
|
166
|
-
}, headers(token));
|
|
167
|
-
});
|
|
168
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
import log from "../services/log.service";
|
|
12
|
-
import StatusOfStep from "../enums/status-of.step";
|
|
13
|
-
export function captureScreenshot() {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
try {
|
|
16
|
-
const pages = yield puppeteer.defaultPage.browser().pages();
|
|
17
|
-
if (!pages.length)
|
|
18
|
-
return undefined;
|
|
19
|
-
const lastPage = pages[pages.length - 1] || puppeteer.defaultPage;
|
|
20
|
-
const screenshotBuffer = yield lastPage.screenshot({
|
|
21
|
-
fullPage: true,
|
|
22
|
-
captureBeyondViewport: false,
|
|
23
|
-
encoding: 'binary'
|
|
24
|
-
});
|
|
25
|
-
if (Buffer.isBuffer(screenshotBuffer))
|
|
26
|
-
return screenshotBuffer;
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
log.push('When', e.toString(), StatusOfStep.FAILED);
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export function captureScreenshotPage(page) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
try {
|
|
38
|
-
const screenshotBuffer = yield page.screenshot({
|
|
39
|
-
fullPage: true,
|
|
40
|
-
captureBeyondViewport: false,
|
|
41
|
-
encoding: 'binary'
|
|
42
|
-
});
|
|
43
|
-
if (Buffer.isBuffer(screenshotBuffer))
|
|
44
|
-
return screenshotBuffer;
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
log.push('When', e.toString(), StatusOfStep.FAILED);
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import googleType = require("googleapis");
|
|
2
|
-
export declare class AuxGoogleAuth {
|
|
3
|
-
private static _oAuth2Client;
|
|
4
|
-
private static credentialsJson;
|
|
5
|
-
static get oAuth2Client(): googleType.Auth.OAuth2Client;
|
|
6
|
-
static get googleClient(): googleType.GoogleApis;
|
|
7
|
-
static get gmailClient(): googleType.gmail_v1.Gmail;
|
|
8
|
-
static setupBrowser(): Promise<void>;
|
|
9
|
-
static setEmailPassword(email: string, password: string): Promise<void>;
|
|
10
|
-
static setupHeadless(): Promise<void>;
|
|
11
|
-
private static authorize;
|
|
12
|
-
private static authorizeHeadless;
|
|
13
|
-
private static getNewToken;
|
|
14
|
-
private static getNewTokenHeadless;
|
|
15
|
-
private static LogIn;
|
|
16
|
-
}
|
|
17
|
-
declare const _default: AuxGoogleAuth;
|
|
18
|
-
export default _default;
|
|
19
|
-
export interface currentUser {
|
|
20
|
-
name: string;
|
|
21
|
-
email: string;
|
|
22
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
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 { config } from "../../auxta/configs/config";
|
|
11
|
-
import puppeteer from "../../puppeteer/puppeteer";
|
|
12
|
-
import FunctionHelper from "../helpers/code.helper";
|
|
13
|
-
import StatusOfStep from "../../auxta/enums/status-of.step";
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const readline = require('readline');
|
|
16
|
-
const { google } = require("googleapis");
|
|
17
|
-
const SCOPES = [
|
|
18
|
-
'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
|
|
19
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.action',
|
|
20
|
-
'https://www.googleapis.com/auth/gmail.labels',
|
|
21
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
|
|
22
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
|
|
23
|
-
'https://www.googleapis.com/auth/gmail.send',
|
|
24
|
-
'https://mail.google.com/',
|
|
25
|
-
'https://www.googleapis.com/auth/gmail.modify',
|
|
26
|
-
'https://www.googleapis.com/auth/gmail.compose',
|
|
27
|
-
'https://www.googleapis.com/auth/gmail.readonly',
|
|
28
|
-
'https://www.googleapis.com/auth/gmail.insert',
|
|
29
|
-
];
|
|
30
|
-
const TOKEN_PATH = 'token.json';
|
|
31
|
-
let TOKEN = '';
|
|
32
|
-
let EMAIL = '';
|
|
33
|
-
let PASSWORD = '';
|
|
34
|
-
export class AuxGoogleAuth {
|
|
35
|
-
static get oAuth2Client() {
|
|
36
|
-
return this._oAuth2Client;
|
|
37
|
-
}
|
|
38
|
-
static get googleClient() {
|
|
39
|
-
return google;
|
|
40
|
-
}
|
|
41
|
-
static get gmailClient() {
|
|
42
|
-
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
43
|
-
}
|
|
44
|
-
static setupBrowser() {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
yield this.authorize(this.credentialsJson);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
static setEmailPassword(email, password) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
EMAIL = email;
|
|
52
|
-
PASSWORD = password;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
static setupHeadless() {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield this.authorizeHeadless(this.credentialsJson);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
static authorize(credentials) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
63
|
-
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
64
|
-
try {
|
|
65
|
-
let token = fs.readFileSync(TOKEN_PATH);
|
|
66
|
-
if (token.length > 0 && token !== undefined) {
|
|
67
|
-
oAuth2Client.setCredentials(JSON.parse(token));
|
|
68
|
-
this._oAuth2Client = oAuth2Client;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
yield this.getNewToken(oAuth2Client);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
yield this.getNewToken(oAuth2Client);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
static authorizeHeadless(credentials) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
81
|
-
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
82
|
-
try {
|
|
83
|
-
FunctionHelper.log('tes', TOKEN, StatusOfStep.PASSED);
|
|
84
|
-
if (TOKEN) {
|
|
85
|
-
oAuth2Client.setCredentials(JSON.parse(TOKEN));
|
|
86
|
-
this._oAuth2Client = oAuth2Client;
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
yield this.getNewTokenHeadless(oAuth2Client);
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
yield this.getNewTokenHeadless(oAuth2Client);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
static getNewToken(oAuth2Client) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const authUrl = oAuth2Client.generateAuthUrl({
|
|
99
|
-
access_type: 'offline',
|
|
100
|
-
prompt: 'consent',
|
|
101
|
-
scope: SCOPES,
|
|
102
|
-
});
|
|
103
|
-
console.log('Authorize this app by visiting this url:', authUrl);
|
|
104
|
-
const rl = readline.createInterface({
|
|
105
|
-
input: process.stdin,
|
|
106
|
-
output: process.stdout,
|
|
107
|
-
});
|
|
108
|
-
rl.question('Enter the code from that page here: ', (code) => {
|
|
109
|
-
rl.close();
|
|
110
|
-
oAuth2Client.getToken(code, (err, token) => {
|
|
111
|
-
if (err)
|
|
112
|
-
return console.error('Error retrieving access token', err);
|
|
113
|
-
oAuth2Client.setCredentials(token);
|
|
114
|
-
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
|
|
115
|
-
if (err)
|
|
116
|
-
return console.error(err);
|
|
117
|
-
console.log('Token stored to', TOKEN_PATH);
|
|
118
|
-
});
|
|
119
|
-
this._oAuth2Client = oAuth2Client;
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
static getNewTokenHeadless(oAuth2Client) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const authUrl = oAuth2Client.generateAuthUrl({
|
|
127
|
-
access_type: 'offline',
|
|
128
|
-
prompt: 'consent',
|
|
129
|
-
scope: SCOPES,
|
|
130
|
-
});
|
|
131
|
-
const code = yield this.LogIn(authUrl);
|
|
132
|
-
FunctionHelper.log('tes', code, StatusOfStep.PASSED);
|
|
133
|
-
oAuth2Client.getToken(code, (err, token) => {
|
|
134
|
-
if (err)
|
|
135
|
-
return console.error('Error retrieving access token', err);
|
|
136
|
-
oAuth2Client.setCredentials(token);
|
|
137
|
-
FunctionHelper.log('tes', token.toString(), StatusOfStep.PASSED);
|
|
138
|
-
TOKEN = token.toString();
|
|
139
|
-
this._oAuth2Client = oAuth2Client;
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
static LogIn(authUrl) {
|
|
144
|
-
var _a, _b;
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const context = yield puppeteer.defaultPage.browser().createIncognitoBrowserContext();
|
|
147
|
-
const page = yield context.newPage();
|
|
148
|
-
yield page.goto(authUrl);
|
|
149
|
-
yield FunctionHelper.waitForSelector('visible', '#identifierId', config.timeout, page);
|
|
150
|
-
yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(EMAIL));
|
|
151
|
-
yield (yield page.$$('button'))[3].click();
|
|
152
|
-
yield FunctionHelper.timeout(3000);
|
|
153
|
-
yield FunctionHelper.waitForSelector('visible', 'input[type="password"]', config.timeout, page);
|
|
154
|
-
yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(PASSWORD));
|
|
155
|
-
yield (yield page.$$('button'))[1].click();
|
|
156
|
-
yield FunctionHelper.timeout(3000);
|
|
157
|
-
yield FunctionHelper.waitForSelector('visible', '#headingText', config.timeout, page);
|
|
158
|
-
yield (yield page.$$('button'))[2].click();
|
|
159
|
-
yield FunctionHelper.timeout(3000);
|
|
160
|
-
const checkbox = yield page.$$('input[type="checkbox"]');
|
|
161
|
-
if (checkbox.length > 0) {
|
|
162
|
-
yield FunctionHelper.waitForSelector('visible', 'input[type="checkbox"]', config.timeout, page);
|
|
163
|
-
yield checkbox[0].click();
|
|
164
|
-
yield (yield page.$$('button'))[2].click();
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
yield (yield page.$$('button'))[2].click();
|
|
168
|
-
}
|
|
169
|
-
yield FunctionHelper.timeout(3000);
|
|
170
|
-
const currentUrl = page.url();
|
|
171
|
-
const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
|
|
172
|
-
yield page.close();
|
|
173
|
-
return decodeURIComponent(code);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
AuxGoogleAuth.credentialsJson = {
|
|
178
|
-
"installed": {
|
|
179
|
-
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
180
|
-
"project_id": "auxta-library",
|
|
181
|
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
182
|
-
"token_uri": "https://oauth2.googleapis.com/token",
|
|
183
|
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
184
|
-
"client_secret": "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",
|
|
185
|
-
"redirect_uris": ["https://auxcode.com"]
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
export default new AuxGoogleAuth();
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
|
-
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
-
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
4
|
-
log(keyword: string, name: string, status: StatusOfStep, screenshot?: string): void;
|
|
5
|
-
screenshot(page?: import("puppeteer").Page): Promise<string | undefined>;
|
|
6
|
-
screenshotCompare(key: string, page?: import("puppeteer").Page): Promise<void>;
|
|
7
|
-
suggest(name: string): void;
|
|
8
|
-
private getEscapedText;
|
|
9
|
-
clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer").Page, time?: number, log_message?: boolean): Promise<void>;
|
|
10
|
-
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<void>;
|
|
11
|
-
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<boolean>;
|
|
12
|
-
timeout(timeout?: number, page?: import("puppeteer").Page): Promise<void>;
|
|
13
|
-
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer").Page, log_message?: boolean): Promise<void>;
|
|
14
|
-
urlContains(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
15
|
-
pressEnter(page?: import("puppeteer").Page): Promise<void>;
|
|
16
|
-
emulate(phone_name: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
|
-
restartBrowser(): Promise<void>;
|
|
18
|
-
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
19
|
-
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
20
|
-
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
declare const _default: FunctionHelper;
|
|
23
|
-
export default _default;
|