@dev-blinq/cucumber-js 1.0.121-dev → 1.0.121-stage
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/bin/cucumber.ts +1 -0
- package/bin/download-install.js +22 -2
- package/lib/api/console_logger.js.map +1 -1
- package/lib/cli/run.js +1 -0
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.js +3 -1
- package/lib/cli/validate_node_engine_version.js.map +1 -1
- package/lib/configuration/axios_client.js +1 -1
- package/lib/configuration/axios_client.js.map +1 -1
- package/lib/formatter/api.js +16 -5
- package/lib/formatter/api.js.map +1 -1
- package/lib/formatter/builder.js +1 -3
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/bvt_analysis_formatter.d.ts +15 -1
- package/lib/formatter/bvt_analysis_formatter.js +214 -55
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.js +22 -8
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/constants.d.ts +50 -0
- package/lib/formatter/helpers/constants.js +60 -0
- package/lib/formatter/helpers/constants.js.map +1 -0
- package/lib/formatter/helpers/report_generator.d.ts +23 -3
- package/lib/formatter/helpers/report_generator.js +339 -27
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +22 -2
- package/lib/formatter/helpers/upload_serivce.js +218 -34
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.js +6 -2
- package/lib/formatter/helpers/uploader.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +2 -1
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/summary_formatter.js +4 -0
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +0 -1
- package/lib/models/definition.js.map +1 -1
- package/lib/pickle_filter.d.ts +3 -2
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +2 -0
- package/lib/runtime/test_case_runner.js +17 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/uncaught_exception_manager.d.ts +1 -1
- package/lib/uncaught_exception_manager.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +7 -3
|
@@ -7,9 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.RunUploadService = void 0;
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const p_limit_1 = __importDefault(require("p-limit"));
|
|
10
11
|
const axios_client_1 = require("../../configuration/axios_client");
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
12
13
|
const bvt_analysis_formatter_1 = require("../bvt_analysis_formatter");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
13
15
|
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
14
16
|
const BATCH_SIZE = 10;
|
|
15
17
|
const MAX_RETRIES = 3;
|
|
@@ -19,10 +21,23 @@ class RunUploadService {
|
|
|
19
21
|
this.runsApiBaseURL = runsApiBaseURL;
|
|
20
22
|
this.accessToken = accessToken;
|
|
21
23
|
}
|
|
22
|
-
async createRunDocument(name) {
|
|
24
|
+
async createRunDocument(name, env) {
|
|
25
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
26
|
+
console.log('Skipping report upload as UPLOADREPORTS is set to false');
|
|
27
|
+
return { id: 'local-run', projectId: 'local-project' };
|
|
28
|
+
}
|
|
23
29
|
try {
|
|
24
30
|
const runDocResult = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/create', {
|
|
25
31
|
name: name ? name : 'TEST',
|
|
32
|
+
branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : 'main',
|
|
33
|
+
video_id: process.env.VIDEO_ID,
|
|
34
|
+
browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',
|
|
35
|
+
mode: process.env.MODE === 'cloud'
|
|
36
|
+
? 'cloud'
|
|
37
|
+
: process.env.MODE === 'executions'
|
|
38
|
+
? 'executions'
|
|
39
|
+
: 'local',
|
|
40
|
+
env: { name: env === null || env === void 0 ? void 0 : env.name, baseUrl: env === null || env === void 0 ? void 0 : env.baseUrl },
|
|
26
41
|
}, {
|
|
27
42
|
headers: {
|
|
28
43
|
Authorization: 'Bearer ' + this.accessToken,
|
|
@@ -45,7 +60,28 @@ class RunUploadService {
|
|
|
45
60
|
throw new Error('Failed to create run document in the server: ' + error);
|
|
46
61
|
}
|
|
47
62
|
}
|
|
63
|
+
async updateProjectAnalytics(projectId) {
|
|
64
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/project/updateAIRecoveryCount', {
|
|
69
|
+
projectId,
|
|
70
|
+
}, {
|
|
71
|
+
headers: {
|
|
72
|
+
Authorization: 'Bearer ' + this.accessToken,
|
|
73
|
+
'x-source': 'cucumber_js',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('Failed to update project metadata:', error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
48
81
|
async upload(formData) {
|
|
82
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
49
85
|
const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/upload', formData, {
|
|
50
86
|
headers: {
|
|
51
87
|
...formData.getHeaders(),
|
|
@@ -65,6 +101,9 @@ class RunUploadService {
|
|
|
65
101
|
}
|
|
66
102
|
}
|
|
67
103
|
async getPreSignedUrls(fileUris, runId) {
|
|
104
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
68
107
|
const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/generateuploadurls', {
|
|
69
108
|
fileUris,
|
|
70
109
|
runId,
|
|
@@ -86,50 +125,146 @@ class RunUploadService {
|
|
|
86
125
|
}
|
|
87
126
|
return response.data.uploadUrls;
|
|
88
127
|
}
|
|
89
|
-
async uploadTestCase(testCaseReport, runId, projectId, reportFolder) {
|
|
128
|
+
async uploadTestCase(testCaseReport, runId, projectId, reportFolder, rerunId) {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
if (process.env.UPLOADREPORTS === 'false')
|
|
131
|
+
return null;
|
|
90
132
|
const fileUris = [];
|
|
91
|
-
//
|
|
133
|
+
// Collect screenshot + trace + logs
|
|
92
134
|
for (const step of testCaseReport.steps) {
|
|
93
135
|
for (const command of step.commands) {
|
|
94
|
-
if (command.screenshotId)
|
|
95
|
-
fileUris.push(
|
|
96
|
-
}
|
|
136
|
+
if (command.screenshotId)
|
|
137
|
+
fileUris.push(`screenshots/${command.screenshotId}.png`);
|
|
97
138
|
}
|
|
139
|
+
if (step.traceFilePath)
|
|
140
|
+
fileUris.push(`trace/${step.traceFilePath}`);
|
|
98
141
|
}
|
|
99
|
-
|
|
100
|
-
|
|
142
|
+
if (testCaseReport.logFileId)
|
|
143
|
+
fileUris.push(`editorLogs/testCaseLog_${testCaseReport.logFileId}.log`);
|
|
144
|
+
if (testCaseReport.traceFileId)
|
|
145
|
+
fileUris.push(`trace/${testCaseReport.traceFileId}`);
|
|
146
|
+
// 🔹 UPLOAD FILES
|
|
101
147
|
try {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
148
|
+
const preSignedUrls = await this.getPreSignedUrls(fileUris, runId);
|
|
149
|
+
await this.uploadFilesInBatches(fileUris, reportFolder, preSignedUrls);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error('🟥 Error uploading files:', {
|
|
153
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
154
|
+
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// 🔹 UPLOAD FINAL TEST REPORT
|
|
158
|
+
try {
|
|
159
|
+
const mode = process.env.MODE === 'cloud'
|
|
160
|
+
? 'cloud'
|
|
161
|
+
: process.env.MODE === 'executions'
|
|
162
|
+
? 'executions'
|
|
163
|
+
: 'local';
|
|
164
|
+
let rerunIdFinal = process.env.RETRY_ID || null;
|
|
165
|
+
if (rerunId)
|
|
166
|
+
rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`;
|
|
167
|
+
if (mode === 'executions')
|
|
168
|
+
testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id;
|
|
169
|
+
const payload = {
|
|
117
170
|
runId,
|
|
118
171
|
projectId,
|
|
119
172
|
testProgressReport: testCaseReport,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
(0, bvt_analysis_formatter_1.
|
|
173
|
+
browser: process.env.BROWSER || 'chromium',
|
|
174
|
+
mode,
|
|
175
|
+
rerunId: rerunIdFinal,
|
|
176
|
+
video_id: process.env.VIDEO_ID,
|
|
177
|
+
};
|
|
178
|
+
const data = await (0, bvt_analysis_formatter_1.createNewTestCase)(payload, this.runsApiBaseURL, this.accessToken);
|
|
179
|
+
await (0, bvt_analysis_formatter_1.postUploadReportEvent)(projectId, this.accessToken);
|
|
180
|
+
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId, testCaseReport.result);
|
|
181
|
+
return data;
|
|
127
182
|
}
|
|
128
183
|
catch (e) {
|
|
129
|
-
console.error(
|
|
184
|
+
console.error('🟥 Failed to upload test case:', {
|
|
185
|
+
testCaseId: testCaseReport.id,
|
|
186
|
+
message: e === null || e === void 0 ? void 0 : e.message,
|
|
187
|
+
status: (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
188
|
+
responseSnippet: (_d = (_c = (_b = e === null || e === void 0 ? void 0 : e.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.toString()) === null || _d === void 0 ? void 0 : _d.slice(0, 300),
|
|
189
|
+
stack: e === null || e === void 0 ? void 0 : e.stack,
|
|
190
|
+
});
|
|
191
|
+
return null;
|
|
130
192
|
}
|
|
131
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Improving error logging
|
|
196
|
+
* 🔧 Sanitizes Axios errors to avoid dumping Cloudflare HTML (524, 502, etc.)
|
|
197
|
+
*/
|
|
198
|
+
sanitizeError(error) {
|
|
199
|
+
// Handle Axios-style errors with response
|
|
200
|
+
if (error === null || error === void 0 ? void 0 : error.response) {
|
|
201
|
+
const { data, status } = error.response;
|
|
202
|
+
// If Cloudflare or HTML error page → return a short meaningful message
|
|
203
|
+
if (typeof data === 'string' && data.includes('<!DOCTYPE html')) {
|
|
204
|
+
return `[HTML_ERROR_PAGE] status=${status} - likely Cloudflare timeout or proxy error`;
|
|
205
|
+
}
|
|
206
|
+
// If data is a JSON object, stringify it with indentation for readability
|
|
207
|
+
if (typeof data === 'object') {
|
|
208
|
+
return JSON.stringify(data, null, 2); // Pretty-print the JSON response
|
|
209
|
+
}
|
|
210
|
+
// If response is a string (could be an error message), return it trimmed
|
|
211
|
+
return (data === null || data === void 0 ? void 0 : data.trim()) || `Unknown response data (status: ${status})`;
|
|
212
|
+
}
|
|
213
|
+
// System / network errors (e.g., if Axios cannot reach the server)
|
|
214
|
+
if (error === null || error === void 0 ? void 0 : error.message) {
|
|
215
|
+
return error.message;
|
|
216
|
+
}
|
|
217
|
+
// If the error has a stack (for debugging purposes)
|
|
218
|
+
if (error === null || error === void 0 ? void 0 : error.stack) {
|
|
219
|
+
return `${error.message}\n${error.stack}`;
|
|
220
|
+
}
|
|
221
|
+
// If it's a generic error object, attempt to stringify it in a readable format
|
|
222
|
+
return JSON.stringify(error, (key, value) => {
|
|
223
|
+
// Avoid circular references or sensitive data
|
|
224
|
+
if (key === 'password' || key === 'accessToken')
|
|
225
|
+
return '[REDACTED]';
|
|
226
|
+
return value;
|
|
227
|
+
}, 2); // Pretty-print the error object with indentation
|
|
228
|
+
}
|
|
229
|
+
async uploadFileWithRetries(filePath, presignedUrl) {
|
|
230
|
+
const MAX_RETRIES = 3;
|
|
231
|
+
const RETRY_DELAY_MS = 1000;
|
|
232
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
233
|
+
try {
|
|
234
|
+
const ok = await this.uploadFile(filePath, presignedUrl);
|
|
235
|
+
if (ok)
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
console.error(`Upload attempt #${attempt} failed for ${filePath}:`, {
|
|
240
|
+
message: err === null || err === void 0 ? void 0 : err.message,
|
|
241
|
+
stack: err === null || err === void 0 ? void 0 : err.stack,
|
|
242
|
+
});
|
|
243
|
+
if (attempt < MAX_RETRIES) {
|
|
244
|
+
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
console.error(`Failed to upload file after ${MAX_RETRIES} retries: ${filePath}`);
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
async uploadFilesInBatches(fileUris, reportFolder, preSignedUrls) {
|
|
252
|
+
const MAX_CONCURRENCY = 5;
|
|
253
|
+
const limit = (0, p_limit_1.default)(MAX_CONCURRENCY);
|
|
254
|
+
const tasks = fileUris
|
|
255
|
+
.filter((uri) => preSignedUrls[uri])
|
|
256
|
+
.map((uri) => limit(async () => {
|
|
257
|
+
const filePath = path_1.default.join(reportFolder, uri);
|
|
258
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
259
|
+
await this.uploadFileWithRetries(filePath, preSignedUrls[uri]);
|
|
260
|
+
}
|
|
261
|
+
}));
|
|
262
|
+
await Promise.all(tasks);
|
|
263
|
+
}
|
|
132
264
|
async uploadFile(filePath, preSignedUrl) {
|
|
265
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
133
268
|
const fileStream = (0, fs_1.createReadStream)(filePath);
|
|
134
269
|
let success = true;
|
|
135
270
|
try {
|
|
@@ -143,8 +278,9 @@ class RunUploadService {
|
|
|
143
278
|
});
|
|
144
279
|
}
|
|
145
280
|
catch (error) {
|
|
146
|
-
if (process.env.
|
|
147
|
-
|
|
281
|
+
if (process.env.MODE === 'executions') {
|
|
282
|
+
const sanitized = this.sanitizeError(error);
|
|
283
|
+
console.error('❌ Error uploading file at:', filePath, 'due to', sanitized);
|
|
148
284
|
}
|
|
149
285
|
success = false;
|
|
150
286
|
}
|
|
@@ -154,9 +290,18 @@ class RunUploadService {
|
|
|
154
290
|
return success;
|
|
155
291
|
}
|
|
156
292
|
async uploadComplete(runId, projectId) {
|
|
293
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
157
296
|
const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/uploadCompletion', {
|
|
158
297
|
runId,
|
|
159
298
|
projectId,
|
|
299
|
+
browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',
|
|
300
|
+
mode: process.env.MODE === 'cloud'
|
|
301
|
+
? 'cloud'
|
|
302
|
+
: process.env.MODE === 'executions'
|
|
303
|
+
? 'executions'
|
|
304
|
+
: 'local',
|
|
160
305
|
}, {
|
|
161
306
|
headers: {
|
|
162
307
|
Authorization: 'Bearer ' + this.accessToken,
|
|
@@ -169,8 +314,25 @@ class RunUploadService {
|
|
|
169
314
|
if (response.data.status !== true) {
|
|
170
315
|
throw new Error('Failed to mark run as complete');
|
|
171
316
|
}
|
|
317
|
+
try {
|
|
318
|
+
await axios_client_1.axiosClient.post(`${constants_1.SERVICES_URI.STORAGE}/event`, {
|
|
319
|
+
event: constants_1.ActionEvents.upload_report,
|
|
320
|
+
}, {
|
|
321
|
+
headers: {
|
|
322
|
+
Authorization: 'Bearer ' + this.accessToken,
|
|
323
|
+
'x-source': 'cucumber_js',
|
|
324
|
+
'x-bvt-project-id': projectId,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
// no event tracking
|
|
330
|
+
}
|
|
172
331
|
}
|
|
173
332
|
async modifyTestCase(runId, projectId, testProgressReport) {
|
|
333
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
174
336
|
try {
|
|
175
337
|
const res = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/modifyTestCase', {
|
|
176
338
|
runId,
|
|
@@ -188,12 +350,34 @@ class RunUploadService {
|
|
|
188
350
|
if (res.data.status !== true) {
|
|
189
351
|
throw new Error('');
|
|
190
352
|
}
|
|
191
|
-
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId);
|
|
353
|
+
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId, testProgressReport.result);
|
|
192
354
|
}
|
|
193
355
|
catch (e) {
|
|
194
356
|
console.error(`failed to modify the test case: ${testProgressReport.id} ${e}`);
|
|
195
357
|
}
|
|
196
358
|
}
|
|
359
|
+
async createStatus(status) {
|
|
360
|
+
if (process.env.UPLOADREPORTS === 'false') {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (!process.env.UUID) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/scenarios/status', {
|
|
368
|
+
status: { status },
|
|
369
|
+
uuid: process.env.UUID,
|
|
370
|
+
}, {
|
|
371
|
+
headers: {
|
|
372
|
+
Authorization: 'Bearer ' + this.accessToken,
|
|
373
|
+
'x-source': 'cucumber_js',
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
console.log('Failed to send status to the server, ignoring it');
|
|
379
|
+
}
|
|
380
|
+
}
|
|
197
381
|
}
|
|
198
382
|
exports.RunUploadService = RunUploadService;
|
|
199
383
|
//# sourceMappingURL=upload_serivce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAiD;AACjD,2DAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAAyD;AAEzD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AACvD,MAAM,gBAAgB;IACpB,YAAoB,cAAsB,EAAU,WAAmB;QAAnD,mBAAc,GAAd,cAAc,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAC3E,KAAK,CAAC,iBAAiB,CAAC,IAAY;QAClC,IAAI;YACF,MAAM,YAAY,GAAG,MAAM,0BAAW,CAAC,IAAI,CACzC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AG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAE,aAAa;aAC1B;SACF,CACF,CAAA;QACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;QACD,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;IACH,CAAC;IACD,KAAK,CAAC,cAAc,CAClB,KAAa,EACb,SAAiB,EACjB,kBAAoC;QAEpC,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,0BAAW,CAAC,IAAI,CAChC,IAAI,CAAC,cAAc,GAAG,+BAA+B,EACrD;gBACE,KAAK;gBACL,SAAS;gBACT,kBAAkB;aACnB,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;YACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;aACpB;YACD,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;gBAC5B,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;aACpB;YACD,IAAA,sCAAa,EAAC,KAAK,EAAE,SAAS,CAAC,CAAA;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,mCAAmC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE,CAChE,CAAA;SACF;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync } from 'fs'\nimport fs from 'fs/promises'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport { logReportLink } from '../bvt_analysis_formatter'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string) {\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async upload(formData: FormData) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string\n ) {\n const fileUris = []\n //iterate over all the files in the JsonCommand.screenshotId and insert them into the fileUris array\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId) {\n fileUris.push(\n 'screenshots' + '/' + String(command.screenshotId) + '.png'\n )\n }\n }\n }\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\n //upload all the files in the fileUris array\n try {\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/createNewTestCase',\n {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n logReportLink(runId, projectId)\n } catch (e) {\n console.error(`failed to upload the test case: ${testCaseReport.id} ${e}`)\n }\n }\n async uploadFile(filePath: string, preSignedUrl: string) {\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.NODE_ENV_BLINQ === 'dev') {\n console.error('Error uploading file:', error)\n }\n success = false\n } finally {\n fileStream.close()\n }\n return success\n }\n async uploadComplete(runId: string, projectId: string) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n}\n\nexport { RunUploadService }\n"]}
|
|
1
|
+
{"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAuE;AACvE,2DAA4B;AAC5B,sDAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAIkC;AAClC,2CAAwD;AAExD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAevD,MAAM,gBA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AO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,mCAAmC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE,CAChE,CAAA;SACF;IACH,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,OAAO,EAAE;YACzC,OAAM;SACP;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;YACrB,OAAM;SACP;QAED,IAAI;YACF,MAAM,0BAAW,CAAC,IAAI,CACpB,IAAI,CAAC,cAAc,GAAG,mBAAmB,EACzC;gBACE,MAAM,EAAE,EAAE,MAAM,EAAE;gBAClB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;aACvB,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync, write, writeFileSync } from 'fs'\nimport fs from 'fs/promises'\nimport pLimit from 'p-limit'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport {\n createNewTestCase,\n logReportLink,\n postUploadReportEvent,\n} from '../bvt_analysis_formatter'\nimport { ActionEvents, SERVICES_URI } from './constants'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport interface RootCauseProps {\n status: boolean\n analysis: string\n failedStep: number\n failClass: string\n}\n\nexport interface FinishTestCaseResponse {\n status: true\n rootCause: RootCauseProps\n report: JsonTestProgress\n}\n\nclass RunUploadService {\n constructor(\n private runsApiBaseURL: string,\n private accessToken: string\n ) {}\n async createRunDocument(name: string, env: any) {\n if (process.env.UPLOADREPORTS === 'false') {\n console.log('Skipping report upload as UPLOADREPORTS is set to false')\n return { id: 'local-run', projectId: 'local-project' }\n }\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : 'main',\n video_id: process.env.VIDEO_ID,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n env: { name: env?.name, baseUrl: env?.baseUrl },\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async updateProjectAnalytics(projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/project/updateAIRecoveryCount',\n {\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.error('Failed to update project metadata:', error)\n }\n }\n async upload(formData: FormData) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return {}\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string,\n rerunId?: string\n ) {\n if (process.env.UPLOADREPORTS === 'false') return null\n\n const fileUris: string[] = []\n\n // Collect screenshot + trace + logs\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId)\n fileUris.push(`screenshots/${command.screenshotId}.png`)\n }\n if (step.traceFilePath) fileUris.push(`trace/${step.traceFilePath}`)\n }\n if (testCaseReport.logFileId)\n fileUris.push(`editorLogs/testCaseLog_${testCaseReport.logFileId}.log`)\n if (testCaseReport.traceFileId)\n fileUris.push(`trace/${testCaseReport.traceFileId}`)\n\n // 🔹 UPLOAD FILES\n try {\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\n await this.uploadFilesInBatches(fileUris, reportFolder, preSignedUrls)\n } catch (error: any) {\n console.error('🟥 Error uploading files:', {\n message: error?.message,\n stack: error?.stack,\n })\n }\n\n // 🔹 UPLOAD FINAL TEST REPORT\n try {\n const mode =\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local'\n let rerunIdFinal = process.env.RETRY_ID || null\n if (rerunId)\n rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`\n if (mode === 'executions')\n testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id\n\n const payload = {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n browser: process.env.BROWSER || 'chromium',\n mode,\n rerunId: rerunIdFinal,\n video_id: process.env.VIDEO_ID,\n }\n\n const data = await createNewTestCase(\n payload,\n this.runsApiBaseURL,\n this.accessToken\n )\n await postUploadReportEvent(projectId, this.accessToken)\n logReportLink(runId, projectId, testCaseReport.result)\n return data\n } catch (e: any) {\n console.error('🟥 Failed to upload test case:', {\n testCaseId: testCaseReport.id,\n message: e?.message,\n status: e?.response?.status,\n responseSnippet: e?.response?.data?.toString()?.slice(0, 300),\n stack: e?.stack,\n })\n return null\n }\n }\n\n /**\n * Improving error logging\n * 🔧 Sanitizes Axios errors to avoid dumping Cloudflare HTML (524, 502, etc.)\n */\n private sanitizeError(error: any) {\n // Handle Axios-style errors with response\n if (error?.response) {\n const { data, status } = error.response\n\n // If Cloudflare or HTML error page → return a short meaningful message\n if (typeof data === 'string' && data.includes('<!DOCTYPE html')) {\n return `[HTML_ERROR_PAGE] status=${status} - likely Cloudflare timeout or proxy error`\n }\n\n // If data is a JSON object, stringify it with indentation for readability\n if (typeof data === 'object') {\n return JSON.stringify(data, null, 2) // Pretty-print the JSON response\n }\n\n // If response is a string (could be an error message), return it trimmed\n return data?.trim() || `Unknown response data (status: ${status})`\n }\n\n // System / network errors (e.g., if Axios cannot reach the server)\n if (error?.message) {\n return error.message\n }\n\n // If the error has a stack (for debugging purposes)\n if (error?.stack) {\n return `${error.message}\\n${error.stack}`\n }\n\n // If it's a generic error object, attempt to stringify it in a readable format\n return JSON.stringify(\n error,\n (key, value) => {\n // Avoid circular references or sensitive data\n if (key === 'password' || key === 'accessToken') return '[REDACTED]'\n return value\n },\n 2\n ) // Pretty-print the error object with indentation\n }\n async uploadFileWithRetries(filePath: string, presignedUrl: string) {\n const MAX_RETRIES = 3\n const RETRY_DELAY_MS = 1000\n for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n try {\n const ok = await this.uploadFile(filePath, presignedUrl)\n if (ok) return true\n } catch (err: any) {\n console.error(`Upload attempt #${attempt} failed for ${filePath}:`, {\n message: err?.message,\n stack: err?.stack,\n })\n if (attempt < MAX_RETRIES) {\n await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt))\n }\n }\n }\n console.error(\n `Failed to upload file after ${MAX_RETRIES} retries: ${filePath}`\n )\n return false\n }\n\n async uploadFilesInBatches(\n fileUris: string[],\n reportFolder: string,\n preSignedUrls: Record<string, string>\n ) {\n const MAX_CONCURRENCY = 5\n const limit = pLimit(MAX_CONCURRENCY)\n const tasks = fileUris\n .filter((uri) => preSignedUrls[uri])\n .map((uri) =>\n limit(async () => {\n const filePath = path.join(reportFolder, uri)\n if (existsSync(filePath)) {\n await this.uploadFileWithRetries(filePath, preSignedUrls[uri])\n }\n })\n )\n\n await Promise.all(tasks)\n }\n\n async uploadFile(filePath: string, preSignedUrl: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return true\n }\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.MODE === 'executions') {\n const sanitized = this.sanitizeError(error)\n console.error(\n '❌ Error uploading file at:',\n filePath,\n 'due to',\n sanitized\n )\n }\n success = false\n } finally {\n fileStream.close()\n }\n return success\n }\n async uploadComplete(runId: string, projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId, testProgressReport.result)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n async createStatus(status: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n if (!process.env.UUID) {\n return\n }\n\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/scenarios/status',\n {\n status: { status },\n uuid: process.env.UUID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.log('Failed to send status to the server, ignoring it')\n }\n }\n}\n\nexport { RunUploadService }\n"]}
|
|
@@ -38,7 +38,11 @@ const URL = process.env.NODE_ENV_BLINQ === 'dev'
|
|
|
38
38
|
? 'http://localhost:5001/api/runs'
|
|
39
39
|
: process.env.NODE_ENV_BLINQ === 'stage'
|
|
40
40
|
? 'https://stage.api.blinq.io/api/runs'
|
|
41
|
-
:
|
|
41
|
+
: process.env.NODE_ENV_BLINQ === 'prod'
|
|
42
|
+
? 'https://api.blinq.io/api/runs'
|
|
43
|
+
: !process.env.NODE_ENV_BLINQ
|
|
44
|
+
? 'https://api.blinq.io/api/runs'
|
|
45
|
+
: `${process.env.NODE_ENV_BLINQ}/api/runs`;
|
|
42
46
|
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
43
47
|
const BATCH_SIZE = 10;
|
|
44
48
|
const MAX_RETRIES = 3;
|
|
@@ -52,7 +56,7 @@ class ReportUploader {
|
|
|
52
56
|
this.reportGenerator = reportGenerator;
|
|
53
57
|
}
|
|
54
58
|
async uploadRun(report, runName) {
|
|
55
|
-
const runDoc = await this.uploadService.createRunDocument(runName);
|
|
59
|
+
const runDoc = await this.uploadService.createRunDocument(runName, report.env);
|
|
56
60
|
const runDocId = runDoc._id;
|
|
57
61
|
const reportFolder = this.reportGenerator.reportFolder;
|
|
58
62
|
if (!fs_1.default.existsSync(reportFolder)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,qDAAmD;AAEnD,0DAAgC;AAChC,yCAAsC;AACtC,kDAAyB;AACzB,gDAAuB;AACvB,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,G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CAAC,CAAA;AAED,MAAM,WAAW,GAAG,CAAC,YAAoB,EAAE,YAAoB,EAAE,EAAE;IACjE,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;IAC1D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAChC,OAAO,EAAE,CAAA;KACV;IACD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA","sourcesContent":["import axios from 'axios'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n} from './report_generator'\nimport { RunUploadService } from './upload_serivce'\n\nimport FormData from 'form-data'\nimport fs, { writeFileSync } from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? 'https://stage.api.blinq.io/api/runs'\n : 'https://api.blinq.io/api/runs'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(runName)\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n if (process.env.NODE_ENV_BLINQ === 'local') {\n const formData = new FormData()\n const zipPath = await this.createZip(reportFolder, report)\n formData.append(runDocId, fs.readFileSync(zipPath), 'report.zip')\n await this.uploadService.upload(formData)\n } else {\n const fileUris = [\n ...getFileUris(reportFolder, 'screenshots'),\n ...getFileUris(reportFolder, 'trace'),\n 'report.json',\n 'network.json',\n ]\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await this.uploadService.uploadComplete(runDocId, runDoc.project_id)\n } catch (err) {\n throw new Error('Failed to upload all the files')\n }\n }\n return { runId: runDoc._id, projectId: runDoc.project_id }\n }\n\n async modifyTestCase(testCase: JsonTestProgress) {\n const runId = process.env.RUN_ID\n if (!runId) {\n return\n }\n const projectId = process.env.PROJECT_ID\n if (!projectId) {\n return\n }\n await this.uploadService.modifyTestCase(runId, projectId, testCase)\n }\n async createZip(reportFolder: string | null, report: JsonReport) {\n if (reportFolder === null) {\n console.error('report folder is empty')\n console.error('it is likey that there are no scenarios to run')\n throw new Error('Empty report folder')\n }\n const zip = new JSZip()\n zip.file('report.json', JSON.stringify(report, null, 2))\n const folder = zip.folder('screenshots')\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n files.forEach((file) => {\n folder.file(\n file,\n fs.readFileSync(path.join(reportFolder, 'screenshots', file))\n )\n })\n const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })\n // save zip file\n const zipPath = path.join(reportFolder, 'report.zip')\n fs.writeFileSync(zipPath, new Uint8Array(zipBuffer))\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\n }\n}\n\nconst getFileUrisScreenShotDir = (reportFolder: string) => {\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n\n return files.map((file) => ['screenshots', file].join('/'))\n}\n\nconst getFileUris = (reportFolder: string, targetFolder: string) => {\n const resultFolder = path.join(reportFolder, targetFolder)\n if (!fs.existsSync(resultFolder)) {\n return []\n }\n const files = fs.readdirSync(resultFolder)\n return files.map((file) => [targetFolder, file].join('/'))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,qDAAmD;AAEnD,0DAAgC;AAChC,yCAAsC;AACtC,kDAAyB;AACzB,gDAAuB;AACvB,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;QACtC,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;YACtC,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM;gBACrC,CAAC,CAAC,+BAA+B;gBACjC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc;oBAC3B,CAAC,C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;IACjE,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;IAC1D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAChC,OAAO,EAAE,CAAA;KACV;IACD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAA","sourcesContent":["import axios from 'axios'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n} from './report_generator'\nimport { RunUploadService } from './upload_serivce'\n\nimport FormData from 'form-data'\nimport fs, { writeFileSync } from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : process.env.NODE_ENV_BLINQ === 'stage'\n ? 'https://stage.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'prod'\n ? 'https://api.blinq.io/api/runs'\n : !process.env.NODE_ENV_BLINQ\n ? 'https://api.blinq.io/api/runs'\n : `${process.env.NODE_ENV_BLINQ}/api/runs`\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(\n runName,\n report.env\n )\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n if (process.env.NODE_ENV_BLINQ === 'local') {\n const formData = new FormData()\n const zipPath = await this.createZip(reportFolder, report)\n formData.append(runDocId, fs.readFileSync(zipPath), 'report.zip')\n await this.uploadService.upload(formData)\n } else {\n const fileUris = [\n ...getFileUris(reportFolder, 'screenshots'),\n ...getFileUris(reportFolder, 'trace'),\n 'report.json',\n 'network.json',\n ]\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n\n for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {\n const batch = fileUris.slice(\n i,\n Math.min(i + BATCH_SIZE, fileUris.length)\n )\n await Promise.all(\n batch\n .filter((fileUri) => preSignedUrls[fileUri])\n .map(async (fileUri) => {\n for (let j = 0; j < MAX_RETRIES; j++) {\n const success = await this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n await this.uploadService.uploadComplete(runDocId, runDoc.project_id)\n } catch (err) {\n throw new Error('Failed to upload all the files')\n }\n }\n return { runId: runDoc._id, projectId: runDoc.project_id }\n }\n\n async modifyTestCase(testCase: JsonTestProgress) {\n const runId = process.env.RUN_ID\n if (!runId) {\n return\n }\n const projectId = process.env.PROJECT_ID\n if (!projectId) {\n return\n }\n await this.uploadService.modifyTestCase(runId, projectId, testCase)\n }\n async createZip(reportFolder: string | null, report: JsonReport) {\n if (reportFolder === null) {\n console.error('report folder is empty')\n console.error('it is likey that there are no scenarios to run')\n throw new Error('Empty report folder')\n }\n const zip = new JSZip()\n zip.file('report.json', JSON.stringify(report, null, 2))\n const folder = zip.folder('screenshots')\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n files.forEach((file) => {\n folder.file(\n file,\n fs.readFileSync(path.join(reportFolder, 'screenshots', file))\n )\n })\n const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })\n // save zip file\n const zipPath = path.join(reportFolder, 'report.zip')\n fs.writeFileSync(zipPath, new Uint8Array(zipBuffer))\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\n }\n}\n\nconst getFileUrisScreenShotDir = (reportFolder: string) => {\n const files = fs.readdirSync(path.join(reportFolder, 'screenshots'))\n\n return files.map((file) => ['screenshots', file].join('/'))\n}\n\nconst getFileUris = (reportFolder: string, targetFolder: string) => {\n const resultFolder = path.join(reportFolder, targetFolder)\n if (!fs.existsSync(resultFolder)) {\n return []\n }\n const files = fs.readdirSync(resultFolder)\n return files.map((file) => [targetFolder, file].join('/'))\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import SummaryFormatter from './summary_formatter';
|
|
2
2
|
import { IFormatterOptions } from './index';
|
|
3
3
|
import * as messages from '@cucumber/messages';
|
|
4
|
-
|
|
4
|
+
type ITestStepFinished = messages.TestStepFinished;
|
|
5
5
|
export default class ProgressFormatter extends SummaryFormatter {
|
|
6
6
|
static readonly documentation: string;
|
|
7
7
|
constructor(options: IFormatterOptions);
|
|
8
8
|
logProgress({ testStepResult: { status } }: ITestStepFinished): void;
|
|
9
9
|
}
|
|
10
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEhD,6DAA8C;AAI9C,MAAM,wBAAwB,G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'\nimport { doesHaveValue } from '../value_checker'\nimport { IFormatterOptions } from './index'\nimport * as messages from '@cucumber/messages'\
|
|
1
|
+
{"version":3,"file":"progress_formatter.js","sourceRoot":"","sources":["../../src/formatter/progress_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAAkD;AAClD,oDAAgD;AAEhD,6DAA8C;AAI9C,MAAM,wBAAwB,GAC5B,IAAI,GAAG,CAAC;IACN,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;IAC9C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC;IAC3C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC;IAC5C,CAAC,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,CAAC;CAC/C,CAAC,CAAA;AAEJ,MAAqB,iBAAkB,SAAQ,2BAAgB;IAI7D,YAAY,OAA0B;QACpC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;aACjB;iBAAM,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;gBACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAA;aAC5C;QACH,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;IAED,WAAW,CAAC,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,EAAqB;QAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAC/C,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CACrC,CAAA;QACD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrB,CAAC;;AApBH,oCAqBC;AApBwB,+BAAa,GAClC,oCAAoC,CAAA","sourcesContent":["import SummaryFormatter from './summary_formatter'\nimport { doesHaveValue } from '../value_checker'\nimport { IFormatterOptions } from './index'\nimport * as messages from '@cucumber/messages'\ntype IEnvelope = messages.Envelope\ntype ITestStepFinished = messages.TestStepFinished\n\nconst STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =\n new Map([\n [messages.TestStepResultStatus.AMBIGUOUS, 'A'],\n [messages.TestStepResultStatus.FAILED, 'F'],\n [messages.TestStepResultStatus.PASSED, '.'],\n [messages.TestStepResultStatus.PENDING, 'P'],\n [messages.TestStepResultStatus.SKIPPED, '-'],\n [messages.TestStepResultStatus.UNDEFINED, 'U'],\n ])\n\nexport default class ProgressFormatter extends SummaryFormatter {\n public static readonly documentation: string =\n 'Prints one character per scenario.'\n\n constructor(options: IFormatterOptions) {\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.log('\\n\\n')\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.logProgress(envelope.testStepFinished)\n }\n })\n super(options)\n }\n\n logProgress({ testStepResult: { status } }: ITestStepFinished): void {\n const character = this.colorFns.forStatus(status)(\n STATUS_CHARACTER_MAPPING.get(status)\n )\n this.log(character)\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAAgD;AAChD,oDAAgD;AAChD,6DAA8C;AAG9C,MAAqB,iBAAkB,SAAQ,UAAS;IAItD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC;gBAClC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;aAChB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,IACE,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAClE;oBACA,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,CAAC;;AA9BH,oCA+BC;AA9BwB,+BAAa,GAClC,iIAAiI,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { parseTestCaseAttempt } from './helpers'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\
|
|
1
|
+
{"version":3,"file":"snippets_formatter.js","sourceRoot":"","sources":["../../src/formatter/snippets_formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAiD;AACjD,uCAAgD;AAChD,oDAAgD;AAChD,6DAA8C;AAG9C,MAAqB,iBAAkB,SAAQ,UAAS;IAItD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAmB,EAAE,EAAE;YAC9D,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW;QACT,MAAM,QAAQ,GAAa,EAAE,CAAA;QAC7B,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE;YACxE,MAAM,MAAM,GAAG,IAAA,8BAAoB,EAAC;gBAClC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;aAChB,CAAC,CAAA;YACF,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACpC,IACE,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAClE;oBACA,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;iBAChC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,CAAC;;AA9BH,oCA+BC;AA9BwB,+BAAa,GAClC,iIAAiI,CAAA","sourcesContent":["import Formatter, { IFormatterOptions } from './'\nimport { parseTestCaseAttempt } from './helpers'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\ntype IEnvelope = messages.Envelope\n\nexport default class SnippetsFormatter extends Formatter {\n public static readonly documentation: string =\n \"The Snippets Formatter doesn't output anything regarding the test run; it just prints snippets to implement any undefined steps\"\n\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: IEnvelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.logSnippets()\n }\n })\n }\n\n logSnippets(): void {\n const snippets: string[] = []\n this.eventDataCollector.getTestCaseAttempts().forEach((testCaseAttempt) => {\n const parsed = parseTestCaseAttempt({\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n })\n parsed.testSteps.forEach((testStep) => {\n if (\n testStep.result.status === messages.TestStepResultStatus.UNDEFINED\n ) {\n snippets.push(testStep.snippet)\n }\n })\n })\n this.log(snippets.join('\\n\\n'))\n }\n}\n"]}
|
|
@@ -8,6 +8,7 @@ const _1 = __importDefault(require("./"));
|
|
|
8
8
|
const value_checker_1 = require("../value_checker");
|
|
9
9
|
const issue_helpers_1 = require("./helpers/issue_helpers");
|
|
10
10
|
const time_1 = require("../time");
|
|
11
|
+
const bvt_analysis_formatter_1 = require("./bvt_analysis_formatter");
|
|
11
12
|
class SummaryFormatter extends _1.default {
|
|
12
13
|
constructor(options) {
|
|
13
14
|
super(options);
|
|
@@ -43,6 +44,9 @@ class SummaryFormatter extends _1.default {
|
|
|
43
44
|
if (warnings.length > 0) {
|
|
44
45
|
this.logIssues({ issues: warnings, title: 'Warnings' });
|
|
45
46
|
}
|
|
47
|
+
if (bvt_analysis_formatter_1.globalReportLink) {
|
|
48
|
+
console.log(`Report link: ${bvt_analysis_formatter_1.globalReportLink}\n`);
|
|
49
|
+
}
|
|
46
50
|
this.log((0, helpers_1.formatSummary)({
|
|
47
51
|
colorFns: this.colorFns,
|
|
48
52
|
testCaseAttempts,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary_formatter.js","sourceRoot":"","sources":["../../src/formatter/summary_formatter.ts"],"names":[],"mappings":";;;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AAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,eAAe;gBACf,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aACxC,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;;AAnFH,mCAoFC;AAnFwB,8BAAa,GAClC,yCAAyC,CAAA","sourcesContent":["import { formatIssue, formatSummary, isFailure, isWarning } from './helpers'\nimport Formatter, { IFormatterOptions } from './'\nimport { doesHaveValue } from '../value_checker'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { formatUndefinedParameterTypes } from './helpers/issue_helpers'\nimport { durationBetweenTimestamps } from '../time'\nimport { globalReportLink } from './bvt_analysis_formatter'\n\ninterface ILogIssuesRequest {\n issues: ITestCaseAttempt[]\n title: string\n}\n\nexport default class SummaryFormatter extends Formatter {\n public static readonly documentation: string =\n 'Summary output of feature and scenarios'\n\n constructor(options: IFormatterOptions) {\n super(options)\n let testRunStartedTimestamp: messages.Timestamp\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunStarted)) {\n testRunStartedTimestamp = envelope.testRunStarted.timestamp\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const testRunFinishedTimestamp = envelope.testRunFinished.timestamp\n this.logSummary(\n durationBetweenTimestamps(\n testRunStartedTimestamp,\n testRunFinishedTimestamp\n )\n )\n }\n })\n }\n\n logSummary(testRunDuration: messages.Duration): void {\n const failures: ITestCaseAttempt[] = []\n const warnings: ITestCaseAttempt[] = []\n const testCaseAttempts = this.eventDataCollector.getTestCaseAttempts()\n testCaseAttempts.forEach((testCaseAttempt) => {\n if (\n isFailure(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n failures.push(testCaseAttempt)\n } else if (\n isWarning(\n testCaseAttempt.worstTestStepResult,\n testCaseAttempt.willBeRetried\n )\n ) {\n warnings.push(testCaseAttempt)\n }\n })\n if (this.eventDataCollector.undefinedParameterTypes.length > 0) {\n this.log(\n formatUndefinedParameterTypes(\n this.eventDataCollector.undefinedParameterTypes\n )\n )\n }\n if (failures.length > 0) {\n this.logIssues({ issues: failures, title: 'Failures' })\n }\n if (warnings.length > 0) {\n this.logIssues({ issues: warnings, title: 'Warnings' })\n }\n if (globalReportLink) {\n console.log(`Report link: ${globalReportLink}\\n`)\n }\n this.log(\n formatSummary({\n colorFns: this.colorFns,\n testCaseAttempts,\n testRunDuration,\n })\n )\n }\n\n logIssues({ issues, title }: ILogIssuesRequest): void {\n this.log(`${title}:\\n\\n`)\n issues.forEach((testCaseAttempt, index) => {\n this.log(\n formatIssue({\n colorFns: this.colorFns,\n number: index + 1,\n snippetBuilder: this.snippetBuilder,\n supportCodeLibrary: this.supportCodeLibrary,\n testCaseAttempt,\n printAttachments: this.printAttachments,\n })\n )\n })\n }\n}\n"]}
|