@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,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.StepStatus = void 0;
|
|
35
|
+
const puppeteer_1 = __importDefault(require("./puppeteer/puppeteer"));
|
|
36
|
+
const code_helper_1 = require("./macros/helpers/code.helper");
|
|
37
|
+
const path_1 = __importDefault(require("path"));
|
|
38
|
+
const fs_1 = __importDefault(require("fs"));
|
|
39
|
+
const status_of_step_1 = __importDefault(require("./auxta/enums/status-of.step"));
|
|
40
|
+
const upload_model_1 = require("./auxta/models/upload.model");
|
|
41
|
+
const dotenv = __importStar(require("dotenv"));
|
|
42
|
+
const config_1 = require("./auxta/configs/config");
|
|
43
|
+
const start_suite_helper_1 = require("./auxta/utilities/start-suite.helper");
|
|
44
|
+
const report_service_1 = require("./auxta/services/report.service");
|
|
45
|
+
dotenv.config();
|
|
46
|
+
class AuxTA extends code_helper_1.FunctionHelper {
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.puppeteer = puppeteer_1.default;
|
|
50
|
+
this.config = config_1.config;
|
|
51
|
+
let file;
|
|
52
|
+
if (!process.env.RPA) {
|
|
53
|
+
try {
|
|
54
|
+
let currentDir = "";
|
|
55
|
+
while (true) {
|
|
56
|
+
file = path_1.default.join(__dirname, currentDir, "auxta.json");
|
|
57
|
+
if (!fs_1.default.existsSync(file)) {
|
|
58
|
+
currentDir += "../";
|
|
59
|
+
if (currentDir.length >= 30) {
|
|
60
|
+
console.log("auxta.json file not found!");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const jsonConfig = JSON.parse(fs_1.default.readFileSync(file).toString());
|
|
69
|
+
try {
|
|
70
|
+
this.config = (0, config_1.setupConfig)(jsonConfig);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.log("Missing field in auxta.json:", e);
|
|
74
|
+
}
|
|
75
|
+
this.uploadModel = new upload_model_1.UploadModel(jsonConfig.organization, jsonConfig.baseURL, jsonConfig.digitalProduct, jsonConfig.environment);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.log("Missing or corrupted config: auxta.json. Searching in location:", file);
|
|
79
|
+
console.log(e);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.uploadModel = new upload_model_1.UploadModel('', '', '', '');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
run(event, overrideConfig) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
this.changeModelData(overrideConfig);
|
|
90
|
+
let reportId = event.queryStringParameters.reportId;
|
|
91
|
+
if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
|
|
92
|
+
return { statusCode: 401, message: 'Unauthorized' };
|
|
93
|
+
const suites = this.config.suitesList.slice(0);
|
|
94
|
+
yield (0, start_suite_helper_1.startSuite)(suites, reportId || (yield (0, report_service_1.createEmptyReport)(this.uploadModel)));
|
|
95
|
+
return { statusCode: 204 };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
changeModelData(overrideConfig) {
|
|
99
|
+
if (overrideConfig) {
|
|
100
|
+
if (overrideConfig.digitalProduct)
|
|
101
|
+
this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
|
|
102
|
+
if (overrideConfig.environment)
|
|
103
|
+
this.uploadModel.environment = overrideConfig.environment;
|
|
104
|
+
if (overrideConfig.baseURL)
|
|
105
|
+
this.uploadModel.baseUrl = overrideConfig.baseURL;
|
|
106
|
+
this.config = (0, config_1.setupOverrideConfig)(overrideConfig);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
this.changeModelData(overrideConfig);
|
|
112
|
+
if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
|
|
113
|
+
if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
|
|
114
|
+
return { statusCode: 401, message: 'Unauthorized' };
|
|
115
|
+
this.uploadModel.reportId = yield (0, report_service_1.createEmptyReport)(this.uploadModel);
|
|
116
|
+
this.uploadModel.nextSuites = [];
|
|
117
|
+
}
|
|
118
|
+
return this.puppeteer.run(event, callback, feature, scenario);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
startBrowserRPA(event, callback, baseURL) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
this.changeModelData({
|
|
124
|
+
baseURL: baseURL,
|
|
125
|
+
environment: '',
|
|
126
|
+
digitalProduct: ''
|
|
127
|
+
});
|
|
128
|
+
return this.puppeteer.runRPA(event, callback);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
getUploadModel() {
|
|
132
|
+
return this.uploadModel;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.StepStatus = status_of_step_1.default;
|
|
136
|
+
const auxta = new AuxTA();
|
|
137
|
+
exports.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,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = exports.setupOverrideConfig = exports.setupConfig = void 0;
|
|
4
|
+
function setupConfig(jsonConfig) {
|
|
5
|
+
if (!jsonConfig.baseURL)
|
|
6
|
+
throw new Error("baseURL");
|
|
7
|
+
exports.config.baseURL = jsonConfig.baseURL;
|
|
8
|
+
if (!jsonConfig.digitalProduct)
|
|
9
|
+
throw new Error("digitalProduct");
|
|
10
|
+
exports.config.digitalProduct = jsonConfig.digitalProduct;
|
|
11
|
+
if (!jsonConfig.testsURL)
|
|
12
|
+
throw new Error("testsURL");
|
|
13
|
+
exports.config.netlifyPath = (process.env.ENVIRONMENT == 'LOCAL') ? 'http://localhost:9999/' : jsonConfig.testsURL;
|
|
14
|
+
if (!jsonConfig.organization)
|
|
15
|
+
throw new Error("organization");
|
|
16
|
+
exports.config.organization = jsonConfig.organization;
|
|
17
|
+
if (!jsonConfig.token)
|
|
18
|
+
throw new Error("token");
|
|
19
|
+
exports.config.token = jsonConfig.token;
|
|
20
|
+
if (!jsonConfig.email)
|
|
21
|
+
throw new Error("email");
|
|
22
|
+
exports.config.auxtaCredentials.email = jsonConfig.email;
|
|
23
|
+
if (!jsonConfig.password)
|
|
24
|
+
throw new Error("password");
|
|
25
|
+
exports.config.auxtaCredentials.password = jsonConfig.password;
|
|
26
|
+
if (!jsonConfig.suitesList)
|
|
27
|
+
throw new Error("suitesList");
|
|
28
|
+
exports.config.suitesList = jsonConfig.suitesList;
|
|
29
|
+
if (jsonConfig.timeout)
|
|
30
|
+
exports.config.timeout = jsonConfig.timeout;
|
|
31
|
+
if (jsonConfig.screenWidth)
|
|
32
|
+
exports.config.screenWidth = jsonConfig.screenWidth;
|
|
33
|
+
if (jsonConfig.screenHeight)
|
|
34
|
+
exports.config.screenHeight = jsonConfig.screenHeight;
|
|
35
|
+
return exports.config;
|
|
36
|
+
}
|
|
37
|
+
exports.setupConfig = setupConfig;
|
|
38
|
+
function setupOverrideConfig(overrideConfig) {
|
|
39
|
+
if (overrideConfig.baseURL)
|
|
40
|
+
exports.config.baseURL = overrideConfig.baseURL;
|
|
41
|
+
if (overrideConfig.digitalProduct)
|
|
42
|
+
exports.config.digitalProduct = overrideConfig.digitalProduct;
|
|
43
|
+
if (overrideConfig.screenWidth)
|
|
44
|
+
exports.config.screenWidth = overrideConfig.screenWidth;
|
|
45
|
+
if (overrideConfig.screenHeight)
|
|
46
|
+
exports.config.screenHeight = overrideConfig.screenHeight;
|
|
47
|
+
return exports.config;
|
|
48
|
+
}
|
|
49
|
+
exports.setupOverrideConfig = setupOverrideConfig;
|
|
50
|
+
exports.config = {
|
|
51
|
+
auxtaURL: "https://auxta.live/.netlify/functions/",
|
|
52
|
+
baseURL: "",
|
|
53
|
+
siteURL: "",
|
|
54
|
+
organization: "",
|
|
55
|
+
netlifyPath: "",
|
|
56
|
+
digitalProduct: "",
|
|
57
|
+
token: "",
|
|
58
|
+
screenWidth: 1920,
|
|
59
|
+
screenHeight: 1080,
|
|
60
|
+
timeout: 10000,
|
|
61
|
+
suitesList: [],
|
|
62
|
+
auxtaCredentials: {
|
|
63
|
+
email: "",
|
|
64
|
+
password: "",
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatusOfStep = void 0;
|
|
4
|
+
var StatusOfStep;
|
|
5
|
+
(function (StatusOfStep) {
|
|
6
|
+
StatusOfStep["PASSED"] = "passed";
|
|
7
|
+
StatusOfStep["FAILED"] = "failed";
|
|
8
|
+
StatusOfStep["SKIPPED"] = "skipped";
|
|
9
|
+
StatusOfStep["SUGGESTION"] = "suggestion";
|
|
10
|
+
})(StatusOfStep = exports.StatusOfStep || (exports.StatusOfStep = {}));
|
|
11
|
+
exports.default = StatusOfStep;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.returnImage = void 0;
|
|
4
|
+
function returnImage(code, screenshot) {
|
|
5
|
+
return {
|
|
6
|
+
isBase64Encoded: true,
|
|
7
|
+
statusCode: code,
|
|
8
|
+
headers: {
|
|
9
|
+
"Content-Type": "image/png",
|
|
10
|
+
"Content-Length": screenshot.length.toString()
|
|
11
|
+
},
|
|
12
|
+
body: screenshot.toString("base64")
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.returnImage = returnImage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const r = /^--params\.suite=(.*)$/g;
|
|
15
|
+
let suite = process.argv.find(el => !!el.match(r));
|
|
16
|
+
if (!suite)
|
|
17
|
+
throw `Locale is undefined`;
|
|
18
|
+
let suites = suite.replace('--params.suite=', '');
|
|
19
|
+
let suitesArr = suites.split(',');
|
|
20
|
+
if (!suitesArr)
|
|
21
|
+
suitesArr = [suites];
|
|
22
|
+
for (const suite of suitesArr) {
|
|
23
|
+
let f = require((0, path_1.join)(process.cwd(), 'build', 'functions', 'controllers', suite));
|
|
24
|
+
yield f.handler();
|
|
25
|
+
}
|
|
26
|
+
}))();
|
|
@@ -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,66 @@
|
|
|
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.afterComplete = exports.onTestEnd = void 0;
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const log_service_1 = __importDefault(require("../services/log.service"));
|
|
18
|
+
const report_service_1 = require("../services/report.service");
|
|
19
|
+
const start_suite_helper_1 = require("../utilities/start-suite.helper");
|
|
20
|
+
const status_of_step_1 = require("../enums/status-of.step");
|
|
21
|
+
function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let isFinal = false;
|
|
24
|
+
if (process.env.ENVIRONMENT == "LIVE") {
|
|
25
|
+
console.log('asc ' + errMessage);
|
|
26
|
+
console.log('--- Uploading scenario and feature for AUXTA report ---');
|
|
27
|
+
const stepsArr = log_service_1.default.returnScenarioReport();
|
|
28
|
+
try {
|
|
29
|
+
const scenarioRes = yield (0, report_service_1.uploadScenario)(stepsArr, scenarioName, screenshotBuffer, errMessage);
|
|
30
|
+
const featureRes = yield (0, report_service_1.uploadFeature)(scenarioRes, featureName, (0, path_1.basename)(__filename), (statusCode != 200));
|
|
31
|
+
const feature = {
|
|
32
|
+
featureId: featureRes.featureRef,
|
|
33
|
+
featureName: featureRes.name,
|
|
34
|
+
featureUri: featureRes.uri,
|
|
35
|
+
status: featureRes.status,
|
|
36
|
+
scenariosCount: featureRes.scenariosCount
|
|
37
|
+
};
|
|
38
|
+
const stepCounts = {
|
|
39
|
+
failedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.FAILED),
|
|
40
|
+
passedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.PASSED),
|
|
41
|
+
skippedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SKIPPED),
|
|
42
|
+
suggestedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SUGGESTION)
|
|
43
|
+
};
|
|
44
|
+
isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
|
|
45
|
+
yield (0, report_service_1.updateReport)(body.reportId, feature, stepCounts, isFinal);
|
|
46
|
+
console.log('--- Finished uploading report data to AUXTA ---');
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.log('--- Failed to update report in AUXTA ---');
|
|
50
|
+
console.log(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (isFinal)
|
|
54
|
+
yield afterComplete(body);
|
|
55
|
+
else if (body && body.nextSuites)
|
|
56
|
+
yield (0, start_suite_helper_1.startSuite)(body.nextSuites, body.reportId);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.onTestEnd = onTestEnd;
|
|
60
|
+
function afterComplete(body) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (process.env.ENVIRONMENT == "LIVE")
|
|
63
|
+
yield (0, report_service_1.postNotifications)(body);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
exports.afterComplete = afterComplete;
|
|
@@ -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,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadModel = void 0;
|
|
4
|
+
class UploadModel {
|
|
5
|
+
constructor(org, baseUrl, digitalProduct, environment) {
|
|
6
|
+
this._reportId = '';
|
|
7
|
+
this._nextSuites = [];
|
|
8
|
+
this._organization = org;
|
|
9
|
+
this._digitalProduct = digitalProduct;
|
|
10
|
+
this._environment = environment;
|
|
11
|
+
this._baseUrl = baseUrl;
|
|
12
|
+
}
|
|
13
|
+
get reportId() {
|
|
14
|
+
return this._reportId;
|
|
15
|
+
}
|
|
16
|
+
set reportId(value) {
|
|
17
|
+
this._reportId = value;
|
|
18
|
+
}
|
|
19
|
+
get nextSuites() {
|
|
20
|
+
return this._nextSuites;
|
|
21
|
+
}
|
|
22
|
+
set nextSuites(value) {
|
|
23
|
+
this._nextSuites = value;
|
|
24
|
+
}
|
|
25
|
+
get digitalProduct() {
|
|
26
|
+
return this._digitalProduct;
|
|
27
|
+
}
|
|
28
|
+
set digitalProduct(value) {
|
|
29
|
+
this._digitalProduct = value;
|
|
30
|
+
}
|
|
31
|
+
get organization() {
|
|
32
|
+
return this._organization;
|
|
33
|
+
}
|
|
34
|
+
get baseUrl() {
|
|
35
|
+
return this._baseUrl;
|
|
36
|
+
}
|
|
37
|
+
set baseUrl(value) {
|
|
38
|
+
this._baseUrl = value;
|
|
39
|
+
}
|
|
40
|
+
get environment() {
|
|
41
|
+
return this._environment;
|
|
42
|
+
}
|
|
43
|
+
set environment(value) {
|
|
44
|
+
this._environment = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.UploadModel = UploadModel;
|
|
@@ -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,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogSteps = void 0;
|
|
4
|
+
const status_of_step_1 = require("../enums/status-of.step");
|
|
5
|
+
class LogSteps {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.stepLog = [];
|
|
8
|
+
this.lastStepTime = new Date().getTime();
|
|
9
|
+
this.statusCounter = {
|
|
10
|
+
[status_of_step_1.StatusOfStep.PASSED]: 0,
|
|
11
|
+
[status_of_step_1.StatusOfStep.FAILED]: 0,
|
|
12
|
+
[status_of_step_1.StatusOfStep.SKIPPED]: 0,
|
|
13
|
+
[status_of_step_1.StatusOfStep.SUGGESTION]: 0,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
addSuggestion(text) {
|
|
17
|
+
this.statusCounter[status_of_step_1.StatusOfStep.SUGGESTION]++;
|
|
18
|
+
this.stepLog.push({
|
|
19
|
+
keyword: 'Suggestion', name: text, result: { status: status_of_step_1.StatusOfStep.SUGGESTION, duration: 0 }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.stepLog = [];
|
|
24
|
+
this.statusCounter = {
|
|
25
|
+
[status_of_step_1.StatusOfStep.PASSED]: 0,
|
|
26
|
+
[status_of_step_1.StatusOfStep.FAILED]: 0,
|
|
27
|
+
[status_of_step_1.StatusOfStep.SKIPPED]: 0,
|
|
28
|
+
[status_of_step_1.StatusOfStep.SUGGESTION]: 0,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
push(keyword, name, status) {
|
|
32
|
+
console.log(`System log -- status: ${status} -- : ${name} `);
|
|
33
|
+
this.statusCounter[status]++;
|
|
34
|
+
const currentStep = new Date().getTime();
|
|
35
|
+
this.stepLog.push({ keyword, name, result: { status, duration: currentStep - this.lastStepTime } });
|
|
36
|
+
this.lastStepTime = currentStep;
|
|
37
|
+
}
|
|
38
|
+
returnScenarioReport() {
|
|
39
|
+
return this.stepLog;
|
|
40
|
+
}
|
|
41
|
+
getStatusCount(status) {
|
|
42
|
+
return this.statusCounter[status];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.LogSteps = LogSteps;
|
|
46
|
+
const log = new LogSteps();
|
|
47
|
+
exports.default = log;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Step } from "./log.service";
|
|
3
|
+
import { UploadModel } from "../models/upload.model";
|
|
4
|
+
export interface Feature {
|
|
5
|
+
featureId: string;
|
|
6
|
+
featureName: string;
|
|
7
|
+
featureUri: string;
|
|
8
|
+
status: string;
|
|
9
|
+
scenariosCount: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Scenario {
|
|
12
|
+
featureId: string;
|
|
13
|
+
featureName: string;
|
|
14
|
+
featureUri: string;
|
|
15
|
+
status: string;
|
|
16
|
+
scenariosCount: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Steps {
|
|
19
|
+
failedSteps: number;
|
|
20
|
+
passedSteps: number;
|
|
21
|
+
skippedSteps: number;
|
|
22
|
+
suggestedSteps: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function createEmptyReport(body: any): Promise<string>;
|
|
25
|
+
export declare function uploadScenario(stepLog: Step[], scenarioName: string, screenshot?: Buffer, errMessage?: object): Promise<{
|
|
26
|
+
scenarioRef: any;
|
|
27
|
+
name: any;
|
|
28
|
+
status: any;
|
|
29
|
+
stepsCount: any;
|
|
30
|
+
}[]>;
|
|
31
|
+
export declare function uploadFeature(scenarioId: any[], scenarioName: string, uri: string, hasFailed: boolean): Promise<any>;
|
|
32
|
+
export declare function updateReport(reportId: string, feature: Feature, steps: Steps, isFinal: boolean): Promise<void>;
|
|
33
|
+
export declare function getReport(reportId: string): Promise<any>;
|
|
34
|
+
export declare function getLastDayResults(): Promise<any>;
|
|
35
|
+
export declare function postNotifications(body: UploadModel): Promise<void>;
|
|
36
|
+
export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
|