@dev-blinq/cucumber-js 1.0.88-main → 1.0.89-main
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/download-install.js +0 -0
- package/lib/formatter/bvt_analysis_formatter.d.ts +1 -1
- package/lib/formatter/bvt_analysis_formatter.js +56 -32
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/feature_data_format.js +3 -0
- package/lib/formatter/feature_data_format.js.map +1 -1
- package/lib/formatter/helpers/report_generator.d.ts +14 -1
- package/lib/formatter/helpers/report_generator.js +67 -7
- package/lib/formatter/helpers/report_generator.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +3 -0
- package/lib/formatter/helpers/upload_serivce.js +76 -0
- package/lib/formatter/helpers/upload_serivce.js.map +1 -1
- package/lib/formatter/helpers/uploader.d.ts +2 -1
- package/lib/formatter/helpers/uploader.js +22 -2
- package/lib/formatter/helpers/uploader.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 +1 -1
package/bin/download-install.js
CHANGED
|
File without changes
|
|
@@ -14,6 +14,6 @@ export default class BVTAnalysisFormatter extends Formatter {
|
|
|
14
14
|
private uploadFinalReport;
|
|
15
15
|
private retrain;
|
|
16
16
|
private call_cucumber_client;
|
|
17
|
-
private logReportLink;
|
|
18
17
|
private getAppDataDir;
|
|
19
18
|
}
|
|
19
|
+
export declare function logReportLink(runId: string, projectId: string): void;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logReportLink = void 0;
|
|
6
7
|
const child_process_1 = require("child_process");
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const promises_1 = require("fs/promises");
|
|
@@ -26,7 +27,7 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
26
27
|
throw new Error('TOKEN must be set');
|
|
27
28
|
}
|
|
28
29
|
options.eventBroadcaster.on('envelope', async (envelope) => {
|
|
29
|
-
this.reportGenerator.handleMessage(envelope);
|
|
30
|
+
await this.reportGenerator.handleMessage(envelope);
|
|
30
31
|
if ((0, value_checker_1.doesHaveValue)(envelope.meta) &&
|
|
31
32
|
(0, value_checker_1.doesHaveValue)(envelope.meta.runName)) {
|
|
32
33
|
this.runName = envelope.meta.runName;
|
|
@@ -38,7 +39,7 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
38
39
|
await this.analyzeReport(report);
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
|
-
await this.uploadReport(report)
|
|
42
|
+
// await this.uploadReport(report)
|
|
42
43
|
}
|
|
43
44
|
this.exit = true;
|
|
44
45
|
}
|
|
@@ -54,9 +55,22 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
54
55
|
async finished() {
|
|
55
56
|
await new Promise((resolve) => {
|
|
56
57
|
const checkInterval = setInterval(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let anyRem;
|
|
59
|
+
if (process.env.UPLOADING_TEST_CASE) {
|
|
60
|
+
anyRem = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
anyRem = undefined;
|
|
64
|
+
}
|
|
65
|
+
if (this.exit && (!anyRem || anyRem.length === 0)) {
|
|
66
|
+
// clearInterval(checkInterval)
|
|
67
|
+
// resolve(null)
|
|
68
|
+
if (this.reportGenerator.getReport().result.status === 'FAILED') {
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
60
74
|
}
|
|
61
75
|
}, 100); // check every 100ms
|
|
62
76
|
});
|
|
@@ -70,27 +84,22 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
70
84
|
if (process.env.NO_RETRAIN === 'false') {
|
|
71
85
|
this.log('Retraining is skipped since the failed step contains an API request\n');
|
|
72
86
|
}
|
|
73
|
-
const uploadSuccessful = await this.uploadFinalReport(report)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
process.exit(1);
|
|
87
|
+
// const uploadSuccessful = await this.uploadFinalReport(report)
|
|
88
|
+
// process.exit(0)
|
|
89
|
+
this.exit = true;
|
|
90
|
+
return;
|
|
78
91
|
}
|
|
79
92
|
//checking if the type of report.result is JsonResultFailed or not
|
|
80
93
|
this.log('Some tests failed, starting the retraining...\n');
|
|
81
94
|
if (!('startTime' in report.result) || !('endTime' in report.result)) {
|
|
82
95
|
this.log('Unknown error occured,not retraining\n');
|
|
83
|
-
await this.uploadFinalReport(report);
|
|
84
96
|
return;
|
|
85
97
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {
|
|
89
|
-
process.exit(0);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
98
|
+
await this.processTestCases(report);
|
|
99
|
+
if (this.reportGenerator.getReport().result.status === 'FAILED') {
|
|
92
100
|
process.exit(1);
|
|
93
101
|
}
|
|
102
|
+
process.exit(0);
|
|
94
103
|
}
|
|
95
104
|
async processTestCases(report) {
|
|
96
105
|
const finalTestCases = [];
|
|
@@ -121,6 +130,12 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
121
130
|
if (!retrainStats) {
|
|
122
131
|
return testCase;
|
|
123
132
|
}
|
|
133
|
+
if (retrainStats.result.status === 'PASSED') {
|
|
134
|
+
await this.uploader.modifyTestCase({
|
|
135
|
+
...testCase,
|
|
136
|
+
retrainStats,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
124
139
|
return {
|
|
125
140
|
...testCase,
|
|
126
141
|
retrainStats,
|
|
@@ -130,7 +145,7 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
130
145
|
let success = true;
|
|
131
146
|
try {
|
|
132
147
|
const { projectId, runId } = await this.uploader.uploadRun(finalReport, this.runName);
|
|
133
|
-
|
|
148
|
+
logReportLink(runId, projectId);
|
|
134
149
|
}
|
|
135
150
|
catch (err) {
|
|
136
151
|
this.log('Error uploading report\n');
|
|
@@ -139,6 +154,14 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
139
154
|
}
|
|
140
155
|
success = false;
|
|
141
156
|
}
|
|
157
|
+
finally {
|
|
158
|
+
try {
|
|
159
|
+
(0, fs_1.writeFileSync)(path_1.default.join(this.reportGenerator.reportFolder, 'report.json'), JSON.stringify(finalReport, null, 2), 'utf-8');
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
console.error('failed to write report.json to local disk');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
142
165
|
//this.log(JSON.stringify(finalReport, null, 2))
|
|
143
166
|
return success;
|
|
144
167
|
}
|
|
@@ -200,20 +223,6 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
200
223
|
});
|
|
201
224
|
});
|
|
202
225
|
}
|
|
203
|
-
logReportLink(runId, projectId) {
|
|
204
|
-
let reportLinkBaseUrl = 'https://www.app.blinq.io';
|
|
205
|
-
if (process.env.NODE_ENV_BLINQ === 'local') {
|
|
206
|
-
reportLinkBaseUrl = 'http://localhost:3000';
|
|
207
|
-
}
|
|
208
|
-
else if (process.env.NODE_ENV_BLINQ === 'dev') {
|
|
209
|
-
reportLinkBaseUrl = 'https://dev.app.blinq.io';
|
|
210
|
-
}
|
|
211
|
-
else if (process.env.NODE_ENV_BLINQ === 'stage') {
|
|
212
|
-
reportLinkBaseUrl = 'https://stage.app.blinq.io';
|
|
213
|
-
}
|
|
214
|
-
const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`;
|
|
215
|
-
this.log(`Report link: ${reportLink}\n`);
|
|
216
|
-
}
|
|
217
226
|
getAppDataDir() {
|
|
218
227
|
if (process.env.BLINQ_APPDATA_DIR) {
|
|
219
228
|
return process.env.BLINQ_APPDATA_DIR;
|
|
@@ -234,4 +243,19 @@ class BVTAnalysisFormatter extends _1.default {
|
|
|
234
243
|
}
|
|
235
244
|
}
|
|
236
245
|
exports.default = BVTAnalysisFormatter;
|
|
246
|
+
function logReportLink(runId, projectId) {
|
|
247
|
+
let reportLinkBaseUrl = 'https://app.blinq.io';
|
|
248
|
+
if (process.env.NODE_ENV_BLINQ === 'local') {
|
|
249
|
+
reportLinkBaseUrl = 'http://localhost:3000';
|
|
250
|
+
}
|
|
251
|
+
else if (process.env.NODE_ENV_BLINQ === 'dev') {
|
|
252
|
+
reportLinkBaseUrl = 'https://dev.app.blinq.io';
|
|
253
|
+
}
|
|
254
|
+
else if (process.env.NODE_ENV_BLINQ === 'stage') {
|
|
255
|
+
reportLinkBaseUrl = 'https://stage.app.blinq.io';
|
|
256
|
+
}
|
|
257
|
+
const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`;
|
|
258
|
+
console.log(`Report link: ${reportLink}\n`);
|
|
259
|
+
}
|
|
260
|
+
exports.logReportLink = logReportLink;
|
|
237
261
|
//# sourceMappingURL=bvt_analysis_formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;AACA,iDAAqC;AACrC,2BAA6C;AAC7C,0CAAsD;AACtD,gDAAuB;AACvB,6BAA6B;AAC7B,yCAAgD;AAChD,oDAAgD;AAChD,kFAKmC;AACnC,kEAA+C;AAC/C,4CAAmB;AACnB,+BAA6C;AAC7C,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQ/B,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QANR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI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cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;gBAC/C,MAAK;SACR;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AA/QD,uCA+QC","sourcesContent":["import { Envelope, Meta } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport { readFileSync, existsSync } from 'fs'\nimport { mkdir, unlink, writeFile } from 'fs/promises'\nimport path from 'path'\nimport { tmpName } from 'tmp'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n JsonTestResult,\n RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\nimport os from 'os'\nimport { getProjectByAccessKey } from './api'\n//User token\nconst TOKEN = process.env.TOKEN\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\nexport default class BVTAnalysisFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n private exit = false\n private START: number\n private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n if (this.exit) {\n clearInterval(checkInterval)\n resolve(null)\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (\n report.result.status === 'PASSED' ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (report.result.status === 'PASSED') {\n this.log('No test failed. No need to retrain\\n')\n }\n if (process.env.NO_RETRAIN === 'false') {\n this.log(\n 'Retraining is skipped since the failed step contains an API request\\n'\n )\n }\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful) {\n process.exit(0)\n }\n\n process.exit(1)\n }\n\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed, starting the retraining...\\n')\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n await this.uploadFinalReport(report)\n return\n }\n const finalReport = await this.processTestCases(report)\n const uploadSuccessful = await this.uploadFinalReport(finalReport)\n if (finalReport.result.status !== 'FAILED' && uploadSuccessful) {\n process.exit(0)\n } else {\n process.exit(1)\n }\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n const finalTestCases = []\n for (const testCase of report.testCases) {\n const modifiedTestCase = await this.processTestCase(testCase, report)\n\n finalTestCases.push(modifiedTestCase)\n }\n const finalResult = finalTestCases.some(\n (tc) => tc.result.status !== 'PASSED'\n )\n ? report.result\n : ({\n ...report.result,\n status: 'PASSED',\n } as JsonTestResult)\n return {\n result: finalResult,\n testCases: finalTestCases,\n env: report.env,\n }\n }\n private async processTestCase(\n testCase: JsonTestProgress,\n report: JsonReport\n ): Promise<JsonTestProgress> {\n if (testCase.result.status === 'PASSED') {\n return testCase\n }\n const failedTestSteps = testCase.steps\n .map((step, i) => (step.result.status === 'FAILED' ? i : null))\n .filter((i) => i !== null)\n const retrainStats = await this.retrain(failedTestSteps, testCase)\n\n if (!retrainStats) {\n return testCase\n }\n\n return {\n ...testCase,\n retrainStats,\n }\n }\n\n private async uploadFinalReport(finalReport: JsonReport) {\n let success = true\n try {\n const { projectId, runId } = await this.uploader.uploadRun(\n finalReport,\n this.runName\n )\n this.logReportLink(runId, projectId)\n } catch (err) {\n this.log('Error uploading report\\n')\n if ('stack' in err) {\n this.log(err.stack)\n }\n success = false\n }\n\n //this.log(JSON.stringify(finalReport, null, 2))\n return success\n }\n private async retrain(\n failedTestCases: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n const data = await getProjectByAccessKey(TOKEN)\n const currentTimestampInSeconds = Math.floor(Date.now() / 1000)\n if (data.project.expriration_date < currentTimestampInSeconds) {\n console.log(\n 'Warning: Your project has expired, retraining is restricted. Please contact sales.'\n )\n process.exit(1)\n }\n return await this.call_cucumber_client(failedTestCases, testCase)\n }\n\n private async call_cucumber_client(\n stepsToRetrain: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n return new Promise((resolve, reject) => {\n const cucumber_client_path = path.resolve(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber_client',\n 'bin',\n 'client',\n 'cucumber.js'\n )\n\n const args: string[] = [\n process.cwd(),\n path.join(process.cwd(), testCase.uri),\n `${testCase.scenarioName}`,\n 'undefined',\n `${stepsToRetrain.join(',')}`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=${process.env.BLINQ_ENV}`)\n }\n\n if (!existsSync(path.join(this.getAppDataDir(), 'blinq.io', '.temp'))) {\n mkdir(path.join(this.getAppDataDir(), 'blinq.io', '.temp'), {\n recursive: true,\n })\n }\n\n tmpName(async (err, name) => {\n const tempFile = path.join(\n this.getAppDataDir(),\n 'blinq.io',\n '.temp',\n path.basename(name)\n )\n console.log('File path: ', tempFile)\n await writeFile(tempFile, '', 'utf-8')\n\n args.push(`--temp-file=${tempFile}`)\n const cucumberClient = spawn('node', [cucumber_client_path, ...args], {\n env: {\n ...process.env,\n },\n })\n\n cucumberClient.stdout.on('data', (data) => {\n console.log(data.toString())\n })\n\n cucumberClient.stderr.on('data', (data) => {\n console.error(data.toString())\n })\n\n cucumberClient.on('close', async (code) => {\n if (code === 0) {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } else {\n this.log('Error retraining\\n')\n resolve(null)\n }\n })\n })\n })\n }\n private logReportLink(runId: string, projectId: string) {\n let reportLinkBaseUrl = 'https://www.app.blinq.io'\n if (process.env.NODE_ENV_BLINQ === 'local') {\n reportLinkBaseUrl = 'http://localhost:3000'\n } else if (process.env.NODE_ENV_BLINQ === 'dev') {\n reportLinkBaseUrl = 'https://dev.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'stage') {\n reportLinkBaseUrl = 'https://stage.app.blinq.io'\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n this.log(`Report link: ${reportLink}\\n`)\n }\n\n private getAppDataDir() {\n if (process.env.BLINQ_APPDATA_DIR) {\n return process.env.BLINQ_APPDATA_DIR\n }\n\n let appDataDir: string\n\n switch (process.platform) {\n case 'win32':\n appDataDir = process.env.APPDATA!\n break\n case 'darwin':\n appDataDir = path.join(os.homedir(), 'Library', 'Application Support')\n break\n default:\n appDataDir = path.join(os.homedir(), '.config')\n break\n }\n return appDataDir\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bvt_analysis_formatter.js","sourceRoot":"","sources":["../../src/formatter/bvt_analysis_formatter.ts"],"names":[],"mappings":";;;;;;AACA,iDAAqC;AACrC,2BAA4D;AAC5D,0CAAsD;AACtD,gDAAuB;AACvB,6BAA6B;AAC7B,yCAAgD;AAChD,oDAAgD;AAChD,kFAKmC;AACnC,kEAA+C;AAC/C,4CAAmB;AACnB,+BAA6C;AAC7C,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQ/B,MAAqB,oBAAqB,SAAQ,UAAS;IAMzD,YAAY,OAA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MAAK;YACP,KAAK,QAAQ;gBACX,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAA;gBACtE,MAAK;YACP;gBACE,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;gBAC/C,MAAK;SACR;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AA1RD,uCA0RC;AAED,SAAgB,aAAa,CAAC,KAAa,EAAE,SAAiB;IAC5D,IAAI,iBAAiB,GAAG,sBAAsB,CAAA;IAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO,EAAE;QAC1C,iBAAiB,GAAG,uBAAuB,CAAA;KAC5C;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK,EAAE;QAC/C,iBAAiB,GAAG,0BAA0B,CAAA;KAC/C;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO,EAAE;QACjD,iBAAiB,GAAG,4BAA4B,CAAA;KACjD;IACD,MAAM,UAAU,GAAG,GAAG,iBAAiB,IAAI,SAAS,eAAe,KAAK,EAAE,CAAA;IAC1E,OAAO,CAAC,GAAG,CAAC,gBAAgB,UAAU,IAAI,CAAC,CAAA;AAC7C,CAAC;AAXD,sCAWC","sourcesContent":["import { Envelope, Meta } from '@cucumber/messages'\nimport { spawn } from 'child_process'\nimport { readFileSync, existsSync, writeFileSync } from 'fs'\nimport { mkdir, unlink, writeFile } from 'fs/promises'\nimport path from 'path'\nimport { tmpName } from 'tmp'\nimport Formatter, { IFormatterOptions } from '.'\nimport { doesHaveValue } from '../value_checker'\nimport ReportGenerator, {\n JsonReport,\n JsonTestProgress,\n JsonTestResult,\n RetrainStats,\n} from './helpers/report_generator'\nimport ReportUploader from './helpers/uploader'\nimport os from 'os'\nimport { getProjectByAccessKey } from './api'\n//User token\nconst TOKEN = process.env.TOKEN\ninterface MetaMessage extends Meta {\n runName: string\n}\n\ninterface EnvelopeWithMetaMessage extends Envelope {\n meta: MetaMessage\n}\nexport default class BVTAnalysisFormatter extends Formatter {\n private reportGenerator = new ReportGenerator()\n private uploader = new ReportUploader(this.reportGenerator)\n private exit = false\n private START: number\n private runName: string\n constructor(options: IFormatterOptions) {\n super(options)\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage) => {\n await this.reportGenerator.handleMessage(envelope)\n if (\n doesHaveValue(envelope.meta) &&\n doesHaveValue(envelope.meta.runName)\n ) {\n this.runName = envelope.meta.runName\n }\n if (doesHaveValue(envelope.testRunFinished)) {\n const report = this.reportGenerator.getReport()\n this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport(report)\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private async uploadReport(report: JsonReport) {\n const uploadSuccessful = await this.uploadFinalReport(report)\n if (uploadSuccessful && report.result.status !== 'FAILED') {\n process.exit(0)\n }\n process.exit(1)\n }\n\n async finished(): Promise<any> {\n await new Promise((resolve) => {\n const checkInterval = setInterval(() => {\n let anyRem\n if (process.env.UPLOADING_TEST_CASE) {\n anyRem = JSON.parse(process.env.UPLOADING_TEST_CASE) as string[]\n } else {\n anyRem = undefined\n }\n\n if (this.exit && (!anyRem || anyRem.length === 0)) {\n // clearInterval(checkInterval)\n // resolve(null)\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n } else {\n process.exit(0)\n }\n }\n }, 100) // check every 100ms\n })\n }\n private async analyzeReport(report: JsonReport) {\n if (\n report.result.status === 'PASSED' ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (report.result.status === 'PASSED') {\n this.log('No test failed. No need to retrain\\n')\n }\n if (process.env.NO_RETRAIN === 'false') {\n this.log(\n 'Retraining is skipped since the failed step contains an API request\\n'\n )\n }\n // const uploadSuccessful = await this.uploadFinalReport(report)\n // process.exit(0)\n this.exit = true\n return\n }\n\n //checking if the type of report.result is JsonResultFailed or not\n this.log('Some tests failed, starting the retraining...\\n')\n if (!('startTime' in report.result) || !('endTime' in report.result)) {\n this.log('Unknown error occured,not retraining\\n')\n return\n }\n await this.processTestCases(report)\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n }\n process.exit(0)\n }\n private async processTestCases(report: JsonReport): Promise<JsonReport> {\n const finalTestCases = []\n for (const testCase of report.testCases) {\n const modifiedTestCase = await this.processTestCase(testCase, report)\n\n finalTestCases.push(modifiedTestCase)\n }\n const finalResult = finalTestCases.some(\n (tc) => tc.result.status !== 'PASSED'\n )\n ? report.result\n : ({\n ...report.result,\n status: 'PASSED',\n } as JsonTestResult)\n return {\n result: finalResult,\n testCases: finalTestCases,\n env: report.env,\n }\n }\n private async processTestCase(\n testCase: JsonTestProgress,\n report: JsonReport\n ): Promise<JsonTestProgress> {\n if (testCase.result.status === 'PASSED') {\n return testCase\n }\n const failedTestSteps = testCase.steps\n .map((step, i) => (step.result.status === 'FAILED' ? i : null))\n .filter((i) => i !== null)\n const retrainStats = await this.retrain(failedTestSteps, testCase)\n\n if (!retrainStats) {\n return testCase\n }\n if (retrainStats.result.status === 'PASSED') {\n await this.uploader.modifyTestCase({\n ...testCase,\n retrainStats,\n })\n }\n\n return {\n ...testCase,\n retrainStats,\n }\n }\n\n private async uploadFinalReport(finalReport: JsonReport) {\n let success = true\n try {\n const { projectId, runId } = await this.uploader.uploadRun(\n finalReport,\n this.runName\n )\n logReportLink(runId, projectId)\n } catch (err) {\n this.log('Error uploading report\\n')\n if ('stack' in err) {\n this.log(err.stack)\n }\n success = false\n } finally {\n try {\n writeFileSync(\n path.join(this.reportGenerator.reportFolder, 'report.json'),\n JSON.stringify(finalReport, null, 2),\n 'utf-8'\n )\n } catch (e) {\n console.error('failed to write report.json to local disk')\n }\n }\n\n //this.log(JSON.stringify(finalReport, null, 2))\n return success\n }\n private async retrain(\n failedTestCases: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n const data = await getProjectByAccessKey(TOKEN)\n const currentTimestampInSeconds = Math.floor(Date.now() / 1000)\n if (data.project.expriration_date < currentTimestampInSeconds) {\n console.log(\n 'Warning: Your project has expired, retraining is restricted. Please contact sales.'\n )\n process.exit(1)\n }\n return await this.call_cucumber_client(failedTestCases, testCase)\n }\n\n private async call_cucumber_client(\n stepsToRetrain: number[],\n testCase: JsonTestProgress\n ): Promise<RetrainStats | null> {\n return new Promise((resolve, reject) => {\n const cucumber_client_path = path.resolve(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber_client',\n 'bin',\n 'client',\n 'cucumber.js'\n )\n\n const args: string[] = [\n process.cwd(),\n path.join(process.cwd(), testCase.uri),\n `${testCase.scenarioName}`,\n 'undefined',\n `${stepsToRetrain.join(',')}`,\n ]\n\n if (process.env.BLINQ_ENV) {\n args.push(`--env=${process.env.BLINQ_ENV}`)\n }\n\n if (!existsSync(path.join(this.getAppDataDir(), 'blinq.io', '.temp'))) {\n mkdir(path.join(this.getAppDataDir(), 'blinq.io', '.temp'), {\n recursive: true,\n })\n }\n\n tmpName(async (err, name) => {\n const tempFile = path.join(\n this.getAppDataDir(),\n 'blinq.io',\n '.temp',\n path.basename(name)\n )\n console.log('File path: ', tempFile)\n await writeFile(tempFile, '', 'utf-8')\n\n args.push(`--temp-file=${tempFile}`)\n const cucumberClient = spawn('node', [cucumber_client_path, ...args], {\n env: {\n ...process.env,\n },\n })\n\n cucumberClient.stdout.on('data', (data) => {\n console.log(data.toString())\n })\n\n cucumberClient.stderr.on('data', (data) => {\n console.error(data.toString())\n })\n\n cucumberClient.on('close', async (code) => {\n if (code === 0) {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } else {\n this.log('Error retraining\\n')\n resolve(null)\n }\n })\n })\n })\n }\n\n private getAppDataDir() {\n if (process.env.BLINQ_APPDATA_DIR) {\n return process.env.BLINQ_APPDATA_DIR\n }\n\n let appDataDir: string\n\n switch (process.platform) {\n case 'win32':\n appDataDir = process.env.APPDATA!\n break\n case 'darwin':\n appDataDir = path.join(os.homedir(), 'Library', 'Application Support')\n break\n default:\n appDataDir = path.join(os.homedir(), '.config')\n break\n }\n return appDataDir\n }\n}\n\nexport function logReportLink(runId: string, projectId: string) {\n let reportLinkBaseUrl = 'https://app.blinq.io'\n if (process.env.NODE_ENV_BLINQ === 'local') {\n reportLinkBaseUrl = 'http://localhost:3000'\n } else if (process.env.NODE_ENV_BLINQ === 'dev') {\n reportLinkBaseUrl = 'https://dev.app.blinq.io'\n } else if (process.env.NODE_ENV_BLINQ === 'stage') {\n reportLinkBaseUrl = 'https://stage.app.blinq.io'\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n console.log(`Report link: ${reportLink}\\n`)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAuC;AACvC,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AAEzB,MAAM,gBAAgB,GAAG,CACvB,kBAA0B,EAC1B,IAAU,EACV,QAGG,EACH,UAAmB,EACnB,EAAE;IACF,MAAM,MAAM,GAAG,2BAA2B,CAAA;IAC1C,MAAM,aAAa,GAAG,wBAAwB,CAAA;IAC9C,IAAI,UAAU,GAAG,kBAAkB,CAAA;IACnC,IAAI,KAAsB,CAAA;IAC1B,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;KAC3B;IACD,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAC7B,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,iBAA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,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAKC,kFAAmC","sourcesContent":["import { faker } from '@faker-js/faker'\nimport fs from 'fs'\nimport path from 'path'\nimport { TableCell } from '@cucumber/messages'\nimport JSON5 from 'json5'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[],\n projectDir?: string\n) => {\n const regexp = /\\{\\{([^}]*\\([^)]*\\))\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n if (!projectDir) {\n projectDir = process.cwd()\n }\n const namespacePath = path.join(\n projectDir,\n 'features',\n 'step_definitions',\n 'namespaces.json'\n )\n let namespaces: string[] = fs.existsSync(namespacePath)\n ? JSON.parse(fs.readFileSync(namespacePath, 'utf-8'))\n : []\n if (!Array.isArray(namespaces)) {\n namespaces = []\n }\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n // match[0] is the full match, match[1] is the first capturing group\n // Eg:- match[0] = {{name}}, match[1] = name\n if (!namespaces.includes(match[1].split('.')[0])) matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = getFakeString(\n variable.toFake.substring(2, variable.toFake.length - 2)\n )\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n while ((match = regexp.exec(featureFileContent)) !== null) {\n if (namespaces.includes(match[1].split('.')[0])) continue\n try {\n const fake =\n duplicateFakeData &&\n duplicateFakeData.length > 0 &&\n duplicateFakeData[0].var === match[0]\n ? duplicateFakeData.shift().fake\n : getFakeString(match[0].substring(2, match[0].length - 2))\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n //console.log('unknown faker variable:' + match[0])\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\nconst getFakeString = (content: string) => {\n // content example: helpers.fromRegExp('#{2,9}')\n const faking = content.split('(')[0].split('.')\n // faking example: ['helpers', 'fromRegExp']\n const argument = content.substring(\n content.indexOf('(') + 1,\n content.lastIndexOf(')')\n )\n // argument example: '#{2,9}'\n\n let fakeFunc: any = faker\n faking.forEach((f: string) => {\n fakeFunc = fakeFunc[f]\n })\n let regexpParam = false\n if (faking.length === 2 && faking[1] === 'fromRegExp') {\n regexpParam = true\n }\n if (regexpParam) {\n return fakeFunc(new RegExp(argument))\n }\n try {\n return fakeFunc(JSON5.parse(argument))\n } catch (error) {\n return fakeFunc(argument)\n }\n}\n\nconst getDefinitionFunction = (\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const mjsFiles = fs\n .readdirSync(path.join(feature_path, '../step_definitions'))\n .filter((file) => file === `${functionFile}.js`)\n\n if (mjsFiles.length === 0) {\n throw new Error(`File ${functionFile} not found in step_definitions folder`)\n }\n\n const [mjsData] = mjsFiles.map((file) => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { [functionName]: func } = require(path.join(\n feature_path,\n '../step_definitions',\n file\n ))\n if (!func)\n throw new Error(`Function ${functionName} not found in file ${file}`)\n\n return func()\n })\n\n return mjsData\n}\n\nconst generateExamplesFromFunction = (\n data: string,\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const examples = data.split('Examples:')[1].split('\\n').slice(1)\n const headers = examples[0]\n .split('|')\n .map((header) => header.trim())\n .filter((header) => header !== '')\n const values = examples[1]\n .split('|')\n .map((value) => value.trim())\n .filter((header) => header !== '')\n\n const mjsData = getDefinitionFunction(\n feature_path,\n functionName,\n functionFile\n )\n\n const newExamples = headers.map((header) => {\n if (mjsData[header]) {\n return mjsData[header]\n }\n return values[headers.indexOf(header)]\n })\n\n let newExamplesString = data.split('Examples:')[1]\n newExamples.forEach((example, index) => {\n newExamplesString = newExamplesString.replace(values[index], example)\n })\n\n const newData = data.replace(data.split('Examples:')[1], newExamplesString)\n\n return { newData, mjsData }\n}\n\nconst generateExamplesFromFunctionGherkin = (\n headers: readonly TableCell[],\n values: readonly TableCell[],\n mjsData: any\n) => {\n const newExamples = headers.map(({ value: header }, index) => {\n if (mjsData[header]) {\n return { header, value: mjsData[header] }\n }\n return { header, value: values[index].value }\n })\n\n return newExamples\n}\n\nexport {\n generateTestData,\n generateExamplesFromFunction,\n generateExamplesFromFunctionGherkin,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"feature_data_format.js","sourceRoot":"","sources":["../../src/formatter/feature_data_format.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAuC;AACvC,4CAAmB;AACnB,gDAAuB;AAEvB,kDAAyB;AAEzB,MAAM,gBAAgB,GAAG,CACvB,kBAA0B,EAC1B,IAAU,EACV,QAGG,EACH,UAAmB,EACnB,EAAE;IACF,MAAM,MAAM,GAAG,2BAA2B,CAAA;IAC1C,MAAM,aAAa,GAAG,wBAAwB,CAAA;IAC9C,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5B,OAAY,EACZ,EAAE;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE;QAC3D,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YACnB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;SAC1C;QACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAKC,kFAAmC","sourcesContent":["import { faker } from '@faker-js/faker'\nimport fs from 'fs'\nimport path from 'path'\nimport { TableCell } from '@cucumber/messages'\nimport JSON5 from 'json5'\n\nconst generateTestData = (\n featureFileContent: string,\n vars?: any,\n fakeData?: {\n var: string\n fake: string\n }[],\n projectDir?: string\n) => {\n const regexp = /\\{\\{([^}]*\\([^)]*\\))\\}\\}/g\n const variableRegex = /^([a-zA-Z0-9_]*)=(.*)/g\n let newContent = featureFileContent\n let match: RegExpExecArray\n if (!projectDir) {\n projectDir = process.cwd()\n }\n const namespacePath = path.join(\n projectDir,\n 'features',\n 'step_definitions',\n 'namespaces.json'\n )\n let namespaces: string[] = fs.existsSync(namespacePath)\n ? JSON.parse(fs.readFileSync(namespacePath, 'utf-8'))\n : []\n if (!Array.isArray(namespaces)) {\n namespaces = []\n }\n const matches = []\n // collect all matches\n while ((match = regexp.exec(featureFileContent)) !== null) {\n // match[0] is the full match, match[1] is the first capturing group\n // Eg:- match[0] = {{name}}, match[1] = name\n if (!namespaces.includes(match[1].split('.')[0])) matches.push(match)\n }\n // find all variables in the matches\n const variables: any = { ...vars }\n\n if (Object.keys(variables).length > 0) {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n newContent = newContent.replaceAll(`{{${variable.var}}}`, variable.fake)\n }\n } else {\n for (let i = 0; i < matches.length; i++) {\n const _match = matches[i]\n const value = _match[1]\n const variableMatch = variableRegex.exec(value)\n if (variableMatch !== null) {\n variables[variableMatch[1]] = {\n var: variableMatch[1],\n toFake: variableMatch[2],\n }\n newContent = newContent.replaceAll(_match[0], `{{${variableMatch[1]}}}`)\n }\n }\n\n for (const key in variables) {\n const variable = variables[key]\n const fake = getFakeString(\n variable.toFake.substring(2, variable.toFake.length - 2)\n )\n newContent = newContent.replaceAll(`{{${variable.var}}}`, fake)\n variables[key].fake = fake\n }\n }\n\n regexp.lastIndex = 0\n const otherFakeData = []\n const duplicateFakeData = fakeData ? [...fakeData] : []\n let fakeIndex = 0\n while ((match = regexp.exec(featureFileContent)) !== null) {\n if (namespaces.includes(match[1].split('.')[0])) continue\n try {\n const fake =\n duplicateFakeData &&\n duplicateFakeData.length > 0 &&\n duplicateFakeData[0].var === match[0]\n ? duplicateFakeData.shift().fake\n : getFakeString(match[0].substring(2, match[0].length - 2))\n otherFakeData.push({\n var: match[0],\n fake,\n })\n newContent = newContent.replace(match[0], fake)\n fakeIndex++\n } catch (err) {\n // eslint-disable-next-line no-console\n //console.log('unknown faker variable:' + match[0])\n }\n }\n\n return {\n newContent,\n variables,\n otherFakeData,\n changed: newContent !== featureFileContent,\n fakeIndex,\n }\n}\n\nconst getFakeString = (content: string) => {\n // content example: helpers.fromRegExp('#{2,9}')\n const faking = content.split('(')[0].split('.')\n // faking example: ['helpers', 'fromRegExp']\n const argument = content.substring(\n content.indexOf('(') + 1,\n content.lastIndexOf(')')\n )\n // argument example: '#{2,9}'\n\n let fakeFunc: any = faker\n faking.forEach((f: string) => {\n fakeFunc = fakeFunc[f]\n })\n let regexpParam = false\n if (faking.length === 2 && faking[1] === 'fromRegExp') {\n regexpParam = true\n }\n if (regexpParam) {\n return fakeFunc(new RegExp(argument))\n }\n try {\n return fakeFunc(JSON5.parse(argument))\n } catch (error) {\n if (!argument) {\n return fakeFunc()\n }\n\n return fakeFunc(argument)\n }\n}\n\nconst getDefinitionFunction = (\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const mjsFiles = fs\n .readdirSync(path.join(feature_path, '../step_definitions'))\n .filter((file) => file === `${functionFile}.js`)\n\n if (mjsFiles.length === 0) {\n throw new Error(`File ${functionFile} not found in step_definitions folder`)\n }\n\n const [mjsData] = mjsFiles.map((file) => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { [functionName]: func } = require(path.join(\n feature_path,\n '../step_definitions',\n file\n ))\n if (!func)\n throw new Error(`Function ${functionName} not found in file ${file}`)\n\n return func()\n })\n\n return mjsData\n}\n\nconst generateExamplesFromFunction = (\n data: string,\n feature_path: string,\n functionName: string,\n functionFile: string\n) => {\n const examples = data.split('Examples:')[1].split('\\n').slice(1)\n const headers = examples[0]\n .split('|')\n .map((header) => header.trim())\n .filter((header) => header !== '')\n const values = examples[1]\n .split('|')\n .map((value) => value.trim())\n .filter((header) => header !== '')\n\n const mjsData = getDefinitionFunction(\n feature_path,\n functionName,\n functionFile\n )\n\n const newExamples = headers.map((header) => {\n if (mjsData[header]) {\n return mjsData[header]\n }\n return values[headers.indexOf(header)]\n })\n\n let newExamplesString = data.split('Examples:')[1]\n newExamples.forEach((example, index) => {\n newExamplesString = newExamplesString.replace(values[index], example)\n })\n\n const newData = data.replace(data.split('Examples:')[1], newExamplesString)\n\n return { newData, mjsData }\n}\n\nconst generateExamplesFromFunctionGherkin = (\n headers: readonly TableCell[],\n values: readonly TableCell[],\n mjsData: any\n) => {\n const newExamples = headers.map(({ value: header }, index) => {\n if (mjsData[header]) {\n return { header, value: mjsData[header] }\n }\n return { header, value: values[index].value }\n })\n\n return newExamples\n}\n\nexport {\n generateTestData,\n generateExamplesFromFunction,\n generateExamplesFromFunctionGherkin,\n}\n"]}
|
|
@@ -82,6 +82,10 @@ export type JsonTestProgress = {
|
|
|
82
82
|
retrainStats?: RetrainStats;
|
|
83
83
|
webLog: any;
|
|
84
84
|
networkLog: any;
|
|
85
|
+
env: {
|
|
86
|
+
name: string;
|
|
87
|
+
baseUrl: string;
|
|
88
|
+
};
|
|
85
89
|
};
|
|
86
90
|
export type JsonReport = {
|
|
87
91
|
testCases: JsonTestProgress[];
|
|
@@ -91,6 +95,12 @@ export type JsonReport = {
|
|
|
91
95
|
baseUrl: string;
|
|
92
96
|
};
|
|
93
97
|
};
|
|
98
|
+
interface MetaMessage extends messages.Meta {
|
|
99
|
+
runName: string;
|
|
100
|
+
}
|
|
101
|
+
interface EnvelopeWithMetaMessage extends messages.Envelope {
|
|
102
|
+
meta: MetaMessage;
|
|
103
|
+
}
|
|
94
104
|
export default class ReportGenerator {
|
|
95
105
|
private report;
|
|
96
106
|
private gherkinDocumentMap;
|
|
@@ -103,8 +113,10 @@ export default class ReportGenerator {
|
|
|
103
113
|
private scenarioIterationCountMap;
|
|
104
114
|
private logs;
|
|
105
115
|
private networkLog;
|
|
116
|
+
private runName;
|
|
106
117
|
reportFolder: null | string;
|
|
107
|
-
|
|
118
|
+
private uploadService;
|
|
119
|
+
handleMessage(envelope: EnvelopeWithMetaMessage): Promise<void>;
|
|
108
120
|
getReport(): JsonReport;
|
|
109
121
|
private handleParseError;
|
|
110
122
|
private onGherkinDocument;
|
|
@@ -121,6 +133,7 @@ export default class ReportGenerator {
|
|
|
121
133
|
getLogFileContent(): any;
|
|
122
134
|
private getTestCaseResult;
|
|
123
135
|
private onTestCaseFinished;
|
|
136
|
+
private uploadTestCase;
|
|
124
137
|
private onTestRunFinished;
|
|
125
138
|
}
|
|
126
139
|
export {};
|
|
@@ -2,9 +2,22 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
+
var _a, _b;
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const upload_serivce_1 = require("./upload_serivce");
|
|
10
|
+
const URL = process.env.NODE_ENV_BLINQ === 'dev'
|
|
11
|
+
? 'https://dev.api.blinq.io/api/runs'
|
|
12
|
+
: process.env.NODE_ENV_BLINQ === 'local'
|
|
13
|
+
? 'http://localhost:5001/api/runs'
|
|
14
|
+
: process.env.NODE_ENV_BLINQ === 'stage'
|
|
15
|
+
? 'https://stage.api.blinq.io/api/runs'
|
|
16
|
+
: 'https://api.blinq.io/api/runs';
|
|
17
|
+
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
18
|
+
const BATCH_SIZE = 10;
|
|
19
|
+
const MAX_RETRIES = 3;
|
|
20
|
+
const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
|
|
8
21
|
class ReportGenerator {
|
|
9
22
|
constructor() {
|
|
10
23
|
this.report = {
|
|
@@ -27,9 +40,14 @@ class ReportGenerator {
|
|
|
27
40
|
this.scenarioIterationCountMap = new Map();
|
|
28
41
|
this.logs = [];
|
|
29
42
|
this.networkLog = [];
|
|
43
|
+
this.runName = '';
|
|
30
44
|
this.reportFolder = null;
|
|
45
|
+
this.uploadService = new upload_serivce_1.RunUploadService(REPORT_SERVICE_URL, REPORT_SERVICE_TOKEN);
|
|
31
46
|
}
|
|
32
|
-
handleMessage(envelope) {
|
|
47
|
+
async handleMessage(envelope) {
|
|
48
|
+
if (envelope.meta && envelope.meta.runName) {
|
|
49
|
+
this.runName = envelope.meta.runName;
|
|
50
|
+
}
|
|
33
51
|
const type = Object.keys(envelope)[0];
|
|
34
52
|
switch (type) {
|
|
35
53
|
// case "meta": { break}
|
|
@@ -83,7 +101,7 @@ class ReportGenerator {
|
|
|
83
101
|
}
|
|
84
102
|
case 'testCaseFinished': {
|
|
85
103
|
const testCaseFinished = envelope[type];
|
|
86
|
-
this.onTestCaseFinished(testCaseFinished);
|
|
104
|
+
await this.onTestCaseFinished(testCaseFinished);
|
|
87
105
|
break;
|
|
88
106
|
}
|
|
89
107
|
// case "hook": { break} // After Hook
|
|
@@ -236,6 +254,10 @@ class ReportGenerator {
|
|
|
236
254
|
},
|
|
237
255
|
webLog: [],
|
|
238
256
|
networkLog: [],
|
|
257
|
+
env: {
|
|
258
|
+
name: this.report.env.name,
|
|
259
|
+
baseUrl: this.report.env.baseUrl,
|
|
260
|
+
},
|
|
239
261
|
});
|
|
240
262
|
this.report.testCases.push(this.testCaseReportMap.get(id));
|
|
241
263
|
}
|
|
@@ -261,6 +283,10 @@ class ReportGenerator {
|
|
|
261
283
|
if (mediaType === 'application/json+env') {
|
|
262
284
|
const data = JSON.parse(body);
|
|
263
285
|
this.report.env = data;
|
|
286
|
+
this.report.testCases.map((testCase) => {
|
|
287
|
+
testCase.env = data;
|
|
288
|
+
return testCase;
|
|
289
|
+
});
|
|
264
290
|
}
|
|
265
291
|
if (mediaType === 'application/json+log') {
|
|
266
292
|
const log = JSON.parse(body);
|
|
@@ -293,11 +319,11 @@ class ReportGenerator {
|
|
|
293
319
|
const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
|
|
294
320
|
const prevStepResult = stepProgess.result;
|
|
295
321
|
let data = {};
|
|
296
|
-
const reportFolder = this.reportFolder;
|
|
297
|
-
if (reportFolder === null) {
|
|
298
|
-
throw new Error('"reportFolder" is "null". Failed to run BVT hooks. Please retry after running "Generate All" or "Record Scenario" ');
|
|
299
|
-
}
|
|
300
322
|
try {
|
|
323
|
+
const reportFolder = this.reportFolder;
|
|
324
|
+
if (reportFolder === null) {
|
|
325
|
+
throw new Error('"reportFolder" is "null". Failed to run BVT hooks. Please retry after running "Generate All" or "Record Scenario" ');
|
|
326
|
+
}
|
|
301
327
|
if (fs_1.default.existsSync(path_1.default.join(reportFolder, 'data.json'))) {
|
|
302
328
|
data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(reportFolder, 'data.json'), 'utf8'));
|
|
303
329
|
}
|
|
@@ -362,7 +388,7 @@ class ReportGenerator {
|
|
|
362
388
|
status: 'PASSED',
|
|
363
389
|
};
|
|
364
390
|
}
|
|
365
|
-
onTestCaseFinished(testCaseFinished) {
|
|
391
|
+
async onTestCaseFinished(testCaseFinished) {
|
|
366
392
|
const { testCaseStartedId, timestamp } = testCaseFinished;
|
|
367
393
|
const testProgress = this.testCaseReportMap.get(testCaseStartedId);
|
|
368
394
|
const prevResult = testProgress.result;
|
|
@@ -377,6 +403,40 @@ class ReportGenerator {
|
|
|
377
403
|
testProgress.networkLog = this.networkLog;
|
|
378
404
|
this.networkLog = [];
|
|
379
405
|
this.logs = [];
|
|
406
|
+
await this.uploadTestCase(testProgress);
|
|
407
|
+
}
|
|
408
|
+
async uploadTestCase(testCase) {
|
|
409
|
+
let runId = '';
|
|
410
|
+
let projectId = '';
|
|
411
|
+
if (!process.env.UPLOADING_TEST_CASE) {
|
|
412
|
+
process.env.UPLOADING_TEST_CASE = '[]';
|
|
413
|
+
}
|
|
414
|
+
const anyRemArr = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
415
|
+
const randomID = Math.random().toString(36).substring(7);
|
|
416
|
+
anyRemArr.push(randomID);
|
|
417
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(anyRemArr);
|
|
418
|
+
try {
|
|
419
|
+
if (process.env.RUN_ID && process.env.PROJECT_ID) {
|
|
420
|
+
runId = process.env.RUN_ID;
|
|
421
|
+
projectId = process.env.PROJECT_ID;
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
const runDoc = await this.uploadService.createRunDocument(this.runName);
|
|
425
|
+
runId = runDoc._id;
|
|
426
|
+
projectId = runDoc.project_id;
|
|
427
|
+
process.env.RUN_ID = runId;
|
|
428
|
+
process.env.PROJECT_ID = projectId;
|
|
429
|
+
}
|
|
430
|
+
await this.uploadService.uploadTestCase(testCase, runId, projectId, this.reportFolder);
|
|
431
|
+
}
|
|
432
|
+
catch (e) {
|
|
433
|
+
console.error('Error uploading test case:', e);
|
|
434
|
+
}
|
|
435
|
+
finally {
|
|
436
|
+
const arrRem = JSON.parse(process.env.UPLOADING_TEST_CASE);
|
|
437
|
+
arrRem.splice(arrRem.indexOf(randomID), 1);
|
|
438
|
+
process.env.UPLOADING_TEST_CASE = JSON.stringify(arrRem);
|
|
439
|
+
}
|
|
380
440
|
}
|
|
381
441
|
onTestRunFinished(testRunFinished) {
|
|
382
442
|
const { timestamp, success, message } = testRunFinished;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report_generator.js","sourceRoot":"","sources":["../../../src/formatter/helpers/report_generator.ts"],"names":[],"mappings":";;;;;AACA,4CAAmB;AACnB,gDAAuB;AAkHvB,MAAqB,eAAe;IAApC;QACU,WAAM,GAAe;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;aAClB;YACD,SAAS,EAAE,EAAwB;YACnC,GAAG,EAAE;gBACH,IAAI,EAAE,EAAE;gBACR,OAAO,EAAE,EAAE;aACZ;SACF,CAAA;QACO,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAA;QAChE,YAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;QAC1C,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAA;QAC9C,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAA;QAClD,gBAAW,GAAG,IAAI,GAAG,EAA6B,CAAA;QAClD,kBAAa,GAAG,IAAI,GAAG,EAAoB,CAAA;QAC3C,sBAAiB,GAAG,IAAI,GAAG,EAA4B,CAAA;QACvD,8BAAyB,GAAG,IAAI,GAAG,EAAkB,CAAA;QACrD,SAAI,GAAa,EAAE,CAAA;QACnB,eAAU,GAAU,EAAE,CAAA;QAC9B,iBAAY,GAAkB,IAAI,CAAA;IA6XpC,CAAC;IA3XC,aAAa,C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O,EAAE,OAAO,EAAE,GAAG,eAAe,CAAA;QACvD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAG9B,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;YACnB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YACrC,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;YACrC,OAAO;YACP,aAAa;SACd,CAAA;IACH,CAAC;CACF;AAlZD,kCAkZC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport fs from 'fs'\nimport path from 'path'\n// type JsonException = messages.Exception\ntype JsonTimestamp = number //messages.Timestamp\ntype JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome' | 'Conjunction'\n\nexport type JsonResultUnknown = {\n status: 'UNKNOWN'\n}\ntype JsonResultSkipped = {\n status: 'SKIPPED'\n}\ntype JsonResultUndefined = {\n status: 'UNDEFINED'\n}\ntype JsonResultAmbiguous = {\n status: 'AMBIGUOUS'\n}\nexport type JsonResultStarted = {\n status: 'STARTED'\n startTime: JsonTimestamp\n}\ntype JsonResultPending = {\n status: 'PENDING'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultPassed = {\n status: 'PASSED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultFailed = {\n status: 'FAILED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n message?: string\n // exception?: JsonException\n}\nexport type JsonFixedByAi = {\n status: 'FIXED_BY_AI'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\n\ntype JsonCommandResult = JsonResultPassed | JsonResultFailed\ntype JsonStepResult =\n | JsonResultUnknown\n | JsonResultSkipped\n | JsonResultUndefined\n | JsonResultAmbiguous\n | JsonResultStarted\n | JsonResultPending\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\nexport type JsonTestResult =\n | JsonResultUnknown\n | JsonResultStarted\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\ntype JsonReportResult = JsonTestResult\n\ntype JsonCommand = {\n type: string\n value?: string\n text: string\n screenshotId?: string\n result: JsonCommandResult\n webLog?: webLog[]\n netWorkLog?: any[]\n}\ntype webLog = {\n type: string\n text: string\n location: string\n time: string\n}\nexport type JsonStep = {\n keyword: string\n type: JsonStepType\n text: string\n commands: JsonCommand[]\n result: JsonStepResult\n data?: any\n}\nexport type RetrainStats = {\n result: JsonTestResult\n totalSteps: number\n upload_id: string\n local_id: number\n}\nexport type JsonTestProgress = {\n id: string\n featureName: string\n uri: string\n scenarioName: string\n parameters: Record<string, string>\n steps: JsonStep[]\n result: JsonTestResult\n retrainStats?: RetrainStats\n webLog: any\n networkLog: any\n}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n env: {\n name: string\n baseUrl: string\n }\n}\n\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\n env: {\n name: '',\n baseUrl: '',\n },\n }\n private gherkinDocumentMap = new Map<string, messages.GherkinDocument>()\n private stepMap = new Map<string, messages.Step>()\n private pickleMap = new Map<string, messages.Pickle>()\n private testCaseMap = new Map<string, messages.TestCase>()\n private testStepMap = new Map<string, messages.TestStep>()\n private stepReportMap = new Map<string, JsonStep>()\n private testCaseReportMap = new Map<string, JsonTestProgress>()\n private scenarioIterationCountMap = new Map<string, number>()\n private logs: webLog[] = []\n private networkLog: any[] = []\n reportFolder: null | string = null\n\n handleMessage(envelope: messages.Envelope) {\n const type = Object.keys(envelope)[0] as keyof messages.Envelope\n switch (type) {\n // case \"meta\": { break}\n // case \"source\": { break}\n case 'parseError': {\n const parseError = envelope[type]\n this.handleParseError(parseError)\n break\n }\n case 'gherkinDocument': {\n const doc = envelope[type]\n this.onGherkinDocument(doc)\n break\n }\n case 'pickle': {\n const pickle = envelope[type]\n this.onPickle(pickle)\n break\n }\n // case \"stepDefinition\": { break}\n // case \"hook\": { break} // Before Hook\n case 'testRunStarted': {\n const testRunStarted = envelope[type]\n this.onTestRunStarted(testRunStarted)\n break\n }\n case 'testCase': {\n const testCase = envelope[type]\n this.onTestCase(testCase)\n break\n }\n case 'testCaseStarted': {\n const testCaseStarted = envelope[type]\n this.onTestCaseStarted(testCaseStarted)\n break\n }\n case 'testStepStarted': {\n const testStepStarted = envelope[type]\n this.onTestStepStarted(testStepStarted)\n break\n }\n case 'attachment': {\n const attachment = envelope[type]\n this.onAttachment(attachment)\n break\n }\n case 'testStepFinished': {\n const testStepFinished = envelope[type]\n this.onTestStepFinished(testStepFinished)\n break\n }\n case 'testCaseFinished': {\n const testCaseFinished = envelope[type]\n this.onTestCaseFinished(testCaseFinished)\n break\n }\n // case \"hook\": { break} // After Hook\n case 'testRunFinished': {\n const testRunFinished = envelope[type]\n this.onTestRunFinished(testRunFinished)\n break\n }\n\n // case \"parameterType\" : { break}\n // case \"undefinedParameterType\": { break}\n }\n }\n getReport() {\n return this.report\n }\n private handleParseError(parseError: messages.ParseError) {\n const { message } = parseError\n const timestamp = new Date().getTime()\n this.report.result = {\n status: 'FAILED',\n startTime: timestamp,\n endTime: timestamp,\n message: message,\n }\n }\n private onGherkinDocument(doc: messages.GherkinDocument) {\n this.gherkinDocumentMap.set(doc.uri, doc)\n doc.feature.children.forEach((child) => {\n if (child.scenario) {\n child.scenario.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.background) {\n child.background.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.rule) {\n child.rule.children.forEach((child) => {\n if (child.scenario) {\n child.scenario.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.background) {\n child.background.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n }\n })\n }\n })\n }\n private onPickle(pickle: messages.Pickle) {\n this.pickleMap.set(pickle.id, pickle)\n }\n private getTimeStamp(timestamp: messages.Timestamp) {\n return timestamp.seconds * 1000 + timestamp.nanos / 1000000\n }\n private onTestRunStarted(testRunStarted: messages.TestRunStarted) {\n this.report.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(testRunStarted.timestamp),\n }\n }\n private onTestCase(testCase: messages.TestCase) {\n this.testCaseMap.set(testCase.id, testCase)\n testCase.testSteps.forEach((testStep) => {\n this.testStepMap.set(testStep.id, testStep)\n })\n }\n private _findScenario(doc: messages.GherkinDocument, scenarioId: string) {\n for (const child of doc.feature.children) {\n if (child.scenario && child.scenario.id === scenarioId) {\n return child.scenario\n }\n if (child.rule) {\n for (const scenario of child.rule.children) {\n if (scenario.scenario && scenario.scenario.id === scenarioId) {\n return scenario.scenario\n }\n }\n }\n }\n throw new Error(`scenario \"${scenarioId}\" not found`)\n }\n private _getParameters(scenario: messages.Scenario, exampleId: string) {\n const parameters: Record<string, string> = {}\n if (scenario.examples.length === 0) return parameters\n for (const examples of scenario.examples) {\n for (const tableRow of examples.tableBody) {\n if (tableRow.id === exampleId) {\n for (let i = 0; i < examples.tableHeader.cells.length; i++) {\n parameters[examples.tableHeader.cells[i].value] =\n tableRow.cells[i].value\n }\n }\n }\n }\n return parameters\n }\n private onTestCaseStarted(testCaseStarted: messages.TestCaseStarted) {\n const { testCaseId, id, timestamp } = testCaseStarted\n const testCase = this.testCaseMap.get(testCaseId)\n if (testCase === undefined)\n throw new Error(`testCase with id ${testCaseId} not found`)\n const pickle = this.pickleMap.get(testCase.pickleId)\n if (pickle === undefined)\n throw new Error(`pickle with id ${testCase.pickleId} not found`)\n\n const doc = this.gherkinDocumentMap.get(pickle.uri)\n if (doc === undefined)\n throw new Error(`gherkinDocument with uri ${pickle.uri} not found`)\n const featureName = doc.feature.name\n\n const scenarioId = pickle.astNodeIds[0]\n const scenario = this._findScenario(doc, scenarioId)\n const scenarioName = scenario.name\n if (!this.scenarioIterationCountMap.has(scenarioId)) {\n this.scenarioIterationCountMap.set(scenarioId, 1)\n }\n const parameters = this._getParameters(scenario, pickle.astNodeIds[1])\n console.log(\n `Running scenario ${scenarioName} iteration ${this.scenarioIterationCountMap.get(\n scenarioId\n )} with parameters:\\n${JSON.stringify(parameters, null, 4)}\\n \n `\n )\n this.scenarioIterationCountMap.set(\n scenarioId,\n this.scenarioIterationCountMap.get(scenarioId) + 1\n )\n const steps: JsonStep[] = pickle.steps.map((pickleStep) => {\n const stepId = pickleStep.astNodeIds[0]\n const step = this.stepMap.get(stepId)\n this.stepReportMap.set(pickleStep.id, {\n type: step.keywordType,\n keyword: step.keyword,\n text: step.text,\n commands: [],\n result: {\n status: 'UNKNOWN',\n },\n })\n return this.stepReportMap.get(pickleStep.id)\n })\n this.testCaseReportMap.set(id, {\n id,\n uri: pickle.uri,\n featureName,\n scenarioName,\n parameters,\n steps,\n result: {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n },\n webLog: [],\n networkLog: [],\n })\n this.report.testCases.push(this.testCaseReportMap.get(id))\n }\n private onTestStepStarted(testStepStarted: messages.TestStepStarted) {\n const { testStepId, timestamp } = testStepStarted\n const testStep = this.testStepMap.get(testStepId)\n if (testStep === undefined)\n throw new Error(`testStep with id ${testStepId} not found`)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n stepProgess.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n }\n }\n private onAttachment(attachment: messages.Attachment) {\n const { testStepId, body, mediaType } = attachment\n if (mediaType === 'text/plain') {\n this.reportFolder = body.replaceAll('\\\\', '/')\n return\n }\n if (mediaType === 'application/json+env') {\n const data = JSON.parse(body)\n this.report.env = data\n }\n if (mediaType === 'application/json+log') {\n const log: webLog = JSON.parse(body)\n if (this.logs.length < 1000) this.logs.push(log)\n }\n if (mediaType === 'application/json+network') {\n const networkLog = JSON.parse(body)\n if (this.networkLog.length < 1000) this.networkLog.push(networkLog)\n }\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n if (mediaType === 'application/json') {\n const command: JsonCommand = JSON.parse(body)\n stepProgess.commands.push(command)\n }\n }\n private onTestStepFinished(testStepFinished: messages.TestStepFinished) {\n const { testStepId, testStepResult, timestamp } = testStepFinished\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) {\n if (testStepResult.status === 'FAILED') {\n console.error(\n `Before/After hook failed with message: ${testStepResult.message}`\n )\n }\n return\n }\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n const prevStepResult = stepProgess.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n let data = {}\n const reportFolder = this.reportFolder\n if (reportFolder === null) {\n throw new Error(\n '\"reportFolder\" is \"null\". Failed to run BVT hooks. Please retry after running \"Generate All\" or \"Record Scenario\" '\n )\n }\n try {\n if (fs.existsSync(path.join(reportFolder, 'data.json'))) {\n data = JSON.parse(\n fs.readFileSync(path.join(reportFolder, 'data.json'), 'utf8')\n )\n }\n } catch (error) {\n console.log('Error reading data.json')\n }\n stepProgess.result = {\n status: testStepResult.status,\n startTime: prevStepResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message: testStepResult.message,\n // exception: testStepResult.exception,\n }\n if (Object.keys(data).length > 0) {\n stepProgess.data = data\n }\n }\n getLogFileContent() {\n let projectPath = process.cwd()\n if (process.env.PROJECT_PATH) {\n projectPath = process.env.PROJECT_PATH\n }\n const logFolder = path.join(projectPath, 'logs', 'web')\n if (!fs.existsSync(logFolder)) {\n return []\n }\n let nextId = 1\n while (fs.existsSync(path.join(logFolder, `${nextId}.json`))) {\n nextId++\n }\n if (nextId === 1) {\n return []\n }\n try {\n const logFileContent = fs.readFileSync(\n path.join(logFolder, `${nextId - 1}.json`),\n 'utf8'\n )\n return JSON.parse(logFileContent)\n } catch (error) {\n return []\n }\n }\n private getTestCaseResult(steps: JsonStep[]) {\n for (const step of steps) {\n switch (step.result.status) {\n case 'FAILED':\n return {\n status: step.result.status,\n message: step.result.message,\n // exception: step.result.exception,\n } as const\n case 'AMBIGUOUS':\n case 'UNDEFINED':\n case 'PENDING':\n return {\n status: 'FAILED',\n message: `step \"${step.text}\" is ${step.result.status}`,\n } as const\n }\n }\n return {\n status: 'PASSED',\n } as const\n }\n private onTestCaseFinished(testCaseFinished: messages.TestCaseFinished) {\n const { testCaseStartedId, timestamp } = testCaseFinished\n const testProgress = this.testCaseReportMap.get(testCaseStartedId)\n const prevResult = testProgress.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n const steps = Object.values(testProgress.steps)\n const result = this.getTestCaseResult(steps)\n testProgress.result = {\n ...result,\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n }\n testProgress.webLog = this.logs\n testProgress.networkLog = this.networkLog\n this.networkLog = []\n this.logs = []\n }\n private onTestRunFinished(testRunFinished: messages.TestRunFinished) {\n const { timestamp, success, message } = testRunFinished\n const prevResult = this.report.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n this.report.result = {\n status: success ? 'PASSED' : 'FAILED',\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message,\n // exception,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"report_generator.js","sourceRoot":"","sources":["../../../src/formatter/helpers/report_generator.ts"],"names":[],"mappings":";;;;;;AACA,4CAAmB;AACnB,gDAAuB;AACvB,qDAAmD;AAKnD,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,KAAK;IAClC,CAAC,CAAC,mCAAmC;IACrC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;QACxC,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,OAAO;YACxC,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,+BAA+B,CAAA;AAErC,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAA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gBAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,CAAA;gBAC1B,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,SAAS,CAAA;aACnC;YACD,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CACrC,QAAQ,EACR,KAAK,EACL,SAAS,EACT,IAAI,CAAC,YAAY,CAClB,CAAA;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAA;SAC/C;gBAAS;YACR,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAa,CAAA;YACtE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1C,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;SACzD;IACH,CAAC;IACO,iBAAiB,CAAC,eAAyC;QACjE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,eAAe,CAAA;QACvD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAG9B,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG;YACnB,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YACrC,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;YACrC,OAAO;YACP,aAAa;SACd,CAAA;IACH,CAAC;CACF;AAzcD,kCAycC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport fs from 'fs'\nimport path from 'path'\nimport { RunUploadService } from './upload_serivce'\n// type JsonException = messages.Exception\ntype JsonTimestamp = number //messages.Timestamp\ntype JsonStepType = 'Unknown' | 'Context' | 'Action' | 'Outcome' | 'Conjunction'\n\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\nexport type JsonResultUnknown = {\n status: 'UNKNOWN'\n}\ntype JsonResultSkipped = {\n status: 'SKIPPED'\n}\ntype JsonResultUndefined = {\n status: 'UNDEFINED'\n}\ntype JsonResultAmbiguous = {\n status: 'AMBIGUOUS'\n}\nexport type JsonResultStarted = {\n status: 'STARTED'\n startTime: JsonTimestamp\n}\ntype JsonResultPending = {\n status: 'PENDING'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultPassed = {\n status: 'PASSED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\nexport type JsonResultFailed = {\n status: 'FAILED'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n message?: string\n // exception?: JsonException\n}\nexport type JsonFixedByAi = {\n status: 'FIXED_BY_AI'\n startTime: JsonTimestamp\n endTime: JsonTimestamp\n}\n\ntype JsonCommandResult = JsonResultPassed | JsonResultFailed\ntype JsonStepResult =\n | JsonResultUnknown\n | JsonResultSkipped\n | JsonResultUndefined\n | JsonResultAmbiguous\n | JsonResultStarted\n | JsonResultPending\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\nexport type JsonTestResult =\n | JsonResultUnknown\n | JsonResultStarted\n | JsonResultPassed\n | JsonResultFailed\n | JsonFixedByAi\ntype JsonReportResult = JsonTestResult\n\ntype JsonCommand = {\n type: string\n value?: string\n text: string\n screenshotId?: string\n result: JsonCommandResult\n webLog?: webLog[]\n netWorkLog?: any[]\n}\ntype webLog = {\n type: string\n text: string\n location: string\n time: string\n}\nexport type JsonStep = {\n keyword: string\n type: JsonStepType\n text: string\n commands: JsonCommand[]\n result: JsonStepResult\n data?: any\n}\nexport type RetrainStats = {\n result: JsonTestResult\n totalSteps: number\n upload_id: string\n local_id: number\n}\nexport type JsonTestProgress = {\n id: string\n featureName: string\n uri: string\n scenarioName: string\n parameters: Record<string, string>\n steps: JsonStep[]\n result: JsonTestResult\n retrainStats?: RetrainStats\n webLog: any\n networkLog: any\n env: {\n name: string\n baseUrl: string\n }\n}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n env: {\n name: string\n baseUrl: string\n }\n}\n\ninterface MetaMessage extends messages.Meta {\n runName: string\n}\ninterface EnvelopeWithMetaMessage extends messages.Envelope {\n meta: MetaMessage\n}\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\n env: {\n name: '',\n baseUrl: '',\n },\n }\n private gherkinDocumentMap = new Map<string, messages.GherkinDocument>()\n private stepMap = new Map<string, messages.Step>()\n private pickleMap = new Map<string, messages.Pickle>()\n private testCaseMap = new Map<string, messages.TestCase>()\n private testStepMap = new Map<string, messages.TestStep>()\n private stepReportMap = new Map<string, JsonStep>()\n private testCaseReportMap = new Map<string, JsonTestProgress>()\n private scenarioIterationCountMap = new Map<string, number>()\n private logs: webLog[] = []\n private networkLog: any[] = []\n private runName = ''\n reportFolder: null | string = null\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n\n async handleMessage(envelope: EnvelopeWithMetaMessage) {\n if (envelope.meta && envelope.meta.runName) {\n this.runName = envelope.meta.runName\n }\n const type = Object.keys(envelope)[0] as keyof messages.Envelope\n switch (type) {\n // case \"meta\": { break}\n // case \"source\": { break}\n case 'parseError': {\n const parseError = envelope[type]\n this.handleParseError(parseError)\n break\n }\n case 'gherkinDocument': {\n const doc = envelope[type]\n this.onGherkinDocument(doc)\n break\n }\n case 'pickle': {\n const pickle = envelope[type]\n this.onPickle(pickle)\n break\n }\n // case \"stepDefinition\": { break}\n // case \"hook\": { break} // Before Hook\n case 'testRunStarted': {\n const testRunStarted = envelope[type]\n this.onTestRunStarted(testRunStarted)\n break\n }\n case 'testCase': {\n const testCase = envelope[type]\n this.onTestCase(testCase)\n break\n }\n case 'testCaseStarted': {\n const testCaseStarted = envelope[type]\n this.onTestCaseStarted(testCaseStarted)\n break\n }\n case 'testStepStarted': {\n const testStepStarted = envelope[type]\n this.onTestStepStarted(testStepStarted)\n break\n }\n case 'attachment': {\n const attachment = envelope[type]\n this.onAttachment(attachment)\n break\n }\n case 'testStepFinished': {\n const testStepFinished = envelope[type]\n this.onTestStepFinished(testStepFinished)\n break\n }\n case 'testCaseFinished': {\n const testCaseFinished = envelope[type]\n await this.onTestCaseFinished(testCaseFinished)\n break\n }\n // case \"hook\": { break} // After Hook\n case 'testRunFinished': {\n const testRunFinished = envelope[type]\n this.onTestRunFinished(testRunFinished)\n break\n }\n\n // case \"parameterType\" : { break}\n // case \"undefinedParameterType\": { break}\n }\n }\n getReport() {\n return this.report\n }\n private handleParseError(parseError: messages.ParseError) {\n const { message } = parseError\n const timestamp = new Date().getTime()\n this.report.result = {\n status: 'FAILED',\n startTime: timestamp,\n endTime: timestamp,\n message: message,\n }\n }\n\n private onGherkinDocument(doc: messages.GherkinDocument) {\n this.gherkinDocumentMap.set(doc.uri, doc)\n doc.feature.children.forEach((child) => {\n if (child.scenario) {\n child.scenario.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.background) {\n child.background.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.rule) {\n child.rule.children.forEach((child) => {\n if (child.scenario) {\n child.scenario.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n } else if (child.background) {\n child.background.steps.forEach((step) => {\n this.stepMap.set(step.id, step)\n })\n }\n })\n }\n })\n }\n private onPickle(pickle: messages.Pickle) {\n this.pickleMap.set(pickle.id, pickle)\n }\n private getTimeStamp(timestamp: messages.Timestamp) {\n return timestamp.seconds * 1000 + timestamp.nanos / 1000000\n }\n private onTestRunStarted(testRunStarted: messages.TestRunStarted) {\n this.report.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(testRunStarted.timestamp),\n }\n }\n private onTestCase(testCase: messages.TestCase) {\n this.testCaseMap.set(testCase.id, testCase)\n testCase.testSteps.forEach((testStep) => {\n this.testStepMap.set(testStep.id, testStep)\n })\n }\n private _findScenario(doc: messages.GherkinDocument, scenarioId: string) {\n for (const child of doc.feature.children) {\n if (child.scenario && child.scenario.id === scenarioId) {\n return child.scenario\n }\n if (child.rule) {\n for (const scenario of child.rule.children) {\n if (scenario.scenario && scenario.scenario.id === scenarioId) {\n return scenario.scenario\n }\n }\n }\n }\n throw new Error(`scenario \"${scenarioId}\" not found`)\n }\n private _getParameters(scenario: messages.Scenario, exampleId: string) {\n const parameters: Record<string, string> = {}\n if (scenario.examples.length === 0) return parameters\n for (const examples of scenario.examples) {\n for (const tableRow of examples.tableBody) {\n if (tableRow.id === exampleId) {\n for (let i = 0; i < examples.tableHeader.cells.length; i++) {\n parameters[examples.tableHeader.cells[i].value] =\n tableRow.cells[i].value\n }\n }\n }\n }\n return parameters\n }\n private onTestCaseStarted(testCaseStarted: messages.TestCaseStarted) {\n const { testCaseId, id, timestamp } = testCaseStarted\n const testCase = this.testCaseMap.get(testCaseId)\n if (testCase === undefined)\n throw new Error(`testCase with id ${testCaseId} not found`)\n const pickle = this.pickleMap.get(testCase.pickleId)\n if (pickle === undefined)\n throw new Error(`pickle with id ${testCase.pickleId} not found`)\n\n const doc = this.gherkinDocumentMap.get(pickle.uri)\n if (doc === undefined)\n throw new Error(`gherkinDocument with uri ${pickle.uri} not found`)\n const featureName = doc.feature.name\n\n const scenarioId = pickle.astNodeIds[0]\n const scenario = this._findScenario(doc, scenarioId)\n const scenarioName = scenario.name\n if (!this.scenarioIterationCountMap.has(scenarioId)) {\n this.scenarioIterationCountMap.set(scenarioId, 1)\n }\n const parameters = this._getParameters(scenario, pickle.astNodeIds[1])\n console.log(\n `Running scenario ${scenarioName} iteration ${this.scenarioIterationCountMap.get(\n scenarioId\n )} with parameters:\\n${JSON.stringify(parameters, null, 4)}\\n \n `\n )\n this.scenarioIterationCountMap.set(\n scenarioId,\n this.scenarioIterationCountMap.get(scenarioId) + 1\n )\n const steps: JsonStep[] = pickle.steps.map((pickleStep) => {\n const stepId = pickleStep.astNodeIds[0]\n const step = this.stepMap.get(stepId)\n this.stepReportMap.set(pickleStep.id, {\n type: step.keywordType,\n keyword: step.keyword,\n text: step.text,\n commands: [],\n result: {\n status: 'UNKNOWN',\n },\n })\n return this.stepReportMap.get(pickleStep.id)\n })\n this.testCaseReportMap.set(id, {\n id,\n uri: pickle.uri,\n featureName,\n scenarioName,\n parameters,\n steps,\n result: {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n },\n webLog: [],\n networkLog: [],\n env: {\n name: this.report.env.name,\n baseUrl: this.report.env.baseUrl,\n },\n })\n this.report.testCases.push(this.testCaseReportMap.get(id))\n }\n private onTestStepStarted(testStepStarted: messages.TestStepStarted) {\n const { testStepId, timestamp } = testStepStarted\n const testStep = this.testStepMap.get(testStepId)\n if (testStep === undefined)\n throw new Error(`testStep with id ${testStepId} not found`)\n if (testStep.pickleStepId === undefined) return\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n stepProgess.result = {\n status: 'STARTED',\n startTime: this.getTimeStamp(timestamp),\n }\n }\n private onAttachment(attachment: messages.Attachment) {\n const { testStepId, body, mediaType } = attachment\n if (mediaType === 'text/plain') {\n this.reportFolder = body.replaceAll('\\\\', '/')\n return\n }\n if (mediaType === 'application/json+env') {\n const data = JSON.parse(body)\n this.report.env = data\n this.report.testCases.map((testCase) => {\n testCase.env = data\n return testCase\n })\n }\n if (mediaType === 'application/json+log') {\n const log: webLog = JSON.parse(body)\n if (this.logs.length < 1000) this.logs.push(log)\n }\n if (mediaType === 'application/json+network') {\n const networkLog = JSON.parse(body)\n if (this.networkLog.length < 1000) this.networkLog.push(networkLog)\n }\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) return\n\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n if (mediaType === 'application/json') {\n const command: JsonCommand = JSON.parse(body)\n stepProgess.commands.push(command)\n }\n }\n private onTestStepFinished(testStepFinished: messages.TestStepFinished) {\n const { testStepId, testStepResult, timestamp } = testStepFinished\n const testStep = this.testStepMap.get(testStepId)\n if (testStep.pickleStepId === undefined) {\n if (testStepResult.status === 'FAILED') {\n console.error(\n `Before/After hook failed with message: ${testStepResult.message}`\n )\n }\n return\n }\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n const prevStepResult = stepProgess.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n let data = {}\n try {\n const reportFolder = this.reportFolder\n if (reportFolder === null) {\n throw new Error(\n '\"reportFolder\" is \"null\". Failed to run BVT hooks. Please retry after running \"Generate All\" or \"Record Scenario\" '\n )\n }\n if (fs.existsSync(path.join(reportFolder, 'data.json'))) {\n data = JSON.parse(\n fs.readFileSync(path.join(reportFolder, 'data.json'), 'utf8')\n )\n }\n } catch (error) {\n console.log('Error reading data.json')\n }\n stepProgess.result = {\n status: testStepResult.status,\n startTime: prevStepResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message: testStepResult.message,\n // exception: testStepResult.exception,\n }\n if (Object.keys(data).length > 0) {\n stepProgess.data = data\n }\n }\n getLogFileContent() {\n let projectPath = process.cwd()\n if (process.env.PROJECT_PATH) {\n projectPath = process.env.PROJECT_PATH\n }\n const logFolder = path.join(projectPath, 'logs', 'web')\n if (!fs.existsSync(logFolder)) {\n return []\n }\n let nextId = 1\n while (fs.existsSync(path.join(logFolder, `${nextId}.json`))) {\n nextId++\n }\n if (nextId === 1) {\n return []\n }\n try {\n const logFileContent = fs.readFileSync(\n path.join(logFolder, `${nextId - 1}.json`),\n 'utf8'\n )\n return JSON.parse(logFileContent)\n } catch (error) {\n return []\n }\n }\n private getTestCaseResult(steps: JsonStep[]) {\n for (const step of steps) {\n switch (step.result.status) {\n case 'FAILED':\n return {\n status: step.result.status,\n message: step.result.message,\n // exception: step.result.exception,\n } as const\n case 'AMBIGUOUS':\n case 'UNDEFINED':\n case 'PENDING':\n return {\n status: 'FAILED',\n message: `step \"${step.text}\" is ${step.result.status}`,\n } as const\n }\n }\n return {\n status: 'PASSED',\n } as const\n }\n private async onTestCaseFinished(\n testCaseFinished: messages.TestCaseFinished\n ) {\n const { testCaseStartedId, timestamp } = testCaseFinished\n const testProgress = this.testCaseReportMap.get(testCaseStartedId)\n const prevResult = testProgress.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n const steps = Object.values(testProgress.steps)\n const result = this.getTestCaseResult(steps)\n testProgress.result = {\n ...result,\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n }\n testProgress.webLog = this.logs\n testProgress.networkLog = this.networkLog\n this.networkLog = []\n this.logs = []\n await this.uploadTestCase(testProgress)\n }\n private async uploadTestCase(testCase: JsonTestProgress) {\n let runId = ''\n let projectId = ''\n if (!process.env.UPLOADING_TEST_CASE) {\n process.env.UPLOADING_TEST_CASE = '[]'\n }\n const anyRemArr = JSON.parse(process.env.UPLOADING_TEST_CASE) as string[]\n const randomID = Math.random().toString(36).substring(7)\n anyRemArr.push(randomID)\n process.env.UPLOADING_TEST_CASE = JSON.stringify(anyRemArr)\n try {\n if (process.env.RUN_ID && process.env.PROJECT_ID) {\n runId = process.env.RUN_ID\n projectId = process.env.PROJECT_ID\n } else {\n const runDoc = await this.uploadService.createRunDocument(this.runName)\n runId = runDoc._id\n projectId = runDoc.project_id\n process.env.RUN_ID = runId\n process.env.PROJECT_ID = projectId\n }\n await this.uploadService.uploadTestCase(\n testCase,\n runId,\n projectId,\n this.reportFolder\n )\n } catch (e) {\n console.error('Error uploading test case:', e)\n } finally {\n const arrRem = JSON.parse(process.env.UPLOADING_TEST_CASE) as string[]\n arrRem.splice(arrRem.indexOf(randomID), 1)\n process.env.UPLOADING_TEST_CASE = JSON.stringify(arrRem)\n }\n }\n private onTestRunFinished(testRunFinished: messages.TestRunFinished) {\n const { timestamp, success, message } = testRunFinished\n const prevResult = this.report.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\n }\n this.report.result = {\n status: success ? 'PASSED' : 'FAILED',\n startTime: prevResult.startTime,\n endTime: this.getTimeStamp(timestamp),\n message,\n // exception,\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
+
import { JsonTestProgress } from './report_generator';
|
|
2
3
|
declare class RunUploadService {
|
|
3
4
|
private runsApiBaseURL;
|
|
4
5
|
private accessToken;
|
|
@@ -6,7 +7,9 @@ declare class RunUploadService {
|
|
|
6
7
|
createRunDocument(name: string): Promise<any>;
|
|
7
8
|
upload(formData: FormData): Promise<void>;
|
|
8
9
|
getPreSignedUrls(fileUris: string[], runId: string): Promise<any>;
|
|
10
|
+
uploadTestCase(testCaseReport: JsonTestProgress, runId: string, projectId: string, reportFolder: string): Promise<void>;
|
|
9
11
|
uploadFile(filePath: string, preSignedUrl: string): Promise<boolean>;
|
|
10
12
|
uploadComplete(runId: string, projectId: string): Promise<void>;
|
|
13
|
+
modifyTestCase(runId: string, projectId: string, testProgressReport: JsonTestProgress): Promise<void>;
|
|
11
14
|
}
|
|
12
15
|
export { RunUploadService };
|
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
+
var _a, _b;
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
exports.RunUploadService = void 0;
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
10
|
const axios_client_1 = require("../../configuration/axios_client");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const bvt_analysis_formatter_1 = require("../bvt_analysis_formatter");
|
|
13
|
+
const REPORT_SERVICE_URL = (_a = process.env.REPORT_SERVICE_URL) !== null && _a !== void 0 ? _a : URL;
|
|
14
|
+
const BATCH_SIZE = 10;
|
|
15
|
+
const MAX_RETRIES = 3;
|
|
16
|
+
const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
|
|
10
17
|
class RunUploadService {
|
|
11
18
|
constructor(runsApiBaseURL, accessToken) {
|
|
12
19
|
this.runsApiBaseURL = runsApiBaseURL;
|
|
@@ -79,6 +86,51 @@ class RunUploadService {
|
|
|
79
86
|
}
|
|
80
87
|
return response.data.uploadUrls;
|
|
81
88
|
}
|
|
89
|
+
async uploadTestCase(testCaseReport, runId, projectId, reportFolder) {
|
|
90
|
+
const fileUris = [];
|
|
91
|
+
//iterate over all the files in the JsonCommand.screenshotId and insert them into the fileUris array
|
|
92
|
+
for (const step of testCaseReport.steps) {
|
|
93
|
+
for (const command of step.commands) {
|
|
94
|
+
if (command.screenshotId) {
|
|
95
|
+
fileUris.push(path_1.default.join('screenshots', String(command.screenshotId) + '.png'));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const preSignedUrls = await this.getPreSignedUrls(fileUris, runId);
|
|
100
|
+
//upload all the files in the fileUris array
|
|
101
|
+
try {
|
|
102
|
+
for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {
|
|
103
|
+
const batch = fileUris.slice(i, Math.min(i + BATCH_SIZE, fileUris.length));
|
|
104
|
+
await Promise.all(batch
|
|
105
|
+
.filter((fileUri) => preSignedUrls[fileUri])
|
|
106
|
+
.map(async (fileUri) => {
|
|
107
|
+
for (let j = 0; j < MAX_RETRIES; j++) {
|
|
108
|
+
if ((0, fs_1.existsSync)(path_1.default.join(reportFolder, fileUri))) {
|
|
109
|
+
const success = await this.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
|
|
110
|
+
if (success) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
console.error('Failed to upload file:', fileUri);
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/createNewTestCase', {
|
|
119
|
+
runId,
|
|
120
|
+
projectId,
|
|
121
|
+
testProgressReport: testCaseReport,
|
|
122
|
+
}, {
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: 'Bearer ' + this.accessToken,
|
|
125
|
+
'x-source': 'cucumber_js',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
console.error(`failed to upload the test case: ${testCaseReport.id} ${e}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
82
134
|
async uploadFile(filePath, preSignedUrl) {
|
|
83
135
|
const fileStream = (0, fs_1.createReadStream)(filePath);
|
|
84
136
|
let success = true;
|
|
@@ -120,6 +172,30 @@ class RunUploadService {
|
|
|
120
172
|
throw new Error('Failed to mark run as complete');
|
|
121
173
|
}
|
|
122
174
|
}
|
|
175
|
+
async modifyTestCase(runId, projectId, testProgressReport) {
|
|
176
|
+
try {
|
|
177
|
+
const res = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/modifyTestCase', {
|
|
178
|
+
runId,
|
|
179
|
+
projectId,
|
|
180
|
+
testProgressReport,
|
|
181
|
+
}, {
|
|
182
|
+
headers: {
|
|
183
|
+
Authorization: 'Bearer ' + this.accessToken,
|
|
184
|
+
'x-source': 'cucumber_js',
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
if (res.status !== 200) {
|
|
188
|
+
throw new Error('');
|
|
189
|
+
}
|
|
190
|
+
if (res.data.status !== true) {
|
|
191
|
+
throw new Error('');
|
|
192
|
+
}
|
|
193
|
+
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
console.error(`failed to modify the test case: ${testProgressReport.id} ${e}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
123
199
|
}
|
|
124
200
|
exports.RunUploadService = RunUploadService;
|
|
125
201
|
//# 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,2BAAqC;AACrC,2DAA4B;AAE5B,mEAA8D;AAE9D,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,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;gBACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;aAC3B,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;YACD,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG,EAAE;gBAC/B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aAC/D;YACD,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aAC/D;YACD,OA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AA;IAChB,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,KAAa,EAAE,SAAiB;QACnD,MAAM,QAAQ,GAAG,MAAM,0BAAW,CAAC,IAAI,CACrC,IAAI,CAAC,cAAc,GAAG,iCAAiC,EACvD;YACE,KAAK;YACL,SAAS;SACV,EACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,GAAG,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;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream } from 'fs'\nimport fs from 'fs/promises'\nimport { JsonReport } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\n\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 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\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}\n\nexport { RunUploadService }\n"]}
|
|
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,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;gBACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;aAC3B,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;YACD,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG,EAAE;gBAC/B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aAC/D;YACD,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;aAC/D;YACD,OAAO,YAAY,CAAC,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AI;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 path.join('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 if (existsSync(path.join(reportFolder, fileUri))) {\n const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\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,4 +1,4 @@
|
|
|
1
|
-
import ReportGenerator, { JsonReport } from './report_generator';
|
|
1
|
+
import ReportGenerator, { JsonReport, JsonTestProgress } from './report_generator';
|
|
2
2
|
export default class ReportUploader {
|
|
3
3
|
private uploadService;
|
|
4
4
|
private reportGenerator;
|
|
@@ -7,5 +7,6 @@ export default class ReportUploader {
|
|
|
7
7
|
runId: any;
|
|
8
8
|
projectId: any;
|
|
9
9
|
}>;
|
|
10
|
+
modifyTestCase(testCase: JsonTestProgress): Promise<void>;
|
|
10
11
|
createZip(reportFolder: string | null, report: JsonReport): Promise<string>;
|
|
11
12
|
}
|
|
@@ -74,7 +74,8 @@ class ReportUploader {
|
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
const fileUris = [
|
|
77
|
-
...
|
|
77
|
+
...getFileUris(reportFolder, 'screenshots'),
|
|
78
|
+
...getFileUris(reportFolder, 'trace'),
|
|
78
79
|
'report.json',
|
|
79
80
|
'network.json',
|
|
80
81
|
];
|
|
@@ -102,6 +103,17 @@ class ReportUploader {
|
|
|
102
103
|
}
|
|
103
104
|
return { runId: runDoc._id, projectId: runDoc.project_id };
|
|
104
105
|
}
|
|
106
|
+
async modifyTestCase(testCase) {
|
|
107
|
+
const runId = process.env.RUN_ID;
|
|
108
|
+
if (!runId) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const projectId = process.env.PROJECT_ID;
|
|
112
|
+
if (!projectId) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await this.uploadService.modifyTestCase(runId, projectId, testCase);
|
|
116
|
+
}
|
|
105
117
|
async createZip(reportFolder, report) {
|
|
106
118
|
if (reportFolder === null) {
|
|
107
119
|
console.error('report folder is empty');
|
|
@@ -118,7 +130,7 @@ class ReportUploader {
|
|
|
118
130
|
const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' });
|
|
119
131
|
// save zip file
|
|
120
132
|
const zipPath = path_1.default.join(reportFolder, 'report.zip');
|
|
121
|
-
fs_1.default.writeFileSync(zipPath, zipBuffer);
|
|
133
|
+
fs_1.default.writeFileSync(zipPath, new Uint8Array(zipBuffer));
|
|
122
134
|
fs_1.default.writeFileSync(path_1.default.join(reportFolder, 'report.json'), JSON.stringify(report, null, 2));
|
|
123
135
|
return zipPath;
|
|
124
136
|
}
|
|
@@ -128,4 +140,12 @@ const getFileUrisScreenShotDir = (reportFolder) => {
|
|
|
128
140
|
const files = fs_1.default.readdirSync(path_1.default.join(reportFolder, 'screenshots'));
|
|
129
141
|
return files.map((file) => ['screenshots', file].join('/'));
|
|
130
142
|
};
|
|
143
|
+
const getFileUris = (reportFolder, targetFolder) => {
|
|
144
|
+
const resultFolder = path_1.default.join(reportFolder, targetFolder);
|
|
145
|
+
if (!fs_1.default.existsSync(resultFolder)) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const files = fs_1.default.readdirSync(resultFolder);
|
|
149
|
+
return files.map((file) => [targetFolder, file].join('/'));
|
|
150
|
+
};
|
|
131
151
|
//# sourceMappingURL=uploader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAmD;AAEnD,0DAAg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OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,MAAM,CAAC,IAAI,CACT,IAAI,EACJ,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC,CAC9D,CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;QACjE,gBAAgB;QAChB,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;QACrD,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QACpC,YAAE,CAAC,aAAa,CACd,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,EACtC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAChC,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA/FD,iCA+FC;AACD,MAAM,wBAAwB,GAAG,CAAC,YAAoB,EAAE,EAAE;IACxD,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAA;IAEpE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7D,CAAC,CAAA","sourcesContent":["import ReportGenerator, { JsonReport } 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'\n\nlet URL\n\nswitch (process.env.NODE_ENV_BLINQ) {\n case 'stage':\n URL = 'https://stage.api.blinq.io/api/runs'\n break\n case 'dev':\n URL = 'https://dev.api.blinq.io/api/runs'\n break\n case 'local':\n URL = 'http://localhost:5001/api/runs'\n break\n default:\n URL = 'https://api.blinq.io/api/runs'\n}\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 ...getFileUrisScreenShotDir(reportFolder),\n 'report.json',\n 'network.json',\n ]\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\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 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, zipBuffer)\n fs.writeFileSync(\n path.join(reportFolder, 'report.json'),\n JSON.stringify(report, null, 2)\n )\n return zipPath\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"]}
|
|
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;AAEvB,IAAI,GAAG,CAAA;AAEP,QAAQ,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;IAClC,KAAK,OAAO;QACV,GAAG,GAAG,qCAAqC,CAAA;QAC3C,MAAK;IACP,KAAK,KAAK;QACR,GAAG,GAAG,mCAAmC,CAAA;QACzC,MAAK;IACP,KAAK,OAAO;QACV,GAAG,GAAG,gCAAgC,CAAA;QACtC,MAAK;IACP;QACE,GAAG,GAAG,+BAA+B,CAAA;CACx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AE,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'\n\nlet URL\n\nswitch (process.env.NODE_ENV_BLINQ) {\n case 'stage':\n URL = 'https://stage.api.blinq.io/api/runs'\n break\n case 'dev':\n URL = 'https://dev.api.blinq.io/api/runs'\n break\n case 'local':\n URL = 'http://localhost:5001/api/runs'\n break\n default:\n URL = 'https://api.blinq.io/api/runs'\n}\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"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.89-main";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,aAAa,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,aAAa,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.89-main'\n"]}
|