@auxcode/auxta 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/build/{cjs/AuxTA.d.ts → AuxTA.d.ts} +0 -0
  2. package/build/{esm/AuxTA.js → AuxTA.js} +0 -0
  3. package/build/{cjs/auxta → auxta}/configs/config.d.ts +0 -0
  4. package/build/{esm/auxta → auxta}/configs/config.js +0 -0
  5. package/build/{cjs/auxta → auxta}/enums/status-of.step.d.ts +0 -0
  6. package/build/{esm/auxta → auxta}/enums/status-of.step.js +0 -0
  7. package/build/{cjs/auxta → auxta}/helpers/response.helper.d.ts +0 -0
  8. package/build/{esm/auxta → auxta}/helpers/response.helper.js +0 -0
  9. package/build/{cjs/auxta → auxta}/helpers/start.helper.d.ts +0 -0
  10. package/build/{esm/auxta → auxta}/helpers/start.helper.js +0 -0
  11. package/build/{cjs/auxta → auxta}/hooks/report.hook.d.ts +0 -0
  12. package/build/{esm/auxta → auxta}/hooks/report.hook.js +0 -0
  13. package/build/{cjs/auxta → auxta}/models/upload.model.d.ts +0 -0
  14. package/build/{esm/auxta → auxta}/models/upload.model.js +0 -0
  15. package/build/{cjs/auxta → auxta}/services/log.service.d.ts +0 -0
  16. package/build/{esm/auxta → auxta}/services/log.service.js +0 -0
  17. package/build/{cjs/auxta → auxta}/services/report.service.d.ts +0 -0
  18. package/build/{esm/auxta → auxta}/services/report.service.js +0 -0
  19. package/build/{cjs/auxta → auxta}/services/runtime.service.d.ts +0 -0
  20. package/build/{esm/auxta → auxta}/services/runtime.service.js +0 -0
  21. package/build/{cjs/auxta → auxta}/utilities/runtime.helper.d.ts +0 -0
  22. package/build/{esm/auxta → auxta}/utilities/runtime.helper.js +0 -0
  23. package/build/{cjs/auxta → auxta}/utilities/screenshot.helper.d.ts +0 -0
  24. package/build/{esm/auxta → auxta}/utilities/screenshot.helper.js +0 -0
  25. package/build/{cjs/auxta → auxta}/utilities/start-suite.helper.d.ts +0 -0
  26. package/build/{esm/auxta → auxta}/utilities/start-suite.helper.js +0 -0
  27. package/build/{cjs/macros → macros}/helpers/code.helper.d.ts +0 -0
  28. package/build/{esm/macros → macros}/helpers/code.helper.js +0 -0
  29. package/build/{cjs/puppeteer → puppeteer}/puppeteer.d.ts +0 -0
  30. package/build/{esm/puppeteer → puppeteer}/puppeteer.js +0 -0
  31. package/package.json +3 -4
  32. package/build/cjs/AuxTA.js +0 -122
  33. package/build/cjs/auxta/configs/config.js +0 -66
  34. package/build/cjs/auxta/enums/status-of.step.js +0 -11
  35. package/build/cjs/auxta/helpers/response.helper.js +0 -15
  36. package/build/cjs/auxta/helpers/start.helper.js +0 -17
  37. package/build/cjs/auxta/hooks/report.hook.js +0 -53
  38. package/build/cjs/auxta/models/upload.model.js +0 -47
  39. package/build/cjs/auxta/services/log.service.js +0 -47
  40. package/build/cjs/auxta/services/report.service.js +0 -141
  41. package/build/cjs/auxta/services/runtime.service.js +0 -41
  42. package/build/cjs/auxta/utilities/runtime.helper.js +0 -19
  43. package/build/cjs/auxta/utilities/screenshot.helper.js +0 -25
  44. package/build/cjs/auxta/utilities/start-suite.helper.js +0 -21
  45. package/build/cjs/macros/helpers/code.helper.js +0 -165
  46. package/build/cjs/puppeteer/puppeteer.js +0 -143
  47. package/build/esm/AuxTA.d.ts +0 -43
  48. package/build/esm/auxta/configs/config.d.ts +0 -51
  49. package/build/esm/auxta/enums/status-of.step.d.ts +0 -7
  50. package/build/esm/auxta/helpers/response.helper.d.ts +0 -10
  51. package/build/esm/auxta/helpers/start.helper.d.ts +0 -1
  52. package/build/esm/auxta/hooks/report.hook.d.ts +0 -4
  53. package/build/esm/auxta/models/upload.model.d.ts +0 -20
  54. package/build/esm/auxta/services/log.service.d.ts +0 -26
  55. package/build/esm/auxta/services/report.service.d.ts +0 -36
  56. package/build/esm/auxta/services/runtime.service.d.ts +0 -16
  57. package/build/esm/auxta/utilities/runtime.helper.d.ts +0 -15
  58. package/build/esm/auxta/utilities/screenshot.helper.d.ts +0 -2
  59. package/build/esm/auxta/utilities/start-suite.helper.d.ts +0 -1
  60. package/build/esm/macros/helpers/code.helper.d.ts +0 -22
  61. package/build/esm/puppeteer/puppeteer.d.ts +0 -13
  62. package/build/tsconfig-cjs.tsbuildinfo +0 -1
  63. package/build/tsconfig.tsbuildinfo +0 -1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "",
