@auxcode/auxta 0.6.2 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/puppeteer/puppeteer.js +1 -1
- package/build/esm/AuxTA.js +38 -23
- package/build/esm/auxta/helpers/start.helper.js +12 -3
- package/build/esm/auxta/hooks/report.hook.js +50 -37
- package/build/esm/auxta/services/report.service.js +126 -105
- package/build/esm/auxta/utilities/screenshot.helper.js +27 -16
- package/build/esm/auxta/utilities/start-suite.helper.js +22 -11
- package/build/esm/macros/helpers/code.helper.js +164 -129
- package/build/esm/puppeteer/puppeteer.js +117 -100
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ class Puppeteer {
|
|
|
34
34
|
if (process.env.ENVIRONMENT != 'LOCAL')
|
|
35
35
|
args.push(`--window-size=${config_1.config.screenWidth},${config_1.config.screenHeight}`);
|
|
36
36
|
this.browser = yield chrome_aws_lambda_1.default.puppeteer.launch({
|
|
37
|
-
executablePath: process.env.ENVIRONMENT === 'LOCAL' ? undefined :
|
|
37
|
+
executablePath: process.env.ENVIRONMENT === 'LOCAL' ? undefined : process.env.CHROME_PATH,
|
|
38
38
|
args,
|
|
39
39
|
ignoreDefaultArgs: ["--enable-automation"],
|
|
40
40
|
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
package/build/esm/AuxTA.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import puppeteer from "./puppeteer/puppeteer";
|
|
2
11
|
import { FunctionHelper } from "./macros/helpers/code.helper";
|
|
3
12
|
import path from "path";
|
|
@@ -50,14 +59,16 @@ class AuxTA extends FunctionHelper {
|
|
|
50
59
|
this.uploadModel = new UploadModel('', '', '', '');
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
this
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
run(event, overrideConfig) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
this.changeModelData(overrideConfig);
|
|
65
|
+
let reportId = event.queryStringParameters.reportId;
|
|
66
|
+
if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
|
|
67
|
+
return { statusCode: 401, message: 'Unauthorized' };
|
|
68
|
+
const suites = this.config.suitesList.slice(0);
|
|
69
|
+
yield startSuite(suites, reportId || (yield createEmptyReport(this.uploadModel)));
|
|
70
|
+
return { statusCode: 204 };
|
|
71
|
+
});
|
|
61
72
|
}
|
|
62
73
|
changeModelData(overrideConfig) {
|
|
63
74
|
if (overrideConfig) {
|
|
@@ -70,23 +81,27 @@ class AuxTA extends FunctionHelper {
|
|
|
70
81
|
this.config = setupOverrideConfig(overrideConfig);
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
|
|
74
|
-
this
|
|
75
|
-
|
|
76
|
-
if (process.env.ENVIRONMENT
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
this.changeModelData(overrideConfig);
|
|
87
|
+
if (singleFeature && process.env.ENVIRONMENT !== 'LOCAL') {
|
|
88
|
+
if (process.env.ENVIRONMENT === 'LIVE' && event.queryStringParameters.token !== this.config.token)
|
|
89
|
+
return { statusCode: 401, message: 'Unauthorized' };
|
|
90
|
+
this.uploadModel.reportId = yield createEmptyReport(this.uploadModel);
|
|
91
|
+
this.uploadModel.nextSuites = [];
|
|
92
|
+
}
|
|
93
|
+
return this.puppeteer.run(event, callback, feature, scenario);
|
|
94
|
+
});
|
|
82
95
|
}
|
|
83
|
-
|
|
84
|
-
this
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
startBrowserRPA(event, callback, baseURL) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
this.changeModelData({
|
|
99
|
+
baseURL: baseURL,
|
|
100
|
+
environment: '',
|
|
101
|
+
digitalProduct: ''
|
|
102
|
+
});
|
|
103
|
+
return this.puppeteer.runRPA(event, callback);
|
|
88
104
|
});
|
|
89
|
-
return this.puppeteer.runRPA(event, callback);
|
|
90
105
|
}
|
|
91
106
|
getUploadModel() {
|
|
92
107
|
return this.uploadModel;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { join } from 'path';
|
|
2
|
-
(
|
|
11
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
3
12
|
const r = /^--params\.suite=(.*)$/g;
|
|
4
13
|
let suite = process.argv.find(el => !!el.match(r));
|
|
5
14
|
if (!suite)
|
|
@@ -10,6 +19,6 @@ import { join } from 'path';
|
|
|
10
19
|
suitesArr = [suites];
|
|
11
20
|
for (const suite of suitesArr) {
|
|
12
21
|
let f = require(join(process.cwd(), 'build', 'functions', 'controllers', suite));
|
|
13
|
-
|
|
22
|
+
yield f.handler();
|
|
14
23
|
}
|
|
15
|
-
})();
|
|
24
|
+
}))();
|
|
@@ -1,45 +1,58 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { basename } from 'path';
|
|
2
11
|
import log from "../services/log.service";
|
|
3
12
|
import { postNotifications, updateReport, uploadFeature, uploadScenario } from '../services/report.service';
|
|
4
13
|
import { startSuite } from '../utilities/start-suite.helper';
|
|
5
14
|
import { StatusOfStep } from "../enums/status-of.step";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
export function onTestEnd(body, featureName, scenarioName, statusCode, screenshotBuffer, errMessage) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
let isFinal = false;
|
|
18
|
+
if (process.env.ENVIRONMENT == "LIVE") {
|
|
19
|
+
console.log('asc ' + errMessage);
|
|
20
|
+
console.log('--- Uploading scenario and feature for AUXTA report ---');
|
|
21
|
+
const stepsArr = log.returnScenarioReport();
|
|
22
|
+
try {
|
|
23
|
+
const scenarioRes = yield uploadScenario(stepsArr, scenarioName, screenshotBuffer, errMessage);
|
|
24
|
+
const featureRes = yield uploadFeature(scenarioRes, featureName, basename(__filename), (statusCode != 200));
|
|
25
|
+
const feature = {
|
|
26
|
+
featureId: featureRes.featureRef,
|
|
27
|
+
featureName: featureRes.name,
|
|
28
|
+
featureUri: featureRes.uri,
|
|
29
|
+
status: featureRes.status,
|
|
30
|
+
scenariosCount: featureRes.scenariosCount
|
|
31
|
+
};
|
|
32
|
+
const stepCounts = {
|
|
33
|
+
failedSteps: log.getStatusCount(StatusOfStep.FAILED),
|
|
34
|
+
passedSteps: log.getStatusCount(StatusOfStep.PASSED),
|
|
35
|
+
skippedSteps: log.getStatusCount(StatusOfStep.SKIPPED),
|
|
36
|
+
suggestedSteps: log.getStatusCount(StatusOfStep.SUGGESTION)
|
|
37
|
+
};
|
|
38
|
+
isFinal = (!(body.nextSuites && body.nextSuites.length > 0));
|
|
39
|
+
yield updateReport(body.reportId, feature, stepCounts, isFinal);
|
|
40
|
+
console.log('--- Finished uploading report data to AUXTA ---');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log('--- Failed to update report in AUXTA ---');
|
|
44
|
+
console.log(error);
|
|
45
|
+
}
|
|
31
46
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
if (isFinal)
|
|
38
|
-
await afterComplete(body);
|
|
39
|
-
else if (body && body.nextSuites)
|
|
40
|
-
await startSuite(body.nextSuites, body.reportId);
|
|
47
|
+
if (isFinal)
|
|
48
|
+
yield afterComplete(body);
|
|
49
|
+
else if (body && body.nextSuites)
|
|
50
|
+
yield startSuite(body.nextSuites, body.reportId);
|
|
51
|
+
});
|
|
41
52
|
}
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
export function afterComplete(body) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
if (process.env.ENVIRONMENT == "LIVE")
|
|
56
|
+
yield postNotifications(body);
|
|
57
|
+
});
|
|
45
58
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import axios from "axios";
|
|
2
11
|
import { config } from "../configs/config";
|
|
3
12
|
function headers(token) {
|
|
@@ -8,120 +17,132 @@ function headers(token) {
|
|
|
8
17
|
}
|
|
9
18
|
};
|
|
10
19
|
}
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
function auth() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return axios.post(config.auxtaURL + 'login', config.auxtaCredentials, {
|
|
23
|
+
headers: {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
.then(({ data }) => {
|
|
28
|
+
return data.token;
|
|
29
|
+
})
|
|
30
|
+
.catch(() => {
|
|
31
|
+
throw new Error("Invalid login credentials");
|
|
32
|
+
});
|
|
22
33
|
});
|
|
23
34
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
export function createEmptyReport(body) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const token = yield auth();
|
|
38
|
+
return (yield axios.post(config.auxtaURL + "create-empty-report", {
|
|
39
|
+
environment: body.environment,
|
|
40
|
+
digitalProductName: body.digitalProduct,
|
|
41
|
+
start: new Date(),
|
|
42
|
+
url: body.baseUrl
|
|
43
|
+
}, headers(token))).data.reportId;
|
|
44
|
+
});
|
|
32
45
|
}
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
export function uploadScenario(stepLog, scenarioName, screenshot, errMessage) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
let scenarios = [];
|
|
49
|
+
let token = yield auth();
|
|
50
|
+
let lastStep = stepLog[stepLog.length - 1];
|
|
51
|
+
const stepLogFormat = JSON.parse(JSON.stringify(stepLog));
|
|
52
|
+
stepLogFormat.pop();
|
|
53
|
+
let output = (yield axios.post(config.auxtaURL + "create-scenario", {
|
|
54
|
+
json: {
|
|
55
|
+
name: scenarioName,
|
|
56
|
+
steps: [
|
|
57
|
+
...stepLogFormat,
|
|
58
|
+
(lastStep.result.status == 'failed')
|
|
59
|
+
? Object.assign(lastStep, {
|
|
60
|
+
result: Object.assign(Object.assign({}, lastStep.result), { error_message: JSON.stringify(errMessage) })
|
|
61
|
+
})
|
|
62
|
+
: lastStep,
|
|
63
|
+
{
|
|
64
|
+
keyword: "After",
|
|
46
65
|
result: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, headers(token))).data.scenarios;
|
|
66
|
-
scenarios.push({
|
|
67
|
-
scenarioRef: output.scenarioRef,
|
|
68
|
-
name: output.name,
|
|
69
|
-
status: output.status,
|
|
70
|
-
stepsCount: output.stepsCount
|
|
66
|
+
status: "passed",
|
|
67
|
+
duration: 2678000000
|
|
68
|
+
},
|
|
69
|
+
embeddings: (screenshot) ? [{
|
|
70
|
+
data: screenshot.toString("base64"),
|
|
71
|
+
mime_type: "image/png"
|
|
72
|
+
}] : undefined,
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
}
|
|
76
|
+
}, headers(token))).data.scenarios;
|
|
77
|
+
scenarios.push({
|
|
78
|
+
scenarioRef: output.scenarioRef,
|
|
79
|
+
name: output.name,
|
|
80
|
+
status: output.status,
|
|
81
|
+
stepsCount: output.stepsCount
|
|
82
|
+
});
|
|
83
|
+
return scenarios;
|
|
71
84
|
});
|
|
72
|
-
return scenarios;
|
|
73
85
|
}
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
scenarios: scenarioId,
|
|
82
|
-
hasFailed: hasFailed
|
|
83
|
-
}, headers(token))).data;
|
|
84
|
-
}
|
|
85
|
-
export async function updateReport(reportId, feature, steps, isFinal) {
|
|
86
|
-
let token = await auth();
|
|
87
|
-
await axios.post(config.auxtaURL + "update-inprogress-report", {
|
|
88
|
-
reportId: reportId,
|
|
89
|
-
isFinal: isFinal,
|
|
90
|
-
data: {
|
|
91
|
-
feature: {
|
|
92
|
-
featureRef: feature.featureId,
|
|
93
|
-
name: feature.featureName,
|
|
94
|
-
uri: feature.featureUri,
|
|
95
|
-
status: feature.status,
|
|
96
|
-
scenariosCount: feature.scenariosCount
|
|
86
|
+
export function uploadFeature(scenarioId, scenarioName, uri, hasFailed) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
let token = yield auth();
|
|
89
|
+
return (yield axios.post(config.auxtaURL + "create-feature", {
|
|
90
|
+
json: {
|
|
91
|
+
name: scenarioName,
|
|
92
|
+
uri: uri
|
|
97
93
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
scenarios: scenarioId,
|
|
95
|
+
hasFailed: hasFailed
|
|
96
|
+
}, headers(token))).data;
|
|
97
|
+
});
|
|
101
98
|
}
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
export function updateReport(reportId, feature, steps, isFinal) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
let token = yield auth();
|
|
102
|
+
yield axios.post(config.auxtaURL + "update-inprogress-report", {
|
|
103
|
+
reportId: reportId,
|
|
104
|
+
isFinal: isFinal,
|
|
105
|
+
data: Object.assign({ feature: {
|
|
106
|
+
featureRef: feature.featureId,
|
|
107
|
+
name: feature.featureName,
|
|
108
|
+
uri: feature.featureUri,
|
|
109
|
+
status: feature.status,
|
|
110
|
+
scenariosCount: feature.scenariosCount
|
|
111
|
+
} }, steps)
|
|
112
|
+
}, headers(token));
|
|
113
|
+
});
|
|
105
114
|
}
|
|
106
|
-
export
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
export function getReport(reportId) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
let token = yield auth();
|
|
118
|
+
return (yield axios.post(config.auxtaURL + "get-report", { reportId: reportId }, headers(token))).data;
|
|
119
|
+
});
|
|
109
120
|
}
|
|
110
|
-
export
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
organizationName: body.organization,
|
|
116
|
-
reportId: body.reportId,
|
|
117
|
-
}, headers(token));
|
|
121
|
+
export function getLastDayResults() {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
let token = yield auth();
|
|
124
|
+
return (yield axios.get(config.auxtaURL + `get-last-day-results?url=${config.baseURL}`, headers(token))).data.results;
|
|
125
|
+
});
|
|
118
126
|
}
|
|
119
|
-
export
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
export function postNotifications(body) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
let token = yield auth();
|
|
130
|
+
yield axios.post(`${config.auxtaURL}post-notification-after-run-background`, {
|
|
131
|
+
environmentName: body.environment,
|
|
132
|
+
digitalProductName: body.digitalProduct,
|
|
133
|
+
organizationName: body.organization,
|
|
134
|
+
reportId: body.reportId,
|
|
135
|
+
}, headers(token));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export function postNotificationsOnFail(body) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
let token = yield auth();
|
|
141
|
+
yield axios.post(`${config.auxtaURL}post-notifications-after-case-fail-background`, {
|
|
142
|
+
environmentName: body.environment,
|
|
143
|
+
digitalProductName: body.digitalProduct,
|
|
144
|
+
organizationName: body.organization,
|
|
145
|
+
reportId: body.reportId,
|
|
146
|
+
}, headers(token));
|
|
147
|
+
});
|
|
127
148
|
}
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import puppeteer from "../../puppeteer/puppeteer";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export function captureScreenshot() {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const pages = yield puppeteer.defaultPage.browser().pages();
|
|
15
|
+
if (!pages.length)
|
|
16
|
+
return undefined;
|
|
17
|
+
const lastPage = pages[pages.length - 1] || puppeteer.defaultPage;
|
|
18
|
+
const screenshotBuffer = yield lastPage.screenshot({
|
|
19
|
+
fullPage: true,
|
|
20
|
+
encoding: 'binary'
|
|
21
|
+
});
|
|
22
|
+
if (Buffer.isBuffer(screenshotBuffer))
|
|
23
|
+
return screenshotBuffer;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
});
|
|
18
29
|
}
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import axios from 'axios';
|
|
2
11
|
import { config } from "../configs/config";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export function startSuite(suites, reportId) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
if (suites.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
const next = suites.shift();
|
|
17
|
+
console.log('Starting next suite: ' + next);
|
|
18
|
+
try {
|
|
19
|
+
yield axios.post(`${config.netlifyPath}.netlify/functions/${next}?token=${config.token}`, { nextSuites: suites, reportId: reportId });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
yield startSuite(suites, reportId);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
14
25
|
}
|