@auxcode/auxta 0.5.7 → 0.5.8

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 (40) hide show
  1. package/build/AuxTA.d.ts +43 -0
  2. package/build/AuxTA.js +112 -0
  3. package/build/auxta/configs/config.d.ts +51 -0
  4. package/build/auxta/configs/config.js +61 -0
  5. package/build/auxta/enums/status-of.step.d.ts +7 -0
  6. package/build/auxta/enums/status-of.step.js +8 -0
  7. package/build/auxta/helpers/response.helper.d.ts +10 -0
  8. package/build/auxta/helpers/response.helper.js +11 -0
  9. package/build/auxta/helpers/start.helper.d.ts +1 -0
  10. package/build/auxta/helpers/start.helper.js +24 -0
  11. package/build/auxta/hooks/report.hook.d.ts +4 -0
  12. package/build/auxta/hooks/report.hook.js +58 -0
  13. package/build/auxta/models/upload.model.d.ts +20 -0
  14. package/build/auxta/models/upload.model.js +43 -0
  15. package/build/auxta/services/log.service.d.ts +26 -0
  16. package/build/auxta/services/log.service.js +43 -0
  17. package/build/auxta/services/report.service.d.ts +36 -0
  18. package/build/auxta/services/report.service.js +148 -0
  19. package/build/auxta/services/runtime.service.d.ts +16 -0
  20. package/build/auxta/services/runtime.service.js +37 -0
  21. package/build/auxta/utilities/runtime.helper.d.ts +15 -0
  22. package/build/auxta/utilities/runtime.helper.js +15 -0
  23. package/build/auxta/utilities/screenshot.helper.d.ts +2 -0
  24. package/build/auxta/utilities/screenshot.helper.js +29 -0
  25. package/build/auxta/utilities/start-suite.helper.d.ts +1 -0
  26. package/build/auxta/utilities/start-suite.helper.js +25 -0
  27. package/build/cjs/AuxTA.js +38 -23
  28. package/build/cjs/auxta/helpers/start.helper.js +12 -3
  29. package/build/cjs/auxta/hooks/report.hook.js +50 -37
  30. package/build/cjs/auxta/services/report.service.js +126 -105
  31. package/build/cjs/auxta/utilities/screenshot.helper.js +27 -16
  32. package/build/cjs/auxta/utilities/start-suite.helper.js +22 -11
  33. package/build/cjs/macros/helpers/code.helper.js +164 -129
  34. package/build/cjs/puppeteer/puppeteer.js +117 -100
  35. package/build/macros/helpers/code.helper.d.ts +22 -0
  36. package/build/macros/helpers/code.helper.js +193 -0
  37. package/build/puppeteer/puppeteer.d.ts +13 -0
  38. package/build/puppeteer/puppeteer.js +153 -0
  39. package/build/tsconfig-cjs.tsbuildinfo +1 -1
  40. package/package.json +1 -1
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -14,128 +23,140 @@ function headers(token) {
14
23
  }
15
24
  };
16
25
  }
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");
26
+ function auth() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ return axios_1.default.post(config_1.config.auxtaURL + 'login', config_1.config.auxtaCredentials, {
29
+ headers: {
30
+ 'Content-Type': 'application/json',
31
+ }
32
+ })
33
+ .then(({ data }) => {
34
+ return data.token;
35
+ })
36
+ .catch(() => {
37
+ throw new Error("Invalid login credentials");
38
+ });
28
39
  });
29
40
  }
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;
41
+ function createEmptyReport(body) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const token = yield auth();
44
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "create-empty-report", {
45
+ environment: body.environment,
46
+ digitalProductName: body.digitalProduct,
47
+ start: new Date(),
48
+ url: body.baseUrl
49
+ }, headers(token))).data.reportId;
50
+ });
38
51
  }
39
52
  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
+ function uploadScenario(stepLog, scenarioName, screenshot, errMessage) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ let scenarios = [];
56
+ let token = yield auth();
57
+ let lastStep = stepLog[stepLog.length - 1];
58
+ const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
59
+ stepLogFormat.pop();
60
+ let output = (yield axios_1.default.post(config_1.config.auxtaURL + "create-scenario", {
61
+ json: {
62
+ name: scenarioName,
63
+ steps: [
64
+ ...stepLogFormat,
65
+ (lastStep.result.status == 'failed')
66
+ ? Object.assign(lastStep, {
67
+ result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
68
+ })
69
+ : lastStep,
70
+ {
71
+ keyword: "After",
53
72
  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
73
+ status: "passed",
74
+ duration: 2678000000
75
+ },
76
+ embeddings: (screenshot) ? [{
77
+ data: screenshot.toString("base64"),
78
+ mime_type: "image/png"
79
+ }] : undefined,
80
+ }
81
+ ],
82
+ }
83
+ }, headers(token))).data.scenarios;
84
+ scenarios.push({
85
+ scenarioRef: output.scenarioRef,
86
+ name: output.name,
87
+ status: output.status,
88
+ stepsCount: output.stepsCount
89
+ });
90
+ return scenarios;
78
91
  });
