@auxcode/auxta 1.3.45-beta.0 → 1.3.45-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/AuxTA.d.ts +62 -0
- package/build/cjs/AuxTA.js +154 -0
- package/build/cjs/auxta/configs/config.d.ts +57 -0
- package/build/cjs/auxta/configs/config.js +69 -0
- package/build/cjs/auxta/enums/status-of.step.d.ts +7 -0
- package/build/cjs/auxta/enums/status-of.step.js +11 -0
- package/build/cjs/auxta/helpers/response.helper.d.ts +10 -0
- package/build/cjs/auxta/helpers/response.helper.js +15 -0
- package/build/cjs/auxta/helpers/start.helper.d.ts +1 -0
- package/build/cjs/auxta/helpers/start.helper.js +26 -0
- package/build/cjs/auxta/hooks/report.hook.d.ts +14 -0
- package/build/cjs/auxta/hooks/report.hook.js +67 -0
- package/build/cjs/auxta/models/upload.model.d.ts +35 -0
- package/build/cjs/auxta/models/upload.model.js +82 -0
- package/build/cjs/auxta/services/log.service.d.ts +30 -0
- package/build/cjs/auxta/services/log.service.js +60 -0
- package/build/cjs/auxta/services/report.service.d.ts +30 -0
- package/build/cjs/auxta/services/report.service.js +168 -0
- package/build/cjs/auxta/services/runtime.service.d.ts +16 -0
- package/build/cjs/auxta/services/runtime.service.js +41 -0
- package/build/cjs/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/cjs/auxta/utilities/runtime.helper.js +19 -0
- package/build/cjs/auxta/utilities/screenshot.helper.d.ts +4 -0
- package/build/cjs/auxta/utilities/screenshot.helper.js +57 -0
- package/build/cjs/auxta/utilities/start-suite.helper.d.ts +17 -0
- package/build/cjs/auxta/utilities/start-suite.helper.js +31 -0
- package/build/cjs/macros/helpers/Aux2faAuth.d.ts +7 -0
- package/build/cjs/macros/helpers/Aux2faAuth.js +29 -0
- package/build/cjs/macros/helpers/AuxGoogleAuth.d.ts +17 -0
- package/build/cjs/macros/helpers/AuxGoogleAuth.js +104 -0
- package/build/cjs/macros/helpers/code.helper.d.ts +22 -0
- package/build/cjs/macros/helpers/code.helper.js +210 -0
- package/build/cjs/macros/helpers/emailHelper.d.ts +19 -0
- package/build/cjs/macros/helpers/emailHelper.js +177 -0
- package/build/cjs/macros/helpers/extend-default-page.d.ts +6 -0
- package/build/cjs/macros/helpers/extend-default-page.js +89 -0
- package/build/cjs/puppeteer/puppeteer.d.ts +25 -0
- package/build/cjs/puppeteer/puppeteer.js +210 -0
- package/build/esm/AuxTA.d.ts +62 -0
- package/build/esm/AuxTA.js +125 -0
- package/build/esm/auxta/configs/config.d.ts +57 -0
- package/build/esm/auxta/configs/config.js +64 -0
- package/build/esm/auxta/enums/status-of.step.d.ts +7 -0
- package/build/esm/auxta/enums/status-of.step.js +8 -0
- package/build/esm/auxta/helpers/response.helper.d.ts +10 -0
- package/build/esm/auxta/helpers/response.helper.js +11 -0
- package/build/esm/auxta/helpers/start.helper.d.ts +1 -0
- package/build/esm/auxta/helpers/start.helper.js +24 -0
- package/build/esm/auxta/hooks/report.hook.d.ts +14 -0
- package/build/esm/auxta/hooks/report.hook.js +59 -0
- package/build/esm/auxta/models/upload.model.d.ts +35 -0
- package/build/esm/auxta/models/upload.model.js +78 -0
- package/build/esm/auxta/services/log.service.d.ts +30 -0
- package/build/esm/auxta/services/log.service.js +56 -0
- package/build/esm/auxta/services/report.service.d.ts +30 -0
- package/build/esm/auxta/services/report.service.js +154 -0
- package/build/esm/auxta/services/runtime.service.d.ts +16 -0
- package/build/esm/auxta/services/runtime.service.js +37 -0
- package/build/esm/auxta/utilities/runtime.helper.d.ts +15 -0
- package/build/esm/auxta/utilities/runtime.helper.js +15 -0
- package/build/esm/auxta/utilities/screenshot.helper.d.ts +4 -0
- package/build/esm/auxta/utilities/screenshot.helper.js +49 -0
- package/build/esm/auxta/utilities/start-suite.helper.d.ts +17 -0
- package/build/esm/auxta/utilities/start-suite.helper.js +26 -0
- package/build/esm/macros/helpers/Aux2faAuth.d.ts +7 -0
- package/build/esm/macros/helpers/Aux2faAuth.js +25 -0
- package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +17 -0
- package/build/esm/macros/helpers/AuxGoogleAuth.js +100 -0
- package/build/esm/macros/helpers/code.helper.d.ts +22 -0
- package/build/esm/macros/helpers/code.helper.js +203 -0
- package/build/esm/macros/helpers/emailHelper.d.ts +19 -0
- package/build/esm/macros/helpers/emailHelper.js +170 -0
- package/build/esm/macros/helpers/extend-default-page.d.ts +6 -0
- package/build/esm/macros/helpers/extend-default-page.js +82 -0
- package/build/esm/puppeteer/puppeteer.d.ts +25 -0
- package/build/esm/puppeteer/puppeteer.js +202 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,210 @@
|
|
|
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.Puppeteer = void 0;
|
|
16
|
+
const log_service_1 = __importDefault(require("../auxta/services/log.service"));
|
|
17
|
+
const screenshot_helper_1 = require("../auxta/utilities/screenshot.helper");
|
|
18
|
+
const report_hook_1 = require("../auxta/hooks/report.hook");
|
|
19
|
+
const AuxTA_1 = __importDefault(require("../AuxTA"));
|
|
20
|
+
const status_of_step_1 = require("../auxta/enums/status-of.step");
|
|
21
|
+
const config_1 = require("../auxta/configs/config");
|
|
22
|
+
const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
|
|
23
|
+
const report_service_1 = require("../auxta/services/report.service");
|
|
24
|
+
const puppeteer = require("puppeteer");
|
|
25
|
+
class Puppeteer {
|
|
26
|
+
startBrowser() {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
let args = [
|
|
29
|
+
'--start-maximized'
|
|
30
|
+
];
|
|
31
|
+
let env = {};
|
|
32
|
+
if (process.env.ENVIRONMENT != 'LOCAL') {
|
|
33
|
+
args.push(`--window-size=${config_1.config.screenWidth},${config_1.config.screenHeight}`);
|
|
34
|
+
args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
|
|
35
|
+
env = {
|
|
36
|
+
DISPLAY: ":10.0"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
this.browser = yield puppeteer.launch({
|
|
40
|
+
slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
|
|
41
|
+
executablePath: puppeteer.executablePath(),
|
|
42
|
+
args,
|
|
43
|
+
env,
|
|
44
|
+
ignoreDefaultArgs: ["--enable-automation"],
|
|
45
|
+
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
|
46
|
+
width: config_1.config.screenWidth,
|
|
47
|
+
height: config_1.config.screenHeight
|
|
48
|
+
},
|
|
49
|
+
headless: process.env.ENVIRONMENT === 'LOCAL' ? process.env.headless === 'true' : true
|
|
50
|
+
});
|
|
51
|
+
this.defaultPage = (yield this.browser.pages())[0];
|
|
52
|
+
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
|
53
|
+
yield this.defaultPage.goto(config_1.config.baseURL, { waitUntil: 'networkidle0' });
|
|
54
|
+
yield this.defaultPage.waitForNetworkIdle();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
close() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (this.browser) {
|
|
60
|
+
let pages = yield this.browser.pages();
|
|
61
|
+
yield Promise.all(pages.map((page) => page.close()));
|
|
62
|
+
yield this.browser.close();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
run(event, callback, featureName = 'Test feature', scenarioName = 'Test scenario', uploadModel) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
let close;
|
|
69
|
+
try {
|
|
70
|
+
if (uploadModel === undefined) {
|
|
71
|
+
uploadModel = AuxTA_1.default.getUploadModel();
|
|
72
|
+
uploadModel.featureName = featureName;
|
|
73
|
+
uploadModel.scenarioName = scenarioName;
|
|
74
|
+
}
|
|
75
|
+
if (event.close === undefined)
|
|
76
|
+
close = Puppeteer.setupHeader(event, uploadModel);
|
|
77
|
+
let screenshotBuffer;
|
|
78
|
+
let errMessage;
|
|
79
|
+
let statusCode = 200;
|
|
80
|
+
let consoleMessage = [];
|
|
81
|
+
let httpsMessage = [];
|
|
82
|
+
try {
|
|
83
|
+
log_service_1.default.push('When', `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
84
|
+
yield this.startBrowser();
|
|
85
|
+
this.defaultPage.on('console', (message) => consoleMessage.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
86
|
+
.on('pageerror', ({ message }) => consoleMessage.push(message))
|
|
87
|
+
.on('response', (response) => httpsMessage.push(`${response.status()} ${response.url()}`))
|
|
88
|
+
.on('requestfailed', (request) => { var _a; return httpsMessage.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
89
|
+
yield callback(event);
|
|
90
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.log("Error message: \n", err);
|
|
94
|
+
let browser_start_retry = err.toString().includes("Failed to launch the browser process!");
|
|
95
|
+
const pages = yield this.defaultPage.browser().pages();
|
|
96
|
+
consoleMessage.push('pages');
|
|
97
|
+
consoleMessage.push(pages.length);
|
|
98
|
+
if (browser_start_retry) {
|
|
99
|
+
const result = yield (0, start_suite_helper_1.retrySuite)(uploadModel.nextSuites, uploadModel.reportId, uploadModel.currentSuite, uploadModel.retries);
|
|
100
|
+
if (!result) {
|
|
101
|
+
return yield (0, report_hook_1.onTestEnd)(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
102
|
+
currentPageUrl: 'undefined',
|
|
103
|
+
console: consoleMessage,
|
|
104
|
+
https: httpsMessage,
|
|
105
|
+
error: 'Browser did not open'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return { statusCode: 204 };
|
|
109
|
+
}
|
|
110
|
+
errMessage = err;
|
|
111
|
+
statusCode = 500;
|
|
112
|
+
screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshot)();
|
|
113
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
114
|
+
yield (0, report_service_1.postNotificationsOnFail)(uploadModel);
|
|
115
|
+
}
|
|
116
|
+
let url = this.defaultPage.url();
|
|
117
|
+
if (close)
|
|
118
|
+
yield this.close();
|
|
119
|
+
return yield (0, report_hook_1.onTestEnd)(uploadModel, featureName, scenarioName, statusCode, screenshotBuffer, !errMessage ? undefined : {
|
|
120
|
+
currentPageUrl: url,
|
|
121
|
+
console: consoleMessage,
|
|
122
|
+
https: httpsMessage,
|
|
123
|
+
error: errMessage
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
console.log("Lib error:", e);
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
log_service_1.default.clear();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
runRPA(event, callback, uploadModel, close) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
let errMessage;
|
|
137
|
+
try {
|
|
138
|
+
if (uploadModel === undefined)
|
|
139
|
+
uploadModel = AuxTA_1.default.getUploadModel();
|
|
140
|
+
if (close === undefined) {
|
|
141
|
+
try {
|
|
142
|
+
if (event.close) {
|
|
143
|
+
close = event.close === "true";
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
close = true;
|
|
147
|
+
}
|
|
148
|
+
if (event.retries) {
|
|
149
|
+
uploadModel.retries = Number(event.retries);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
close = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
let consoleStack = [];
|
|
157
|
+
try {
|
|
158
|
+
yield log_service_1.default.push('When', `Starting puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
159
|
+
yield this.startBrowser();
|
|
160
|
+
this.defaultPage.on('console', (message) => consoleStack.push(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`))
|
|
161
|
+
.on('pageerror', ({ message }) => consoleStack.push(message))
|
|
162
|
+
.on('response', (response) => consoleStack.push(`${response.status()} ${response.url()}`))
|
|
163
|
+
.on('requestfailed', (request) => { var _a; return consoleStack.push(`${request.failure() !== null ? (_a = request.failure()) === null || _a === void 0 ? void 0 : _a.errorText : ""} ${request.url()}`); });
|
|
164
|
+
yield callback(event);
|
|
165
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.PASSED);
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
console.log("Error message: \n", err);
|
|
169
|
+
let browser_start_retry = err.toString().includes("Failed to launch the browser process!");
|
|
170
|
+
if (browser_start_retry) {
|
|
171
|
+
yield (0, start_suite_helper_1.retrySuite)([], '', uploadModel.currentSuite, uploadModel.retries);
|
|
172
|
+
return { statusCode: 204 };
|
|
173
|
+
}
|
|
174
|
+
errMessage = err;
|
|
175
|
+
log_service_1.default.push('When', `Finished puppeteer process`, status_of_step_1.StatusOfStep.FAILED);
|
|
176
|
+
return errMessage;
|
|
177
|
+
}
|
|
178
|
+
if (close)
|
|
179
|
+
yield this.close();
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
console.log("Lib error:", e);
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
log_service_1.default.clear();
|
|
186
|
+
}
|
|
187
|
+
return { statusCode: 200 };
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
static setupHeader(event, uploadModel) {
|
|
191
|
+
let close = true;
|
|
192
|
+
if (process.env.ENVIRONMENT !== 'LOCAL' && event) {
|
|
193
|
+
uploadModel.reportId = event.reportId;
|
|
194
|
+
uploadModel.nextSuites = event.nextSuites;
|
|
195
|
+
uploadModel.currentSuite = event.currentSuite;
|
|
196
|
+
uploadModel.retries = Number(event.retries);
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
if (event.close) {
|
|
200
|
+
close = event.close === "true";
|
|
201
|
+
}
|
|
202
|
+
return close;
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.Puppeteer = Puppeteer;
|
|
210
|
+
exports.default = new Puppeteer();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Puppeteer } from "./puppeteer/puppeteer";
|
|
2
|
+
import { FunctionHelper } from "./macros/helpers/code.helper";
|
|
3
|
+
import StatusOfStep from "./auxta/enums/status-of.step";
|
|
4
|
+
import { UploadModel } from "./auxta/models/upload.model";
|
|
5
|
+
import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
|
|
6
|
+
declare class AuxTA extends FunctionHelper {
|
|
7
|
+
puppeteer: Puppeteer;
|
|
8
|
+
aux2fa: import("./macros/helpers/Aux2faAuth").Aux2faAuth;
|
|
9
|
+
google: typeof AuxGoogleAuth;
|
|
10
|
+
config: {
|
|
11
|
+
auxtaURL: string;
|
|
12
|
+
baseURL: string;
|
|
13
|
+
siteURL: string;
|
|
14
|
+
organization: string;
|
|
15
|
+
netlifyPath: string;
|
|
16
|
+
digitalProduct: string;
|
|
17
|
+
bucket: string;
|
|
18
|
+
token: string;
|
|
19
|
+
screenWidth: number;
|
|
20
|
+
screenHeight: number;
|
|
21
|
+
timeout: number;
|
|
22
|
+
suitesList: never[];
|
|
23
|
+
googleEmail: string;
|
|
24
|
+
auxtaCredentials: {
|
|
25
|
+
email: string;
|
|
26
|
+
password: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
email: import("./macros/helpers/emailHelper").EmailHelper;
|
|
30
|
+
private readonly uploadModel;
|
|
31
|
+
constructor();
|
|
32
|
+
run(event: any, overrideConfig?: any): Promise<{
|
|
33
|
+
nextSuites?: undefined;
|
|
34
|
+
reportId?: undefined;
|
|
35
|
+
currentSuite?: undefined;
|
|
36
|
+
retries?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
nextSuites: string[];
|
|
39
|
+
reportId: string | undefined;
|
|
40
|
+
currentSuite: string | undefined;
|
|
41
|
+
retries: string;
|
|
42
|
+
}>;
|
|
43
|
+
private changeModelData;
|
|
44
|
+
startBrowser(event: any, callback: any, feature: string, scenario: string, overrideConfig?: any, singleFeature?: boolean, fileName?: string): Promise<{
|
|
45
|
+
nextSuites?: undefined;
|
|
46
|
+
reportId?: undefined;
|
|
47
|
+
currentSuite?: undefined;
|
|
48
|
+
retries?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
nextSuites: string[];
|
|
51
|
+
reportId: string | undefined;
|
|
52
|
+
currentSuite: string | undefined;
|
|
53
|
+
retries: string;
|
|
54
|
+
} | {
|
|
55
|
+
statusCode: number;
|
|
56
|
+
} | undefined>;
|
|
57
|
+
startBrowserRPA(event: any, callback: any, baseURL: string, fileName?: string): Promise<any>;
|
|
58
|
+
getUploadModel(): UploadModel;
|
|
59
|
+
}
|
|
60
|
+
export declare const StepStatus: typeof StatusOfStep;
|
|
61
|
+
declare const auxta: AuxTA;
|
|
62
|
+
export default auxta;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 { FunctionHelper } from "./macros/helpers/code.helper";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import StatusOfStep from "./auxta/enums/status-of.step";
|
|
15
|
+
import { UploadModel } from "./auxta/models/upload.model";
|
|
16
|
+
import * as dotenv from "dotenv";
|
|
17
|
+
import { setupConfig, config as c, setupOverrideConfig } from "./auxta/configs/config";
|
|
18
|
+
import { startSuite } from "./auxta/utilities/start-suite.helper";
|
|
19
|
+
import { createEmptyReport } from "./auxta/services/report.service";
|
|
20
|
+
import Aux2faAuth from "./macros/helpers/Aux2faAuth";
|
|
21
|
+
import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
|
|
22
|
+
import emailHelper from "./macros/helpers/emailHelper";
|
|
23
|
+
dotenv.config();
|
|
24
|
+
class AuxTA extends FunctionHelper {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this.puppeteer = puppeteer;
|
|
28
|
+
this.aux2fa = Aux2faAuth;
|
|
29
|
+
this.google = AuxGoogleAuth;
|
|
30
|
+
this.config = c;
|
|
31
|
+
this.email = emailHelper;
|
|
32
|
+
let file;
|
|
33
|
+
if (!process.env.RPA) {
|
|
34
|
+
try {
|
|
35
|
+
let currentDir = "";
|
|
36
|
+
while (true) {
|
|
37
|
+
file = path.join(__dirname, currentDir, "auxta.json");
|
|
38
|
+
if (!fs.existsSync(file)) {
|
|
39
|
+
currentDir += "../";
|
|
40
|
+
if (currentDir.length >= 30) {
|
|
41
|
+
console.log("auxta.json file not found!");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
const jsonConfig = JSON.parse(fs.readFileSync(file).toString());
|
|
50
|
+
try {
|
|
51
|
+
this.config = setupConfig(jsonConfig);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.log("Missing field in auxta.json:", e);
|
|
55
|
+
}
|
|
56
|
+
this.uploadModel = new UploadModel(jsonConfig.organization, jsonConfig.baseURL, jsonConfig.digitalProduct, jsonConfig.environment, jsonConfig.bucket);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
console.log("Missing or corrupted config: auxta.json. Searching in location:", file);
|
|
60
|
+
console.log(e);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.uploadModel = new UploadModel('', '', '', '', '');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
run(event, overrideConfig) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
this.changeModelData(overrideConfig);
|
|
71
|
+
let reportId;
|
|
72
|
+
try {
|
|
73
|
+
if (event.reportId) {
|
|
74
|
+
reportId = event.reportId;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
reportId = undefined;
|
|
79
|
+
}
|
|
80
|
+
const suites = this.config.suitesList.slice(0);
|
|
81
|
+
return startSuite(suites, reportId || (yield createEmptyReport(this.uploadModel)));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
changeModelData(overrideConfig) {
|
|
85
|
+
if (overrideConfig) {
|
|
86
|
+
if (overrideConfig.digitalProduct)
|
|
87
|
+
this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
|
|
88
|
+
if (overrideConfig.environment)
|
|
89
|
+
this.uploadModel.environment = overrideConfig.environment;
|
|
90
|
+
if (overrideConfig.baseURL)
|
|
91
|
+
this.uploadModel.baseUrl = overrideConfig.baseURL;
|
|
92
|
+
if (overrideConfig.bucket)
|
|
93
|
+
this.uploadModel.bucket = overrideConfig.bucket;
|
|
94
|
+
this.config = setupOverrideConfig(overrideConfig);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false, fileName = '') {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
this.changeModelData(overrideConfig);
|
|
100
|
+
if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
|
|
101
|
+
this.uploadModel.reportId = yield createEmptyReport(this.uploadModel);
|
|
102
|
+
this.uploadModel.currentSuite = fileName;
|
|
103
|
+
this.uploadModel.nextSuites = [];
|
|
104
|
+
}
|
|
105
|
+
return this.puppeteer.run(event, callback, feature, scenario);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
startBrowserRPA(event, callback, baseURL, fileName = '') {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
this.changeModelData({
|
|
111
|
+
baseURL: baseURL,
|
|
112
|
+
environment: '',
|
|
113
|
+
digitalProduct: ''
|
|
114
|
+
});
|
|
115
|
+
this.uploadModel.currentSuite = fileName;
|
|
116
|
+
return this.puppeteer.runRPA(event, callback);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
getUploadModel() {
|
|
120
|
+
return this.uploadModel;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export const StepStatus = StatusOfStep;
|
|
124
|
+
const auxta = new AuxTA();
|
|
125
|
+
export default auxta;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare function setupConfig(jsonConfig: any): {
|
|
2
|
+
auxtaURL: string;
|
|
3
|
+
baseURL: string;
|
|
4
|
+
siteURL: string;
|
|
5
|
+
organization: string;
|
|
6
|
+
netlifyPath: string;
|
|
7
|
+
digitalProduct: string;
|
|
8
|
+
bucket: string;
|
|
9
|
+
token: string;
|
|
10
|
+
screenWidth: number;
|
|
11
|
+
screenHeight: number;
|
|
12
|
+
timeout: number;
|
|
13
|
+
suitesList: never[];
|
|
14
|
+
googleEmail: string;
|
|
15
|
+
auxtaCredentials: {
|
|
16
|
+
email: string;
|
|
17
|
+
password: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function setupOverrideConfig(overrideConfig: any): {
|
|
21
|
+
auxtaURL: string;
|
|
22
|
+
baseURL: string;
|
|
23
|
+
siteURL: string;
|
|
24
|
+
organization: string;
|
|
25
|
+
netlifyPath: string;
|
|
26
|
+
digitalProduct: string;
|
|
27
|
+
bucket: string;
|
|
28
|
+
token: string;
|
|
29
|
+
screenWidth: number;
|
|
30
|
+
screenHeight: number;
|
|
31
|
+
timeout: number;
|
|
32
|
+
suitesList: never[];
|
|
33
|
+
googleEmail: string;
|
|
34
|
+
auxtaCredentials: {
|
|
35
|
+
email: string;
|
|
36
|
+
password: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare let config: {
|
|
40
|
+
auxtaURL: string;
|
|
41
|
+
baseURL: string;
|
|
42
|
+
siteURL: string;
|
|
43
|
+
organization: string;
|
|
44
|
+
netlifyPath: string;
|
|
45
|
+
digitalProduct: string;
|
|
46
|
+
bucket: string;
|
|
47
|
+
token: string;
|
|
48
|
+
screenWidth: number;
|
|
49
|
+
screenHeight: number;
|
|
50
|
+
timeout: number;
|
|
51
|
+
suitesList: never[];
|
|
52
|
+
googleEmail: string;
|
|
53
|
+
auxtaCredentials: {
|
|
54
|
+
email: string;
|
|
55
|
+
password: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function setupConfig(jsonConfig) {
|
|
2
|
+
if (!jsonConfig.baseURL)
|
|
3
|
+
throw new Error("baseURL");
|
|
4
|
+
config.baseURL = jsonConfig.baseURL;
|
|
5
|
+
if (!jsonConfig.digitalProduct)
|
|
6
|
+
throw new Error("digitalProduct");
|
|
7
|
+
config.digitalProduct = jsonConfig.digitalProduct;
|
|
8
|
+
if (!jsonConfig.testsURL)
|
|
9
|
+
throw new Error("testsURL");
|
|
10
|
+
config.bucket = jsonConfig.bucket;
|
|
11
|
+
if (!jsonConfig.testsURL)
|
|
12
|
+
throw new Error("testsURL");
|
|
13
|
+
config.netlifyPath = (process.env.ENVIRONMENT == 'LOCAL') ? 'http://localhost:9999/' : jsonConfig.testsURL;
|
|
14
|
+
if (!jsonConfig.organization)
|
|
15
|
+
throw new Error("organization");
|
|
16
|
+
config.organization = jsonConfig.organization;
|
|
17
|
+
if (!jsonConfig.email)
|
|
18
|
+
throw new Error("email");
|
|
19
|
+
config.auxtaCredentials.email = jsonConfig.email;
|
|
20
|
+
if (!process.env.auxta_password)
|
|
21
|
+
throw new Error("password");
|
|
22
|
+
config.auxtaCredentials.password = process.env.auxta_password;
|
|
23
|
+
if (!jsonConfig.suitesList)
|
|
24
|
+
throw new Error("suitesList");
|
|
25
|
+
config.suitesList = jsonConfig.suitesList;
|
|
26
|
+
config.googleEmail = jsonConfig.googleEmail;
|
|
27
|
+
if (jsonConfig.timeout)
|
|
28
|
+
config.timeout = jsonConfig.timeout;
|
|
29
|
+
if (jsonConfig.screenWidth)
|
|
30
|
+
config.screenWidth = jsonConfig.screenWidth;
|
|
31
|
+
if (jsonConfig.screenHeight)
|
|
32
|
+
config.screenHeight = jsonConfig.screenHeight;
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
export function setupOverrideConfig(overrideConfig) {
|
|
36
|
+
if (overrideConfig.baseURL)
|
|
37
|
+
config.baseURL = overrideConfig.baseURL;
|
|
38
|
+
if (overrideConfig.digitalProduct)
|
|
39
|
+
config.digitalProduct = overrideConfig.digitalProduct;
|
|
40
|
+
if (overrideConfig.screenWidth)
|
|
41
|
+
config.screenWidth = overrideConfig.screenWidth;
|
|
42
|
+
if (overrideConfig.screenHeight)
|
|
43
|
+
config.screenHeight = overrideConfig.screenHeight;
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
export let config = {
|
|
47
|
+
auxtaURL: "http://localhost:8888/.netlify/functions/",
|
|
48
|
+
baseURL: "",
|
|
49
|
+
siteURL: "",
|
|
50
|
+
organization: "",
|
|
51
|
+
netlifyPath: "",
|
|
52
|
+
digitalProduct: "",
|
|
53
|
+
bucket: "",
|
|
54
|
+
token: "",
|
|
55
|
+
screenWidth: 1920,
|
|
56
|
+
screenHeight: 1080,
|
|
57
|
+
timeout: 60000,
|
|
58
|
+
suitesList: [],
|
|
59
|
+
googleEmail: "",
|
|
60
|
+
auxtaCredentials: {
|
|
61
|
+
email: "",
|
|
62
|
+
password: "",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var StatusOfStep;
|
|
2
|
+
(function (StatusOfStep) {
|
|
3
|
+
StatusOfStep["PASSED"] = "passed";
|
|
4
|
+
StatusOfStep["FAILED"] = "failed";
|
|
5
|
+
StatusOfStep["SKIPPED"] = "skipped";
|
|
6
|
+
StatusOfStep["SUGGESTION"] = "suggestion";
|
|
7
|
+
})(StatusOfStep || (StatusOfStep = {}));
|
|
8
|
+
export default StatusOfStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { join } from 'path';
|
|
11
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const r = /^--params\.suite=(.*)$/g;
|
|
13
|
+
let suite = process.argv.find(el => !!el.match(r));
|
|
14
|
+
if (!suite)
|
|
15
|
+
throw `Locale is undefined`;
|
|
16
|
+
let suites = suite.replace('--params.suite=', '');
|
|
17
|
+
let suitesArr = suites.split(',');
|
|
18
|
+
if (!suitesArr)
|
|
19
|
+
suitesArr = [suites];
|
|
20
|
+
for (const suite of suitesArr) {
|
|
21
|
+
let f = require(join(process.cwd(), 'build', 'functions', 'controllers', suite));
|
|
22
|
+
yield f.handler();
|
|
23
|
+
}
|
|
24
|
+
}))();
|
|
@@ -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,59 @@
|
|
|
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, uploadScenario, uploadStep } 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 stepRes = yield uploadStep(stepsArr, scenarioName, screenshotBuffer, errMessage);
|
|
23
|
+
const scenarioRes = yield uploadScenario(stepRes, featureName, basename(__filename), (statusCode != 200));
|
|
24
|
+
const scenario = {
|
|
25
|
+
scenarioId: scenarioRes.scenarioRef,
|
|
26
|
+
scenarioName: scenarioRes.name,
|
|
27
|
+
scenarioUri: scenarioRes.uri,
|
|
28
|
+
status: scenarioRes.status,
|
|
29
|
+
scenariosCount: scenarioRes.scenariosCount,
|
|
30
|
+
lastFiveStepsHash: scenarioRes.lastFiveStepsHash
|
|
31
|
+
};
|
|
32
|
+
const stepCounts = {
|
|
33
|
+
failedSteps: log.getStatusCount(StatusOfStep.FAILED),
|
|
34
|
+
passedSteps: log.getStatusCount(StatusOfStep.PASSED),
|
|
35
|
+
skippedSteps: log.getStatusCount(StatusOfStep.SKIPPED),
|
|
36
|
+
suggestedSteps: log.getStatusCount(StatusOfStep.SUGGESTION)
|
|
37
|
+
};
|
|
38
|
+
isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
|
|
39
|
+
yield updateReport(body.reportId, scenario, stepCounts, isFinal);
|
|
40
|
+
console.log('--- Finished uploading report data to AUXTA ---');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log('--- Failed to update report in AUXTA ---');
|
|
44
|
+
console.log(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isFinal)
|
|
48
|
+
yield afterComplete(body);
|
|
49
|
+
else if (body && body.nextSuites) {
|
|
50
|
+
return yield startSuite(body.nextSuites, body.reportId);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function afterComplete(body) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (process.env.ENVIRONMENT == "LIVE")
|
|
57
|
+
yield postNotifications(body);
|
|
58
|
+
});
|
|
59
|
+
}
|