@dev-blinq/cucumber-js 1.0.208-dev → 1.0.209-dev
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/lib/formatter/bvt_analysis_formatter.d.ts +2 -0
- package/lib/formatter/bvt_analysis_formatter.js +51 -1
- package/lib/formatter/bvt_analysis_formatter.js.map +1 -1
- package/lib/formatter/helpers/upload_serivce.d.ts +8 -1
- package/lib/formatter/helpers/upload_serivce.js +106 -71
- package/lib/formatter/helpers/upload_serivce.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
|
@@ -29,3 +29,5 @@ export default class BVTAnalysisFormatter extends Formatter {
|
|
|
29
29
|
private getAppDataDir;
|
|
30
30
|
}
|
|
31
31
|
export declare function logReportLink(runId: string, projectId: string, status: JsonTestResult): string;
|
|
32
|
+
export declare function postUploadReportEvent(projectId: string, accessToken: string): Promise<void>;
|
|
33
|
+
export declare function createNewTestCase(payload: any, runsApiBaseURL: string, accessToken: string): Promise<any>;
|
|
@@ -3,7 +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 = exports.globalReportLink = void 0;
|
|
6
|
+
exports.createNewTestCase = exports.postUploadReportEvent = exports.logReportLink = exports.globalReportLink = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
@@ -367,4 +367,54 @@ function publishReportLinkToGuacServer(reportLink, result) {
|
|
|
367
367
|
execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result);
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
+
async function postUploadReportEvent(projectId, accessToken) {
|
|
371
|
+
try {
|
|
372
|
+
await axios_client_1.axiosClient.post(`${constants_1.SERVICES_URI.STORAGE}/event`, { event: constants_1.ActionEvents.upload_report }, {
|
|
373
|
+
headers: {
|
|
374
|
+
Authorization: 'Bearer ' + accessToken,
|
|
375
|
+
'x-source': 'cucumber_js',
|
|
376
|
+
'x-bvt-project-id': projectId,
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
catch (_a) { }
|
|
381
|
+
}
|
|
382
|
+
exports.postUploadReportEvent = postUploadReportEvent;
|
|
383
|
+
async function createNewTestCase(payload, runsApiBaseURL, accessToken) {
|
|
384
|
+
var _a, _b, _c, _d;
|
|
385
|
+
const jsonSizeKB = Buffer.byteLength(JSON.stringify(payload)) / 1024;
|
|
386
|
+
if (jsonSizeKB > 10240) {
|
|
387
|
+
// 10 MB
|
|
388
|
+
console.warn(`⚠️ Payload exceeds recommended size of 10MB: ${jsonSizeKB} KB`);
|
|
389
|
+
}
|
|
390
|
+
const MAX_RETRIES = 3;
|
|
391
|
+
const RETRY_DELAY_MS = 1000;
|
|
392
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
393
|
+
const start = Date.now();
|
|
394
|
+
try {
|
|
395
|
+
const { data } = await axios_client_1.axiosClient.post(`${runsApiBaseURL}/cucumber-runs/createNewTestCase`, payload, {
|
|
396
|
+
headers: {
|
|
397
|
+
Authorization: 'Bearer ' + accessToken,
|
|
398
|
+
'x-source': 'cucumber_js',
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
return data;
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
const isLastAttempt = attempt === MAX_RETRIES;
|
|
405
|
+
const errInfo = {
|
|
406
|
+
attempt,
|
|
407
|
+
message: e === null || e === void 0 ? void 0 : e.message,
|
|
408
|
+
status: (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
409
|
+
responseSnippet: (_d = (_c = (_b = e === null || e === void 0 ? void 0 : e.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.toString()) === null || _d === void 0 ? void 0 : _d.slice(0, 300),
|
|
410
|
+
durationMs: Date.now() - start,
|
|
411
|
+
};
|
|
412
|
+
console.error('🟥 Failed to POST /createNewTestCase:', JSON.stringify(errInfo, null, 2));
|
|
413
|
+
if (isLastAttempt)
|
|
414
|
+
throw e;
|
|
415
|
+
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt));
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
exports.createNewTestCase = createNewTestCase;
|
|
370
420
|
//# 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,2BAA4D;AAC5D,0CAAsD;AACtD,gDAAuB;AACvB,6BAA6B;AAC7B,yCAAgD;AAChD,oDAAgD;AAChD,kFAKmC;AACnC,kEAA+C;AAC/C,4CAAmB;AACnB,+BAA6C;AAC7C,4EAAkD;AAClD,mDAAgE;AAChE,gEAA2D;AAK3D,+BAAgC;AAChC,iDAAoC;AAGpC,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQpB,QAAA,gBAAgB,GAAG,EAAE,CAAA;AAChC,MAAqB,oBAAqB,SAAQ,UAAS;IAiBzD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QAbR,oBAAe,GAAG,IAAI,0BAAe,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,kBAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACnD,SAAI,GAAG,KAAK,CAAA;QAKZ,mBAAc,GAGhB,EAAE,CAAA;QAIN,IAAI,CAAC,gBAAgB,GAAG,IAAI,2BAAgB,CAAC,OAAO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O,EAAE;QACjD,iBAAiB,GAAG,4BAA4B,CAAA;KACjD;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE;QAChD,iBAAiB,GAAG,sBAAsB,CAAA;KAC3C;SAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QACtC,iBAAiB,GAAG,sBAAsB,CAAA;KAC3C;SAAM;QACL,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;KACrE;IACD,MAAM,UAAU,GAAG,GAAG,iBAAiB,IAAI,SAAS,eAAe,KAAK,EAAE,CAAA;IAC1E,wBAAgB,GAAG,UAAU,CAAA;IAC7B,IAAI;QACF,6BAA6B,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAA;KACtE;IAAC,OAAO,GAAG,EAAE;QACZ,8BAA8B;KAC/B;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AA3BD,sCA2BC;AAED,SAAS,6BAA6B,CAAC,UAAkB,EAAE,MAAe;IACxE,IAAI,IAAA,eAAU,EAAC,wBAAwB,CAAC,EAAE;QACxC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAA;QACjC,SAAS,CAAC,4BAA4B,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,CAAC,CAAA;KACpE;AACH,CAAC","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'\nimport SummaryFormatter from './summary_formatter'\nimport { ActionEvents, SERVICES_URI } from './helpers/constants'\nimport { axiosClient } from '../configuration/axios_client'\nimport {\n FinishTestCaseResponse,\n RootCauseProps,\n} from './helpers/upload_serivce'\nimport { promisify } from 'util'\nimport { exec } from 'child_process'\nimport { isCloudRecorder } from './helpers/isCloudRecorder'\n\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 let globalReportLink = ''\nexport default class BVTAnalysisFormatter extends Formatter {\n static reportGenerator: ReportGenerator\n static reRunFailedStepsIndex:\n | { testCaseId: string; failedStepIndex: number }[]\n | null\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 private failedStepsIndex: { testCaseId: string; failedStepIndex: number }[]\n private summaryFormatter: SummaryFormatter\n private rootCauseArray: {\n rootCause: RootCauseProps\n report: JsonTestProgress\n }[] = []\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.summaryFormatter = new SummaryFormatter(options)\n BVTAnalysisFormatter.reportGenerator = this.reportGenerator\n this.rootCauseArray = []\n this.failedStepsIndex = []\n BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN\n ? JSON.parse(process.env.RERUN)\n : null\n\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n this.sendEvent(ActionEvents.cli_run_tests)\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage, data?: any) => {\n if (doesHaveValue(envelope.testCaseFinished) && data) {\n const { rootCause, report } = data as FinishTestCaseResponse\n\n if (!rootCause.status) {\n console.error(\n `Root cause: ${rootCause.failClass}\\n, ${rootCause.analysis}\\nfailing step: ${rootCause.failedStep}`\n )\n this.rootCauseArray.push({ rootCause, report })\n this.failedStepsIndex.push({\n testCaseId: report.id,\n failedStepIndex: rootCause.failedStep,\n })\n }\n return\n }\n await this.reportGenerator.handleMessage(envelope)\n\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 this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport()\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private sendEvent(event: ActionEvents) {\n axiosClient\n .post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event,\n },\n {\n headers: {\n Authorization: `Bearer ${TOKEN}`,\n 'x-source': 'cucumber_js',\n },\n }\n )\n .catch((err) => {\n // Error with events, ignoring\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() {\n if (\n this.rootCauseArray.length === 0 ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (this.rootCauseArray.length === 0) {\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\n this.log('Some tests failed, starting the retraining...\\n')\n await this.processTestCases()\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n }\n process.exit(0)\n }\n private async processTestCases() {\n for (const { rootCause, report } of this.rootCauseArray) {\n await this.processTestCase(rootCause, report)\n }\n }\n private async processTestCase(\n rootCause: RootCauseProps,\n report: JsonTestProgress\n ) {\n const failedTestSteps = rootCause.failedStep\n\n if (\n BVTAnalysisFormatter.reRunFailedStepsIndex &&\n BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0\n ) {\n const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0]\n if (previousRun.failedStepIndex === failedTestSteps) {\n console.log('Same step has failed again, skipping retraining')\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n return\n }\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n }\n\n const retrainStats = await this.retrain(failedTestSteps, report)\n\n if (!retrainStats) {\n return\n }\n\n await this.uploader.modifyTestCase({\n ...report,\n retrainStats,\n })\n\n await this.rerun(report)\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, finalReport.result)\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 rerun(report: JsonTestProgress) {\n await new Promise<void>((resolve) => {\n // Default to system Node.js\n let node_path = process.argv.shift()\n\n // Use bundled Node if running from recorder app on macOS or Windows\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true'\n const isSupportedPlatform =\n process.platform === 'darwin' || process.platform === 'win32'\n\n if (isFromRecorderApp && isSupportedPlatform) {\n node_path = process.execPath\n }\n\n const args = [\n path.join(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber-js',\n 'bin',\n 'cucumber.js'\n ),\n '--name',\n `^${report.scenarioName}$`,\n '--exit',\n '--format',\n 'bvt',\n '--run-name',\n `${report.scenarioName}@debug`,\n path.join(process.cwd(), report.uri),\n ]\n\n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n RERUN: JSON.stringify(this.failedStepsIndex),\n }\n\n // Inject Electron node env only if using bundled node\n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = '1'\n }\n\n const cucumberClient = spawn(node_path!, args, {\n env: envVars,\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', () => {\n resolve()\n })\n })\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},`,\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\n if (!existsSync(path.dirname(tempFile))) {\n await mkdir(path.dirname(tempFile), { recursive: true })\n }\n await writeFile(tempFile, '', 'utf-8')\n\n args.push(`--temp-file=${tempFile}`)\n\n // Determine node path\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true'\n const isSupportedPlatform =\n process.platform === 'darwin' || process.platform === 'win32'\n const node_path =\n isFromRecorderApp && isSupportedPlatform ? process.execPath : 'node'\n\n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n TEMP_FILE_PATH: tempFile,\n }\n\n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = '1'\n }\n\n const cucumberClient = spawn(\n node_path,\n [cucumber_client_path, ...args],\n {\n env: envVars,\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 try {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } catch (e) {\n this.log('Error reading scenario report\\n ' + e)\n resolve(null)\n }\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(\n runId: string,\n projectId: string,\n status: JsonTestResult\n) {\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 } else if (process.env.NODE_ENV_BLINQ === 'prod') {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else if (!process.env.NODE_ENV_BLINQ) {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else {\n reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app')\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n globalReportLink = reportLink\n try {\n publishReportLinkToGuacServer(reportLink, status.status === 'PASSED')\n } catch (err) {\n // Error with events, ignoring\n }\n return reportLink\n}\n\nfunction publishReportLinkToGuacServer(reportLink: string, result: boolean) {\n if (existsSync('/tmp/report_publish.sh')) {\n const execAsync = promisify(exec)\n execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result)\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,4EAAkD;AAClD,mDAAgE;AAChE,gEAA2D;AAK3D,+BAAgC;AAChC,iDAAoC;AAGpC,YAAY;AACZ,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;AAQpB,QAAA,gBAAgB,GAAG,EAAE,CAAA;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,OAAO,EAAE,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO;gBACnB,MAAM,EAAE,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,0CAAE,MAAM;gBAC3B,eAAe,EAAE,MAAA,MAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,0CAAE,IAAI,0CAAE,QAAQ,EAAE,0CAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;gBAC7D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;aAC/B,CAAA;YACD,OAAO,CAAC,KAAK,CACX,uCAAuC,EACvC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CACjC,CAAA;YAED,IAAI,aAAa;gBAAE,MAAM,CAAC,CAAA;YAE1B,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAA;SAClE;KACF;AACH,CAAC;AAlDD,8CAkDC","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'\nimport SummaryFormatter from './summary_formatter'\nimport { ActionEvents, SERVICES_URI } from './helpers/constants'\nimport { axiosClient } from '../configuration/axios_client'\nimport {\n FinishTestCaseResponse,\n RootCauseProps,\n} from './helpers/upload_serivce'\nimport { promisify } from 'util'\nimport { exec } from 'child_process'\nimport { isCloudRecorder } from './helpers/isCloudRecorder'\n\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 let globalReportLink = ''\nexport default class BVTAnalysisFormatter extends Formatter {\n static reportGenerator: ReportGenerator\n static reRunFailedStepsIndex:\n | { testCaseId: string; failedStepIndex: number }[]\n | null\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 private failedStepsIndex: { testCaseId: string; failedStepIndex: number }[]\n private summaryFormatter: SummaryFormatter\n private rootCauseArray: {\n rootCause: RootCauseProps\n report: JsonTestProgress\n }[] = []\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.summaryFormatter = new SummaryFormatter(options)\n BVTAnalysisFormatter.reportGenerator = this.reportGenerator\n this.rootCauseArray = []\n this.failedStepsIndex = []\n BVTAnalysisFormatter.reRunFailedStepsIndex = process.env.RERUN\n ? JSON.parse(process.env.RERUN)\n : null\n\n if (!TOKEN && process.env.BVT_FORMATTER === 'ANALYSIS') {\n throw new Error('TOKEN must be set')\n }\n this.sendEvent(ActionEvents.cli_run_tests)\n options.eventBroadcaster.on(\n 'envelope',\n async (envelope: EnvelopeWithMetaMessage, data?: any) => {\n if (doesHaveValue(envelope.testCaseFinished) && data) {\n const { rootCause, report } = data as FinishTestCaseResponse\n\n if (!rootCause.status) {\n console.error(\n `Root cause: ${rootCause.failClass}\\n, ${rootCause.analysis}\\nfailing step: ${rootCause.failedStep}`\n )\n this.rootCauseArray.push({ rootCause, report })\n this.failedStepsIndex.push({\n testCaseId: report.id,\n failedStepIndex: rootCause.failedStep,\n })\n }\n return\n }\n await this.reportGenerator.handleMessage(envelope)\n\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 this.START = Date.now()\n if (process.env.BVT_FORMATTER === 'ANALYSIS') {\n await this.analyzeReport()\n } else {\n // await this.uploadReport(report)\n }\n this.exit = true\n }\n }\n )\n }\n\n private sendEvent(event: ActionEvents) {\n axiosClient\n .post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event,\n },\n {\n headers: {\n Authorization: `Bearer ${TOKEN}`,\n 'x-source': 'cucumber_js',\n },\n }\n )\n .catch((err) => {\n // Error with events, ignoring\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() {\n if (\n this.rootCauseArray.length === 0 ||\n process.env.NO_RETRAIN === 'false'\n ) {\n if (this.rootCauseArray.length === 0) {\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\n this.log('Some tests failed, starting the retraining...\\n')\n await this.processTestCases()\n if (this.reportGenerator.getReport().result.status === 'FAILED') {\n process.exit(1)\n }\n process.exit(0)\n }\n private async processTestCases() {\n for (const { rootCause, report } of this.rootCauseArray) {\n await this.processTestCase(rootCause, report)\n }\n }\n private async processTestCase(\n rootCause: RootCauseProps,\n report: JsonTestProgress\n ) {\n const failedTestSteps = rootCause.failedStep\n\n if (\n BVTAnalysisFormatter.reRunFailedStepsIndex &&\n BVTAnalysisFormatter.reRunFailedStepsIndex.length > 0\n ) {\n const previousRun = BVTAnalysisFormatter.reRunFailedStepsIndex[0]\n if (previousRun.failedStepIndex === failedTestSteps) {\n console.log('Same step has failed again, skipping retraining')\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n return\n }\n BVTAnalysisFormatter.reRunFailedStepsIndex.shift()\n }\n\n const retrainStats = await this.retrain(failedTestSteps, report)\n\n if (!retrainStats) {\n return\n }\n\n await this.uploader.modifyTestCase({\n ...report,\n retrainStats,\n })\n\n await this.rerun(report)\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, finalReport.result)\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 rerun(report: JsonTestProgress) {\n await new Promise<void>((resolve) => {\n // Default to system Node.js\n let node_path = process.argv.shift()\n\n // Use bundled Node if running from recorder app on macOS or Windows\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true'\n const isSupportedPlatform =\n process.platform === 'darwin' || process.platform === 'win32'\n\n if (isFromRecorderApp && isSupportedPlatform) {\n node_path = process.execPath\n }\n\n const args = [\n path.join(\n process.cwd(),\n 'node_modules',\n '@dev-blinq',\n 'cucumber-js',\n 'bin',\n 'cucumber.js'\n ),\n '--name',\n `^${report.scenarioName}$`,\n '--exit',\n '--format',\n 'bvt',\n '--run-name',\n `${report.scenarioName}@debug`,\n path.join(process.cwd(), report.uri),\n ]\n\n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n RERUN: JSON.stringify(this.failedStepsIndex),\n }\n\n // Inject Electron node env only if using bundled node\n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = '1'\n }\n\n const cucumberClient = spawn(node_path!, args, {\n env: envVars,\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', () => {\n resolve()\n })\n })\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},`,\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\n if (!existsSync(path.dirname(tempFile))) {\n await mkdir(path.dirname(tempFile), { recursive: true })\n }\n await writeFile(tempFile, '', 'utf-8')\n\n args.push(`--temp-file=${tempFile}`)\n\n // Determine node path\n const isFromRecorderApp = process.env.FROM_RECORDER_APP === 'true'\n const isSupportedPlatform =\n process.platform === 'darwin' || process.platform === 'win32'\n const node_path =\n isFromRecorderApp && isSupportedPlatform ? process.execPath : 'node'\n\n const envVars: NodeJS.ProcessEnv = {\n ...process.env,\n TEMP_FILE_PATH: tempFile,\n }\n\n if (node_path === process.execPath) {\n envVars.ELECTRON_RUN_AS_NODE = '1'\n }\n\n const cucumberClient = spawn(\n node_path,\n [cucumber_client_path, ...args],\n {\n env: envVars,\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 try {\n const reportData = readFileSync(tempFile, 'utf-8')\n const retrainStats = JSON.parse(reportData) as RetrainStats\n await unlink(tempFile)\n resolve(retrainStats)\n } catch (e) {\n this.log('Error reading scenario report\\n ' + e)\n resolve(null)\n }\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(\n runId: string,\n projectId: string,\n status: JsonTestResult\n) {\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 } else if (process.env.NODE_ENV_BLINQ === 'prod') {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else if (!process.env.NODE_ENV_BLINQ) {\n reportLinkBaseUrl = 'https://app.blinq.io'\n } else {\n reportLinkBaseUrl = process.env.NODE_ENV_BLINQ.replace('api', 'app')\n }\n const reportLink = `${reportLinkBaseUrl}/${projectId}/run-report/${runId}`\n globalReportLink = reportLink\n try {\n publishReportLinkToGuacServer(reportLink, status.status === 'PASSED')\n } catch (err) {\n // Error with events, ignoring\n }\n return reportLink\n}\n\nfunction publishReportLinkToGuacServer(reportLink: string, result: boolean) {\n if (existsSync('/tmp/report_publish.sh')) {\n const execAsync = promisify(exec)\n execAsync('sh /tmp/report_publish.sh ' + reportLink + ' ' + result)\n }\n}\n\nexport async function postUploadReportEvent(\n projectId: string,\n accessToken: string\n) {\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n { event: ActionEvents.upload_report },\n {\n headers: {\n Authorization: 'Bearer ' + accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch {}\n}\n\nexport async function createNewTestCase(\n payload: any,\n runsApiBaseURL: string,\n accessToken: string\n): Promise<any> {\n const jsonSizeKB = Buffer.byteLength(JSON.stringify(payload)) / 1024\n\n if (jsonSizeKB > 10240) {\n // 10 MB\n console.warn(\n `⚠️ Payload exceeds recommended size of 10MB: ${jsonSizeKB} KB`\n )\n }\n\n const MAX_RETRIES = 3\n const RETRY_DELAY_MS = 1000\n\n for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n const start = Date.now()\n try {\n const { data } = await axiosClient.post(\n `${runsApiBaseURL}/cucumber-runs/createNewTestCase`,\n payload,\n {\n headers: {\n Authorization: 'Bearer ' + accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n return data\n } catch (e: any) {\n const isLastAttempt = attempt === MAX_RETRIES\n const errInfo = {\n attempt,\n message: e?.message,\n status: e?.response?.status,\n responseSnippet: e?.response?.data?.toString()?.slice(0, 300),\n durationMs: Date.now() - start,\n }\n console.error(\n '🟥 Failed to POST /createNewTestCase:',\n JSON.stringify(errInfo, null, 2)\n )\n\n if (isLastAttempt) throw e\n\n await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt))\n }\n }\n}\n"]}
|
|
@@ -19,7 +19,14 @@ declare class RunUploadService {
|
|
|
19
19
|
updateProjectAnalytics(projectId: string): Promise<void>;
|
|
20
20
|
upload(formData: FormData): Promise<void>;
|
|
21
21
|
getPreSignedUrls(fileUris: string[], runId: string): Promise<any>;
|
|
22
|
-
uploadTestCase(testCaseReport: JsonTestProgress, runId: string, projectId: string, reportFolder: string, rerunId?: string): Promise<
|
|
22
|
+
uploadTestCase(testCaseReport: JsonTestProgress, runId: string, projectId: string, reportFolder: string, rerunId?: string): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Improving error logging
|
|
25
|
+
* 🔧 Sanitizes Axios errors to avoid dumping Cloudflare HTML (524, 502, etc.)
|
|
26
|
+
*/
|
|
27
|
+
private sanitizeError;
|
|
28
|
+
uploadFileWithRetries(filePath: string, presignedUrl: string): Promise<boolean>;
|
|
29
|
+
uploadFilesInBatches(fileUris: string[], reportFolder: string, preSignedUrls: Record<string, string>): Promise<void>;
|
|
23
30
|
uploadFile(filePath: string, preSignedUrl: string): Promise<boolean>;
|
|
24
31
|
uploadComplete(runId: string, projectId: string): Promise<void>;
|
|
25
32
|
modifyTestCase(runId: string, projectId: string, testProgressReport: JsonTestProgress): Promise<void>;
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.RunUploadService = void 0;
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const p_limit_1 = __importDefault(require("p-limit"));
|
|
10
11
|
const axios_client_1 = require("../../configuration/axios_client");
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
12
13
|
const bvt_analysis_formatter_1 = require("../bvt_analysis_formatter");
|
|
@@ -125,108 +126,141 @@ class RunUploadService {
|
|
|
125
126
|
return response.data.uploadUrls;
|
|
126
127
|
}
|
|
127
128
|
async uploadTestCase(testCaseReport, runId, projectId, reportFolder, rerunId) {
|
|
128
|
-
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
if (process.env.UPLOADREPORTS === 'false')
|
|
129
131
|
return null;
|
|
130
|
-
}
|
|
131
132
|
const fileUris = [];
|
|
132
|
-
//
|
|
133
|
+
// Collect screenshot + trace + logs
|
|
133
134
|
for (const step of testCaseReport.steps) {
|
|
134
135
|
for (const command of step.commands) {
|
|
135
|
-
if (command.screenshotId)
|
|
136
|
-
fileUris.push(
|
|
137
|
-
}
|
|
136
|
+
if (command.screenshotId)
|
|
137
|
+
fileUris.push(`screenshots/${command.screenshotId}.png`);
|
|
138
138
|
}
|
|
139
|
-
if (step.traceFilePath)
|
|
140
|
-
fileUris.push(
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (testCaseReport.logFileId) {
|
|
144
|
-
fileUris.push('editorLogs' + '/' + 'testCaseLog_' + testCaseReport.logFileId + '.log');
|
|
139
|
+
if (step.traceFilePath)
|
|
140
|
+
fileUris.push(`trace/${step.traceFilePath}`);
|
|
145
141
|
}
|
|
146
|
-
if (testCaseReport.
|
|
142
|
+
if (testCaseReport.logFileId)
|
|
143
|
+
fileUris.push(`editorLogs/testCaseLog_${testCaseReport.logFileId}.log`);
|
|
144
|
+
if (testCaseReport.traceFileId)
|
|
147
145
|
fileUris.push(`trace/${testCaseReport.traceFileId}`);
|
|
148
|
-
|
|
149
|
-
// console.log({ fileUris })
|
|
150
|
-
//upload all the files in the fileUris array
|
|
146
|
+
// 🔹 UPLOAD FILES
|
|
151
147
|
try {
|
|
152
148
|
const preSignedUrls = await this.getPreSignedUrls(fileUris, runId);
|
|
153
|
-
|
|
154
|
-
const batch = fileUris.slice(i, Math.min(i + BATCH_SIZE, fileUris.length));
|
|
155
|
-
await Promise.all(batch
|
|
156
|
-
.filter((fileUri) => preSignedUrls[fileUri])
|
|
157
|
-
.map(async (fileUri) => {
|
|
158
|
-
for (let j = 0; j < MAX_RETRIES; j++) {
|
|
159
|
-
if ((0, fs_1.existsSync)(path_1.default.join(reportFolder, fileUri))) {
|
|
160
|
-
const success = await this.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
|
|
161
|
-
if (success) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const success = await this.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
|
|
166
|
-
if (success) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
console.error('Failed to upload file:', fileUri);
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
149
|
+
await this.uploadFilesInBatches(fileUris, reportFolder, preSignedUrls);
|
|
173
150
|
}
|
|
174
151
|
catch (error) {
|
|
175
|
-
|
|
176
|
-
|
|
152
|
+
console.error('🟥 Error uploading files:', {
|
|
153
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
154
|
+
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
155
|
+
});
|
|
177
156
|
}
|
|
157
|
+
// 🔹 UPLOAD FINAL TEST REPORT
|
|
178
158
|
try {
|
|
179
|
-
// writeFileSync("report.json", JSON.stringify(testCaseReport, null, 2))
|
|
180
159
|
const mode = process.env.MODE === 'cloud'
|
|
181
160
|
? 'cloud'
|
|
182
161
|
: process.env.MODE === 'executions'
|
|
183
162
|
? 'executions'
|
|
184
163
|
: 'local';
|
|
185
|
-
let rerunIdFinal = null;
|
|
186
|
-
|
|
187
|
-
if (rerunId) {
|
|
164
|
+
let rerunIdFinal = process.env.RETRY_ID || null;
|
|
165
|
+
if (rerunId)
|
|
188
166
|
rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`;
|
|
189
|
-
|
|
190
|
-
if (mode === 'executions') {
|
|
167
|
+
if (mode === 'executions')
|
|
191
168
|
testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id;
|
|
192
|
-
|
|
193
|
-
const { data } = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/createNewTestCase', {
|
|
169
|
+
const payload = {
|
|
194
170
|
runId,
|
|
195
171
|
projectId,
|
|
196
172
|
testProgressReport: testCaseReport,
|
|
197
|
-
browser: process.env.BROWSER
|
|
173
|
+
browser: process.env.BROWSER || 'chromium',
|
|
198
174
|
mode,
|
|
199
175
|
rerunId: rerunIdFinal,
|
|
200
176
|
video_id: process.env.VIDEO_ID,
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
'x-source': 'cucumber_js',
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
try {
|
|
208
|
-
await axios_client_1.axiosClient.post(`${constants_1.SERVICES_URI.STORAGE}/event`, {
|
|
209
|
-
event: constants_1.ActionEvents.upload_report,
|
|
210
|
-
}, {
|
|
211
|
-
headers: {
|
|
212
|
-
Authorization: 'Bearer ' + this.accessToken,
|
|
213
|
-
'x-source': 'cucumber_js',
|
|
214
|
-
'x-bvt-project-id': projectId,
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
// no event tracking
|
|
220
|
-
}
|
|
177
|
+
};
|
|
178
|
+
const data = await (0, bvt_analysis_formatter_1.createNewTestCase)(payload, this.runsApiBaseURL, this.accessToken);
|
|
179
|
+
await (0, bvt_analysis_formatter_1.postUploadReportEvent)(projectId, this.accessToken);
|
|
221
180
|
(0, bvt_analysis_formatter_1.logReportLink)(runId, projectId, testCaseReport.result);
|
|
222
181
|
return data;
|
|
223
182
|
}
|
|
224
183
|
catch (e) {
|
|
225
|
-
|
|
226
|
-
|
|
184
|
+
console.error('🟥 Failed to upload test case:', {
|
|
185
|
+
testCaseId: testCaseReport.id,
|
|
186
|
+
message: e === null || e === void 0 ? void 0 : e.message,
|
|
187
|
+
status: (_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
188
|
+
responseSnippet: (_d = (_c = (_b = e === null || e === void 0 ? void 0 : e.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.toString()) === null || _d === void 0 ? void 0 : _d.slice(0, 300),
|
|
189
|
+
stack: e === null || e === void 0 ? void 0 : e.stack,
|
|
190
|
+
});
|
|
227
191
|
return null;
|
|
228
192
|
}
|
|
229
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Improving error logging
|
|
196
|
+
* 🔧 Sanitizes Axios errors to avoid dumping Cloudflare HTML (524, 502, etc.)
|
|
197
|
+
*/
|
|
198
|
+
sanitizeError(error) {
|
|
199
|
+
// Handle Axios-style errors with response
|
|
200
|
+
if (error === null || error === void 0 ? void 0 : error.response) {
|
|
201
|
+
const { data, status } = error.response;
|
|
202
|
+
// If Cloudflare or HTML error page → return a short meaningful message
|
|
203
|
+
if (typeof data === 'string' && data.includes('<!DOCTYPE html')) {
|
|
204
|
+
return `[HTML_ERROR_PAGE] status=${status} - likely Cloudflare timeout or proxy error`;
|
|
205
|
+
}
|
|
206
|
+
// If data is a JSON object, stringify it with indentation for readability
|
|
207
|
+
if (typeof data === 'object') {
|
|
208
|
+
return JSON.stringify(data, null, 2); // Pretty-print the JSON response
|
|
209
|
+
}
|
|
210
|
+
// If response is a string (could be an error message), return it trimmed
|
|
211
|
+
return (data === null || data === void 0 ? void 0 : data.trim()) || `Unknown response data (status: ${status})`;
|
|
212
|
+
}
|
|
213
|
+
// System / network errors (e.g., if Axios cannot reach the server)
|
|
214
|
+
if (error === null || error === void 0 ? void 0 : error.message) {
|
|
215
|
+
return error.message;
|
|
216
|
+
}
|
|
217
|
+
// If the error has a stack (for debugging purposes)
|
|
218
|
+
if (error === null || error === void 0 ? void 0 : error.stack) {
|
|
219
|
+
return `${error.message}\n${error.stack}`;
|
|
220
|
+
}
|
|
221
|
+
// If it's a generic error object, attempt to stringify it in a readable format
|
|
222
|
+
return JSON.stringify(error, (key, value) => {
|
|
223
|
+
// Avoid circular references or sensitive data
|
|
224
|
+
if (key === 'password' || key === 'accessToken')
|
|
225
|
+
return '[REDACTED]';
|
|
226
|
+
return value;
|
|
227
|
+
}, 2); // Pretty-print the error object with indentation
|
|
228
|
+
}
|
|
229
|
+
async uploadFileWithRetries(filePath, presignedUrl) {
|
|
230
|
+
const MAX_RETRIES = 3;
|
|
231
|
+
const RETRY_DELAY_MS = 1000;
|
|
232
|
+
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
233
|
+
try {
|
|
234
|
+
const ok = await this.uploadFile(filePath, presignedUrl);
|
|
235
|
+
if (ok)
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
console.error(`Upload attempt #${attempt} failed for ${filePath}:`, {
|
|
240
|
+
message: err === null || err === void 0 ? void 0 : err.message,
|
|
241
|
+
stack: err === null || err === void 0 ? void 0 : err.stack,
|
|
242
|
+
});
|
|
243
|
+
if (attempt < MAX_RETRIES) {
|
|
244
|
+
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
console.error(`Failed to upload file after ${MAX_RETRIES} retries: ${filePath}`);
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
async uploadFilesInBatches(fileUris, reportFolder, preSignedUrls) {
|
|
252
|
+
const MAX_CONCURRENCY = 5;
|
|
253
|
+
const limit = (0, p_limit_1.default)(MAX_CONCURRENCY);
|
|
254
|
+
const tasks = fileUris
|
|
255
|
+
.filter((uri) => preSignedUrls[uri])
|
|
256
|
+
.map((uri) => limit(async () => {
|
|
257
|
+
const filePath = path_1.default.join(reportFolder, uri);
|
|
258
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
259
|
+
await this.uploadFileWithRetries(filePath, preSignedUrls[uri]);
|
|
260
|
+
}
|
|
261
|
+
}));
|
|
262
|
+
await Promise.all(tasks);
|
|
263
|
+
}
|
|
230
264
|
async uploadFile(filePath, preSignedUrl) {
|
|
231
265
|
if (process.env.UPLOADREPORTS === 'false') {
|
|
232
266
|
return true;
|
|
@@ -244,8 +278,9 @@ class RunUploadService {
|
|
|
244
278
|
});
|
|
245
279
|
}
|
|
246
280
|
catch (error) {
|
|
247
|
-
if (process.env.
|
|
248
|
-
|
|
281
|
+
if (process.env.MODE === 'executions') {
|
|
282
|
+
const sanitized = this.sanitizeError(error);
|
|
283
|
+
console.error('❌ Error uploading file at:', filePath, 'due to', sanitized);
|
|
249
284
|
}
|
|
250
285
|
success = false;
|
|
251
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAuE;AACvE,2DAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAAyD;AACzD,2CAAwD;AAExD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAevD,MAAM,gBAAgB;IACpB,YAAoB,cAAsB,EAAU,WAAmB;QAAnD,mBAAc,GAAd,cAAc,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAC3E,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,GAAQ;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,aAA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AE;gBAClB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;aACvB,EACD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;oBAC3C,UAAU,EAAE,aAAa;iBAC1B;aACF,CACF,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync, write, writeFileSync } from 'fs'\nimport fs from 'fs/promises'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport { logReportLink } from '../bvt_analysis_formatter'\nimport { ActionEvents, SERVICES_URI } from './constants'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport interface RootCauseProps {\n status: boolean\n analysis: string\n failedStep: number\n failClass: string\n}\n\nexport interface FinishTestCaseResponse {\n status: true\n rootCause: RootCauseProps\n report: JsonTestProgress\n}\n\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string, env: any) {\n if (process.env.UPLOADREPORTS === 'false') {\n console.log('Skipping report upload as UPLOADREPORTS is set to false')\n return { id: 'local-run', projectId: 'local-project' }\n }\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : 'main',\n video_id: process.env.VIDEO_ID,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n env: { name: env?.name, baseUrl: env?.baseUrl },\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async updateProjectAnalytics(projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/project/updateAIRecoveryCount',\n {\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.error('Failed to update project metadata:', error)\n }\n }\n async upload(formData: FormData) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return {}\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string,\n rerunId?: string\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return null\n }\n const fileUris = []\n //iterate over all the files in the JsonCommand.screenshotId and insert them into the fileUris array\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId) {\n fileUris.push(\n 'screenshots' + '/' + String(command.screenshotId) + '.png'\n )\n }\n }\n if (step.traceFilePath) {\n fileUris.push('trace' + '/' + step.traceFilePath)\n }\n }\n if (testCaseReport.logFileId) {\n fileUris.push(\n 'editorLogs' + '/' + 'testCaseLog_' + testCaseReport.logFileId + '.log'\n )\n }\n if (testCaseReport.traceFileId) {\n fileUris.push(`trace/${testCaseReport.traceFileId}`)\n }\n // console.log({ fileUris })\n //upload all the files in the fileUris array\n\n try {\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\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 const success = await this.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n if (success) {\n return\n }\n }\n console.error('Failed to upload file:', fileUri)\n })\n )\n }\n } catch (error) {\n const errorMessage = error.response ? error.response.data : error.message\n console.error('Error uploading files:', errorMessage)\n }\n\n try {\n // writeFileSync(\"report.json\", JSON.stringify(testCaseReport, null, 2))\n const mode =\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local'\n\n let rerunIdFinal = null\n\n rerunIdFinal = process.env.RETRY_ID || null\n if (rerunId) {\n rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`\n }\n\n if (mode === 'executions') {\n testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id\n }\n\n const { data } = await axiosClient.post<FinishTestCaseResponse>(\n this.runsApiBaseURL + '/cucumber-runs/createNewTestCase',\n {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode,\n rerunId: rerunIdFinal,\n video_id: process.env.VIDEO_ID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n logReportLink(runId, projectId, testCaseReport.result)\n return data\n } catch (e) {\n const errorMessage = e.response ? e.response.data : e.message\n console.error(\n `failed to upload the test case: ${testCaseReport.id} ${errorMessage}`\n )\n return null\n }\n }\n async uploadFile(filePath: string, preSignedUrl: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return true\n }\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.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 if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId, testProgressReport.result)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n async createStatus(status: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n if (!process.env.UUID) {\n return\n }\n\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/scenarios/status',\n {\n status: { status },\n uuid: process.env.UUID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.log('Failed to send status to the server, ignoring it')\n }\n }\n}\n\nexport { RunUploadService }\n"]}
|
|
1
|
+
{"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;;AAEA,2BAAuE;AACvE,2DAA4B;AAC5B,sDAA4B;AAG5B,mEAA8D;AAC9D,gDAAuB;AACvB,sEAIkC;AAClC,2CAAwD;AAExD,MAAM,kBAAkB,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,mCAAI,GAAG,CAAA;AAChE,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,oBAAoB,GACxB,MAAA,OAAO,CAAC,GAAG,CAAC,KAAK,mCAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;AAevD,MAAM,gBAAgB;IACpB,YACU,cAAsB,EACtB,WAAmB;QADnB,mBAAc,GAAd,cAAc,CAAQ;QACtB,gBAAW,GAAX,WAAW,CAAQ;IAC1B,CAAC;IACJ,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,GAAQ;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,OAAO,EAAE;YACzC,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAA;YACtE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,CAAA;SACvD;QACD,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;gBAC1B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,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,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAEQ,4CAAgB","sourcesContent":["/* eslint-disable no-console */\nimport FormData from 'form-data'\nimport { createReadStream, existsSync, write, writeFileSync } from 'fs'\nimport fs from 'fs/promises'\nimport pLimit from 'p-limit'\n\nimport { JsonReport, JsonTestProgress } from './report_generator'\nimport { axiosClient } from '../../configuration/axios_client'\nimport path from 'path'\nimport {\n createNewTestCase,\n logReportLink,\n postUploadReportEvent,\n} from '../bvt_analysis_formatter'\nimport { ActionEvents, SERVICES_URI } from './constants'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport interface RootCauseProps {\n status: boolean\n analysis: string\n failedStep: number\n failClass: string\n}\n\nexport interface FinishTestCaseResponse {\n status: true\n rootCause: RootCauseProps\n report: JsonTestProgress\n}\n\nclass RunUploadService {\n constructor(\n private runsApiBaseURL: string,\n private accessToken: string\n ) {}\n async createRunDocument(name: string, env: any) {\n if (process.env.UPLOADREPORTS === 'false') {\n console.log('Skipping report upload as UPLOADREPORTS is set to false')\n return { id: 'local-run', projectId: 'local-project' }\n }\n try {\n const runDocResult = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/create',\n {\n name: name ? name : 'TEST',\n branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : 'main',\n video_id: process.env.VIDEO_ID,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n env: { name: env?.name, baseUrl: env?.baseUrl },\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (runDocResult.status !== 200) {\n throw new Error('Failed to create run document in the server')\n }\n if (runDocResult.data.status !== true) {\n throw new Error('Failed to create run document in the server')\n }\n return runDocResult.data.run\n } catch (error) {\n if (error.response && error.response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot create or upload reports.'\n )\n process.exit(1)\n }\n throw new Error('Failed to create run document in the server: ' + error)\n }\n }\n async updateProjectAnalytics(projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/project/updateAIRecoveryCount',\n {\n projectId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.error('Failed to update project metadata:', error)\n }\n }\n async upload(formData: FormData) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/upload',\n formData,\n {\n headers: {\n ...formData.getHeaders(),\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 401) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to upload run to the server')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to upload run to the server')\n }\n }\n async getPreSignedUrls(fileUris: string[], runId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return {}\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/generateuploadurls',\n {\n fileUris,\n runId,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status === 403) {\n console.log(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n throw new Error(\n 'Warning: Your trial plan has ended. Cannot upload reports and perform retraining'\n )\n }\n if (response.status !== 200) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to get pre-signed urls for the files')\n }\n\n return response.data.uploadUrls\n }\n\n async uploadTestCase(\n testCaseReport: JsonTestProgress,\n runId: string,\n projectId: string,\n reportFolder: string,\n rerunId?: string\n ) {\n if (process.env.UPLOADREPORTS === 'false') return null\n\n const fileUris: string[] = []\n\n // Collect screenshot + trace + logs\n for (const step of testCaseReport.steps) {\n for (const command of step.commands) {\n if (command.screenshotId)\n fileUris.push(`screenshots/${command.screenshotId}.png`)\n }\n if (step.traceFilePath) fileUris.push(`trace/${step.traceFilePath}`)\n }\n if (testCaseReport.logFileId)\n fileUris.push(`editorLogs/testCaseLog_${testCaseReport.logFileId}.log`)\n if (testCaseReport.traceFileId)\n fileUris.push(`trace/${testCaseReport.traceFileId}`)\n\n // 🔹 UPLOAD FILES\n try {\n const preSignedUrls = await this.getPreSignedUrls(fileUris, runId)\n await this.uploadFilesInBatches(fileUris, reportFolder, preSignedUrls)\n } catch (error: any) {\n console.error('🟥 Error uploading files:', {\n message: error?.message,\n stack: error?.stack,\n })\n }\n\n // 🔹 UPLOAD FINAL TEST REPORT\n try {\n const mode =\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local'\n let rerunIdFinal = process.env.RETRY_ID || null\n if (rerunId)\n rerunIdFinal = rerunId.includes(runId) ? rerunId : `${runId}${rerunId}`\n if (mode === 'executions')\n testCaseReport.id = process.env.VIDEO_ID || testCaseReport.id\n\n const payload = {\n runId,\n projectId,\n testProgressReport: testCaseReport,\n browser: process.env.BROWSER || 'chromium',\n mode,\n rerunId: rerunIdFinal,\n video_id: process.env.VIDEO_ID,\n }\n\n const data = await createNewTestCase(\n payload,\n this.runsApiBaseURL,\n this.accessToken\n )\n await postUploadReportEvent(projectId, this.accessToken)\n logReportLink(runId, projectId, testCaseReport.result)\n return data\n } catch (e: any) {\n console.error('🟥 Failed to upload test case:', {\n testCaseId: testCaseReport.id,\n message: e?.message,\n status: e?.response?.status,\n responseSnippet: e?.response?.data?.toString()?.slice(0, 300),\n stack: e?.stack,\n })\n return null\n }\n }\n\n /**\n * Improving error logging\n * 🔧 Sanitizes Axios errors to avoid dumping Cloudflare HTML (524, 502, etc.)\n */\n private sanitizeError(error: any) {\n // Handle Axios-style errors with response\n if (error?.response) {\n const { data, status } = error.response\n\n // If Cloudflare or HTML error page → return a short meaningful message\n if (typeof data === 'string' && data.includes('<!DOCTYPE html')) {\n return `[HTML_ERROR_PAGE] status=${status} - likely Cloudflare timeout or proxy error`\n }\n\n // If data is a JSON object, stringify it with indentation for readability\n if (typeof data === 'object') {\n return JSON.stringify(data, null, 2) // Pretty-print the JSON response\n }\n\n // If response is a string (could be an error message), return it trimmed\n return data?.trim() || `Unknown response data (status: ${status})`\n }\n\n // System / network errors (e.g., if Axios cannot reach the server)\n if (error?.message) {\n return error.message\n }\n\n // If the error has a stack (for debugging purposes)\n if (error?.stack) {\n return `${error.message}\\n${error.stack}`\n }\n\n // If it's a generic error object, attempt to stringify it in a readable format\n return JSON.stringify(\n error,\n (key, value) => {\n // Avoid circular references or sensitive data\n if (key === 'password' || key === 'accessToken') return '[REDACTED]'\n return value\n },\n 2\n ) // Pretty-print the error object with indentation\n }\n async uploadFileWithRetries(filePath: string, presignedUrl: string) {\n const MAX_RETRIES = 3\n const RETRY_DELAY_MS = 1000\n for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n try {\n const ok = await this.uploadFile(filePath, presignedUrl)\n if (ok) return true\n } catch (err: any) {\n console.error(`Upload attempt #${attempt} failed for ${filePath}:`, {\n message: err?.message,\n stack: err?.stack,\n })\n if (attempt < MAX_RETRIES) {\n await new Promise((r) => setTimeout(r, RETRY_DELAY_MS * attempt))\n }\n }\n }\n console.error(\n `Failed to upload file after ${MAX_RETRIES} retries: ${filePath}`\n )\n return false\n }\n\n async uploadFilesInBatches(\n fileUris: string[],\n reportFolder: string,\n preSignedUrls: Record<string, string>\n ) {\n const MAX_CONCURRENCY = 5\n const limit = pLimit(MAX_CONCURRENCY)\n const tasks = fileUris\n .filter((uri) => preSignedUrls[uri])\n .map((uri) =>\n limit(async () => {\n const filePath = path.join(reportFolder, uri)\n if (existsSync(filePath)) {\n await this.uploadFileWithRetries(filePath, preSignedUrls[uri])\n }\n })\n )\n\n await Promise.all(tasks)\n }\n\n async uploadFile(filePath: string, preSignedUrl: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return true\n }\n const fileStream = createReadStream(filePath)\n let success = true\n try {\n const fileStats = await fs.stat(filePath)\n const fileSize = fileStats.size\n\n await axiosClient.put(preSignedUrl, fileStream, {\n headers: {\n 'Content-Type': 'application/octet-stream',\n 'Content-Length': fileSize,\n },\n })\n } catch (error) {\n if (process.env.MODE === 'executions') {\n const sanitized = this.sanitizeError(error)\n console.error(\n '❌ Error uploading file at:',\n filePath,\n 'due to',\n sanitized\n )\n }\n success = false\n } finally {\n fileStream.close()\n }\n return success\n }\n async uploadComplete(runId: string, projectId: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadCompletion',\n {\n runId,\n projectId,\n browser: process.env.BROWSER ? process.env.BROWSER : 'chromium',\n mode:\n process.env.MODE === 'cloud'\n ? 'cloud'\n : process.env.MODE === 'executions'\n ? 'executions'\n : 'local',\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (response.status !== 200) {\n throw new Error('Failed to mark run as complete')\n }\n if (response.data.status !== true) {\n throw new Error('Failed to mark run as complete')\n }\n\n try {\n await axiosClient.post(\n `${SERVICES_URI.STORAGE}/event`,\n {\n event: ActionEvents.upload_report,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n 'x-bvt-project-id': projectId,\n },\n }\n )\n } catch (error) {\n // no event tracking\n }\n }\n async modifyTestCase(\n runId: string,\n projectId: string,\n testProgressReport: JsonTestProgress\n ) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n try {\n const res = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/modifyTestCase',\n {\n runId,\n projectId,\n testProgressReport,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n if (res.status !== 200) {\n throw new Error('')\n }\n if (res.data.status !== true) {\n throw new Error('')\n }\n logReportLink(runId, projectId, testProgressReport.result)\n } catch (e) {\n console.error(\n `failed to modify the test case: ${testProgressReport.id} ${e}`\n )\n }\n }\n async createStatus(status: string) {\n if (process.env.UPLOADREPORTS === 'false') {\n return\n }\n if (!process.env.UUID) {\n return\n }\n\n try {\n await axiosClient.post(\n this.runsApiBaseURL + '/scenarios/status',\n {\n status: { status },\n uuid: process.env.UUID,\n },\n {\n headers: {\n Authorization: 'Bearer ' + this.accessToken,\n 'x-source': 'cucumber_js',\n },\n }\n )\n } catch (error) {\n console.log('Failed to send status to the server, ignoring it')\n }\n }\n}\n\nexport { RunUploadService }\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.0.209-dev";
|
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.209-dev'\n"]}
|