79
- return scenarios;
80
92
  }
81
93
  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;
94
+ function uploadFeature(scenarioId, scenarioName, uri, hasFailed) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ let token = yield auth();
97
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "create-feature", {
98
+ json: {
99
+ name: scenarioName,
100
+ uri: uri
101
+ },
102
+ scenarios: scenarioId,
103
+ hasFailed: hasFailed
104
+ }, headers(token))).data;
105
+ });
92
106
  }
93
107
  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));
108
+ function updateReport(reportId, feature, steps, isFinal) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ let token = yield auth();
111
+ yield axios_1.default.post(config_1.config.auxtaURL + "update-inprogress-report", {
112
+ reportId: reportId,
113
+ isFinal: isFinal,
114
+ data: Object.assign({ feature: {
115
+ featureRef: feature.featureId,
116
+ name: feature.featureName,
117
+ uri: feature.featureUri,
118
+ status: feature.status,
119
+ scenariosCount: feature.scenariosCount
120
+ } }, steps)
121
+ }, headers(token));
122
+ });
110
123
  }
111
124
  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;
125
+ function getReport(reportId) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ let token = yield auth();
128
+ return (yield axios_1.default.post(config_1.config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
129
+ });
115
130
  }
116
131
  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;
132
+ function getLastDayResults() {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ let token = yield auth();
135
+ return (yield axios_1.default.get(config_1.config.auxtaURL + `get-last-day-results?url=${config_1.config.baseURL}`, headers(token))).data.results;
136
+ });
120
137
  }
121
138
  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));
139
+ function postNotifications(body) {
140
+ return __awaiter(this, void 0, void 0, function* () {
141
+ let token = yield auth();
142
+ yield axios_1.default.post(`${config_1.config.auxtaURL}post-notification-after-run-background`, {
143
+ environmentName: body.environment,
144
+ digitalProductName: body.digitalProduct,
145
+ organizationName: body.organization,
146
+ reportId: body.reportId,
147
+ }, headers(token));
148
+ });
130
149
  }
131
150
  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));
151
+ function postNotificationsOnFail(body) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ let token = yield auth();
154
+ yield axios_1.default.post(`${config_1.config.auxtaURL}post-notifications-after-case-fail-background`, {
155
+ environmentName: body.environment,
156
+ digitalProductName: body.digitalProduct,
157
+ organizationName: body.organization,
158
+ reportId: body.reportId,
159
+ }, headers(token));
160
+ });
140
161
  }
141
162
  exports.postNotificationsOnFail = postNotificationsOnFail;
@@ -1,25 +1,36 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
15
  exports.captureScreenshot = void 0;
7
16
  const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
8
- async function captureScreenshot() {
9
- try {
10
- const pages = await puppeteer_1.default.defaultPage.browser().pages();
11
- if (!pages.length)
12
- return undefined;
13
- const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
14
- const screenshotBuffer = await lastPage.screenshot({
15
- fullPage: true,
16
- encoding: 'binary'
17
- });
18
- if (Buffer.isBuffer(screenshotBuffer))
19
- return screenshotBuffer;
20
- }
21
- catch (e) {
22
- }
23
- return undefined;
17
+ function captureScreenshot() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ try {
20
+ const pages = yield puppeteer_1.default.defaultPage.browser().pages();
21
+ if (!pages.length)
22
+ return undefined;
23
+ const lastPage = pages[pages.length - 1] || puppeteer_1.default.defaultPage;
24
+ const screenshotBuffer = yield lastPage.screenshot({
25
+ fullPage: true,
26
+ encoding: 'binary'
27
+ });
28
+ if (Buffer.isBuffer(screenshotBuffer))
29
+ return screenshotBuffer;
30
+ }
31
+ catch (e) {
32
+ }
33
+ return undefined;
34
+ });
24
35
  }
25
36
  exports.captureScreenshot = captureScreenshot;
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -6,16 +15,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
15
  exports.startSuite = void 0;
7
16
  const axios_1 = __importDefault(require("axios"));
8
17
  const config_1 = require("../configs/config");
9
- async function startSuite(suites, reportId) {
10
- if (suites.length === 0)
11
- return;
12
- const next = suites.shift();
13
- console.log('Starting next suite: ' + next);
14
- try {
15
- await axios_1.default.post(`${config_1.config.netlifyPath}.netlify/functions/${next}?token=${config_1.config.token}`, { nextSuites: suites, reportId: reportId });
16
- }
17
- catch (e) {
18
- await startSuite(suites, reportId);
19
- }
18
+ function startSuite(suites, reportId) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ if (suites.length === 0)
21
+ return;
22
+ const next = suites.shift();
23
+ console.log('Starting next suite: ' + next);
24
+ try {
25
+ yield axios_1.default.post(`${config_1.config.netlifyPath}.netlify/functions/${next}?token=${config_1.config.token}`, { nextSuites: suites, reportId: reportId });
26
+ }
27
+ catch (e) {
28
+ yield startSuite(suites, reportId);
29
+ }
30
+ });
20
31
  }
21
32
  exports.startSuite = startSuite;