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