5
- "main": "./build/cjs/AuxTA.js",
6
- "module": "./build/esm/AuxTA.js",
5
+ "main": "./build/AuxTA.js",
7
6
  "files": [
8
7
  "build/"
9
8
  ],
10
9
  "scripts": {
11
- "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json",
10
+ "tsc": "tsc -p tsconfig.json",
12
11
  "prepublish": "npm run tsc",
13
12
  "test": "npm run prepublish & node ./build/AuxTA.js"
14
13
  },
@@ -1,122 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.StepStatus = void 0;
26
- const puppeteer_1 = __importDefault(require("./puppeteer/puppeteer"));
27
- const code_helper_1 = require("./macros/helpers/code.helper");
28
- const path_1 = __importDefault(require("path"));
29
- const fs_1 = __importDefault(require("fs"));
30
- const status_of_step_1 = __importDefault(require("./auxta/enums/status-of.step"));
31
- const upload_model_1 = require("./auxta/models/upload.model");
32
- const dotenv = __importStar(require("dotenv"));
33
- const config_1 = require("./auxta/configs/config");
34
- const start_suite_helper_1 = require("./auxta/utilities/start-suite.helper");
35
- const report_service_1 = require("./auxta/services/report.service");
36
- dotenv.config();
37
- class AuxTA extends code_helper_1.FunctionHelper {
38
- constructor() {
39
- super();
40
- this.puppeteer = puppeteer_1.default;
41
- this.config = config_1.config;
42
- let file;
43
- if (!process.env.RPA) {
44
- try {
45
- let currentDir = "";
46
- while (true) {
47
- file = path_1.default.join(__dirname, currentDir, "auxta.json");
48
- if (!fs_1.default.existsSync(file)) {
49
- currentDir += "../";
50
- if (currentDir.length >= 30) {
51
- console.log("auxta.json file not found!");
52
- process.exit(1);
53
- return;
54
- }
55
- continue;
56
- }
57
- break;
58
- }
59
- const jsonConfig = JSON.parse(fs_1.default.readFileSync(file).toString());
60
- try {
61
- this.config = (0, config_1.setupConfig)(jsonConfig);
62
- }
63
- catch (e) {
64
- console.log("Missing field in auxta.json:", e);
65
- }
66
- this.uploadModel = new upload_model_1.UploadModel(jsonConfig.organization, jsonConfig.baseURL, jsonConfig.digitalProduct, jsonConfig.environment);
67
- }
68
- catch (e) {
69
- console.log("Missing or corrupted config: auxta.json. Searching in location:", file);
70
- console.log(e);
71
- process.exit(1);
72
- }
73
- }
74
- else {
75
- this.uploadModel = new upload_model_1.UploadModel('', '', '', '');
76
- }
77
- }
78
- async run(event, overrideConfig) {
79
- this.changeModelData(overrideConfig);
80
- let reportId = event.queryStringParameters.reportId;
81
- if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
82
- return { statusCode: 401, message: 'Unauthorized' };
83
- const suites = this.config.suitesList.slice(0);
84
- await (0, start_suite_helper_1.startSuite)(suites, reportId || await (0, report_service_1.createEmptyReport)(this.uploadModel));
85
- return { statusCode: 204 };
86
- }
87
- changeModelData(overrideConfig) {
88
- if (overrideConfig) {
89
- if (overrideConfig.digitalProduct)
90
- this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
91
- if (overrideConfig.environment)
92
- this.uploadModel.environment = overrideConfig.environment;
93
- if (overrideConfig.baseURL)
94
- this.uploadModel.baseUrl = overrideConfig.baseURL;
95
- this.config = (0, config_1.setupOverrideConfig)(overrideConfig);
96
- }
97
- }
98
- async startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false) {
99
- this.changeModelData(overrideConfig);
100
- if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
101
- if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
102
- return { statusCode: 401, message: 'Unauthorized' };
103
- this.uploadModel.reportId = await (0, report_service_1.createEmptyReport)(this.uploadModel);
104
- this.uploadModel.nextSuites = [];
105
- }
106
- return this.puppeteer.run(event, callback, feature, scenario);
107
- }
108
- async startBrowserRPA(event, callback, baseURL) {
109
- this.changeModelData({
110
- baseURL: baseURL,
111
- environment: '',
112
- digitalProduct: ''
113
- });
114
- return this.puppeteer.runRPA(event, callback);
115
- }
116
- getUploadModel() {
117
- return this.uploadModel;
118
- }
119
- }
120
- exports.StepStatus = status_of_step_1.default;
121
- const auxta = new AuxTA();
122
- exports.default = auxta;
@@ -1,66 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- (async () => {
5
- const r = /^--params\.suite=(.*)$/g;
6
- let suite = process.argv.find(el => !!el.match(r));
7
- if (!suite)
8
- throw `Locale is undefined`;
9
- let suites = suite.replace('--params.suite=', '');
10
- let suitesArr = suites.split(',');
11
- if (!suitesArr)
12
- suitesArr = [suites];
13
- for (const suite of suitesArr) {
14
- let f = require((0, path_1.join)(process.cwd(), 'build', 'functions', 'controllers', suite));
15
- await f.handler();
16
- }
17
- })();
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.afterComplete = exports.onTestEnd = void 0;
7
- const path_1 = require("path");
8
- const log_service_1 = __importDefault(require("../services/log.service"));
9
- const report_service_1 = require("../services/report.service");
10
- const start_suite_helper_1 = require("../utilities/start-suite.helper");
11
- const status_of_step_1 = require("../enums/status-of.step");
12
- async function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
13
- let isFinal = false;
14
- if (process.env.ENVIRONMENT == "LIVE") {
15
- console.log('asc ' + errMessage);
16
- console.log('--- Uploading scenario and feature for AUXTA report ---');
17
- const stepsArr = log_service_1.default.returnScenarioReport();
18
- try {
19
- const scenarioRes = await (0, report_service_1.uploadScenario)(stepsArr, scenarioName, screenshotBuffer, errMessage);
20
- const featureRes = await (0, report_service_1.uploadFeature)(scenarioRes, featureName, (0, path_1.basename)(__filename), (statusCode != 200));
21
- const feature = {
22
- featureId: featureRes.featureRef,
23
- featureName: featureRes.name,
24
- featureUri: featureRes.uri,
25
- status: featureRes.status,
26
- scenariosCount: featureRes.scenariosCount
27
- };
28
- const stepCounts = {
29
- failedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.FAILED),
30
- passedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.PASSED),
31
- skippedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SKIPPED),
32
- suggestedSteps: log_service_1.default.getStatusCount(status_of_step_1.StatusOfStep.SUGGESTION)
33
- };
34
- isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
35
- await (0, report_service_1.updateReport)(body.reportId, feature, stepCounts, isFinal);
36
- console.log('--- Finished uploading report data to AUXTA ---');
37
- }
38
- catch (error) {
39
- console.log('--- Failed to update report in AUXTA ---');
40
- console.log(error);
41
- }
42
- }
43
- if (isFinal)
44
- await afterComplete(body);
45
- else if (body && body.nextSuites)
46
- await (0, start_suite_helper_1.startSuite)(body.nextSuites, body.reportId);
47
- }
48
- exports.onTestEnd = onTestEnd;
49
- async function afterComplete(body) {
50
- if (process.env.ENVIRONMENT == "LIVE")
51
- await (0, report_service_1.postNotifications)(body);
52
- }
53
- exports.afterComplete = afterComplete;
@@ -1,47 +0,0 @@
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;
@@ -1,47 +0,0 @@
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;
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.postNotificationsOnFail = exports.postNotifications = exports.getLastDayResults = exports.getReport = exports.updateReport = exports.uploadFeature = exports.uploadScenario = exports.createEmptyReport = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const config_1 = require("../configs/config");
9
- function headers(token) {
10
- return {
11
- headers: {
12
- 'Content-Type': 'application/json',
13
- 'cookie': `authToken=${token}`
14
- }
15
- };
16
- }
17
- async function auth() {
18
- return axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
19
- headers: {
20
- 'Content-Type': 'application/json',
21
- }
22
- })
23
- .then(({ data }) => {
24
- return data.token;
25
- })
26
- .catch(() => {
27
- throw new Error("Invalid login credentials");
28
- });
29
- }
30
- async function createEmptyReport(body) {
31
- const token = await auth();
32
- return (await axios_1.default.post(config_1.config.auxtaURL + "create-empty-report", {
33
- environment: body.environment,
34
- digitalProductName: body.digitalProduct,
35
- start: new Date(),
36
- url: body.baseUrl
37
- }, headers(token))).data.reportId;
38
- }
39
- exports.createEmptyReport = createEmptyReport;
40
- async function uploadScenario(stepLog, scenarioName, screenshot, errMessage) {
41
- let scenarios = [];
42
- let token = await auth();
43
- let lastStep = stepLog[stepLog.length - 1];
44
- const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
45
- stepLogFormat.pop();
46
- let output = (await axios_1.default.post(config_1.config.auxtaURL + "create-scenario", {
47
- json: {
48
- name: scenarioName,
49
- steps: [
50
- ...stepLogFormat,
51
- (lastStep.result.status == 'failed')
52
- ? Object.assign(lastStep, {
53
- result: {
54
- ...lastStep.result,
55
- error_message: JSON.stringify(errMessage)
56
- }
57
- })
58
- : lastStep,
59
- {
60
- keyword: "After",
61
- result: {
62
- status: "passed",
63
- duration: 2678000000
64
- },
65
- embeddings: (screenshot) ? [{
66
- data: screenshot.toString("base64"),
67
- mime_type: "image/png"
68
- }] : undefined,
69
- }
70
- ],
71
- }
72
- }, headers(token))).data.scenarios;
73
- scenarios.push({
74
- scenarioRef: output.scenarioRef,
75
- name: output.name,
76
- status: output.status,
77
- stepsCount: output.stepsCount
78
- });
79
- return scenarios;
80
- }
81
- exports.uploadScenario = uploadScenario;
82
- async function uploadFeature(scenarioId, scenarioName, uri, hasFailed) {
83
- let token = await auth();
84
- return (await axios_1.default.post(config_1.config.auxtaURL + "create-feature", {
85
- json: {
86
- name: scenarioName,
87
- uri: uri
88
- },
89
- scenarios: scenarioId,
90
- hasFailed: hasFailed
91
- }, headers(token))).data;
92
- }
93
- exports.uploadFeature = uploadFeature;
94
- async function updateReport(reportId, feature, steps, isFinal) {
95
- let token = await auth();
96
- await axios_1.default.post(config_1.config.auxtaURL + "update-inprogress-report", {
97
- reportId: reportId,
98
- isFinal: isFinal,
99
- data: {
100
- feature: {
101
- featureRef: feature.featureId,
102
- name: feature.featureName,
103
- uri: feature.featureUri,
104
- status: feature.status,
105
- scenariosCount: feature.scenariosCount
106
- },
107
- ...steps
108
- }
109
- }, headers(token));
110
- }
111
- exports.updateReport = updateReport;
112
- async function getReport(reportId) {
113
- let token = await auth();
114
- return (await axios_1.default.post(config_1.config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
115
- }
116
- exports.getReport = getReport;
117
- async function getLastDayResults() {
118
- let token = await auth();
119
- return (await axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
120
- }
121
- exports.getLastDayResults = getLastDayResults;
122
- async function postNotifications(body) {
123
- let token = await auth();
124
- await axios_1.default.post(`${config_1.config.auxtaURL}post-notification-after-run-background`, {
125
- environmentName: body.environment,
126
- digitalProductName: body.digitalProduct,
127
- organizationName: body.organization,
128
- reportId: body.reportId,
129
- }, headers(token));
130
- }
131
- exports.postNotifications = postNotifications;
132
- async function postNotificationsOnFail(body) {
133
- let token = await auth();
134
- await axios_1.default.post(`${config_1.config.auxtaURL}post-notifications-after-case-fail-background`, {
135
- environmentName: body.environment,
136
- digitalProductName: body.digitalProduct,
137
- organizationName: body.organization,
138
- reportId: body.reportId,
139
- }, headers(token));
140
- }
141
- exports.postNotificationsOnFail = postNotificationsOnFail;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Runtime = void 0;
4
- class Runtime {
5
- constructor(s, e) {
6
- this.start = s;
7
- this.end = e;
8
- }
9
- calculateDuration() {
10
- let currentTime = new Date;
11
- let duration = currentTime.getTime() - this.start.getTime();
12
- return duration;
13
- }
14
- splitAtDecimanlMinutes(time) {
15
- let minutes = time.toFixed(2).toString().split('.');
16
- return `${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
17
- }
18
- splitAtDecimanlHours(time) {
19
- let hours = time.toFixed(2).toString().split('.');
20
- let minutes = (Number(hours[1]) / 100 * 60).toFixed(2).toString().split('.');
21
- return `${hours[0]}h ${minutes[0]}m ${(Number(minutes[1]) / 100 * 60).toFixed(0)}s`;
22
- }
23
- formatRuntime(duration) {
24
- if (duration / 1000 < 60)
25
- return `${(duration / 1000).toFixed(0)}s`;
26
- else {
27
- if (duration / 60000 < 60)
28
- return this.splitAtDecimanlMinutes(duration / 60000);
29
- else
30
- return this.splitAtDecimanlHours(duration / 3600000);
31
- }
32
- }
33
- returnRuntime() {
34
- let duration = this.formatRuntime(this.calculateDuration());
35
- let startTime = this.start;
36
- let endTime = this.end;
37
- this.runtime = { duration, startTime, endTime };
38
- return this.runtime;
39
- }
40
- }
41
- exports.Runtime = Runtime;