@dev-blinq/cucumber-js 1.0.61 → 1.0.62

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.
@@ -4,6 +4,8 @@ const path = require('path')
4
4
  const JSZip = require('jszip')
5
5
  const { mkdirSync, writeFileSync } = require('node:fs')
6
6
  const axios = require('axios').default
7
+ const tunnel = require('tunnel');
8
+
7
9
  let token = null
8
10
  let extractPath = null
9
11
  const getSSoUrl = () => {
@@ -85,6 +87,8 @@ const downloadAndInstall = async (extractPath, token) => {
85
87
  const accessKeyUrl = `${ssoUrl}/getProjectByAccessKey`
86
88
  const response = await axios.post(accessKeyUrl, {
87
89
  access_key: token,
90
+ httpAgent: getProxy(),
91
+ proxy: false,
88
92
  })
89
93
  if(response.status !== 200){
90
94
  console.error('Error: Invalid access key')
@@ -92,11 +96,12 @@ const downloadAndInstall = async (extractPath, token) => {
92
96
  }
93
97
 
94
98
  const workspaceUrl = getWorkSpaceUrl() + '/pull-workspace'
95
-
96
99
  const res = await axios.get(workspaceUrl, {
97
100
  params: {
98
101
  projectId: response.data.project._id,
99
102
  },
103
+ httpAgent: getProxy(),
104
+ proxy: false,
100
105
  responseType: 'arraybuffer',
101
106
  headers: {
102
107
  Authorization: `Bearer ${token}`,
@@ -124,3 +129,23 @@ const downloadAndInstall = async (extractPath, token) => {
124
129
  downloadAndInstall(extractPath, token).then(() =>
125
130
  console.log('Download completed!')
126
131
  )
132
+
133
+ const getProxy = () => {
134
+ if (!process.env.PROXY) {
135
+ return null
136
+ }
137
+
138
+ const proxy = process.env.PROXY
139
+ const url = new URL(proxy)
140
+ const proxyObject = {
141
+ host: url.hostname,
142
+ port: Number(url.port),
143
+ }
144
+
145
+ const { username, password } = url
146
+
147
+ if (username && password) {
148
+ proxyObject.proxyAuth = `${username}:${password}`
149
+ }
150
+ return tunnel.httpsOverHttp({ proxy: proxyObject })
151
+ }
@@ -0,0 +1 @@
1
+ export declare const axiosClient: import("axios").AxiosInstance;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.axiosClient = void 0;
7
+ /* eslint-disable no-console */
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const tunnel_1 = __importDefault(require("tunnel"));
10
+ const getProxy = () => {
11
+ if (!process.env.PROXY) {
12
+ return null;
13
+ }
14
+ const proxy = process.env.PROXY;
15
+ const url = new URL(proxy);
16
+ const proxyObject = {
17
+ host: url.hostname,
18
+ port: Number(url.port),
19
+ };
20
+ const { username, password } = url;
21
+ if (username && password) {
22
+ proxyObject.proxyAuth = `${username}:${password}`;
23
+ }
24
+ return tunnel_1.default.httpsOverHttp({ proxy: proxyObject });
25
+ };
26
+ const createAxiosClient = () => {
27
+ try {
28
+ const agent = getProxy();
29
+ return axios_1.default.create({
30
+ httpAgent: agent,
31
+ proxy: false,
32
+ });
33
+ }
34
+ catch (error) {
35
+ console.log(error.message);
36
+ throw new Error(`Error creating axios client ${error instanceof Error ? error.message : error.response.data}`);
37
+ }
38
+ };
39
+ exports.axiosClient = createAxiosClient();
40
+ //# sourceMappingURL=axios_client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios_client.js","sourceRoot":"","sources":["../../src/configuration/axios_client.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kDAAyB;AACzB,oDAA6C;AAG7C,MAAM,QAAQ,GAAG,GAAiB,EAAE;IAClC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,KAAK,GAAkB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,MAAM,WAAW,GAAiB;QAChC,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;KACvB,CAAA;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAElC,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,WAAW,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAA;KAClD;IACD,OAAO,gBAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,IAAI;QACF,MAAM,KAAK,GAAmB,QAAQ,EAAE,CAAA;QACxC,OAAO,eAAK,CAAC,MAAM,CAAC;YAClB,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK;SACb,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,MAAM,IAAI,KAAK,CACb,+BACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAC1D,EAAE,CACH,CAAA;KACF;AACH,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,iBAAiB,EAAE,CAAA","sourcesContent":["/* eslint-disable no-console */\nimport axios from 'axios'\nimport tunnel, { ProxyOptions } from 'tunnel'\nimport { Agent } from 'http'\n\nconst getProxy = (): Agent | null => {\n if (!process.env.PROXY) {\n return null\n }\n\n const proxy: string | null = process.env.PROXY\n const url = new URL(proxy)\n const proxyObject: ProxyOptions = {\n host: url.hostname,\n port: Number(url.port),\n }\n\n const { username, password } = url\n\n if (username && password) {\n proxyObject.proxyAuth = `${username}:${password}`\n }\n return tunnel.httpsOverHttp({ proxy: proxyObject })\n}\n\nconst createAxiosClient = () => {\n try {\n const agent: string | Agent = getProxy()\n return axios.create({\n httpAgent: agent,\n proxy: false,\n })\n } catch (error) {\n console.log(error.message)\n throw new Error(\n `Error creating axios client ${\n error instanceof Error ? error.message : error.response.data\n }`\n )\n }\n}\n\nexport const axiosClient = createAxiosClient()\n"]}
@@ -55,7 +55,6 @@ export type JsonStep = {
55
55
  text: string;
56
56
  commands: JsonCommand[];
57
57
  result: JsonStepResult;
58
- data?: any;
59
58
  };
60
59
  export type RetrainStats = {
61
60
  result: JsonTestResult;
@@ -72,7 +71,6 @@ export type JsonTestProgress = {
72
71
  steps: JsonStep[];
73
72
  result: JsonTestResult;
74
73
  retrainStats?: RetrainStats;
75
- webLog: any;
76
74
  };
77
75
  export type JsonReport = {
78
76
  testCases: JsonTestProgress[];
@@ -103,7 +101,6 @@ export default class ReportGenerator {
103
101
  private onTestStepStarted;
104
102
  private onAttachment;
105
103
  private onTestStepFinished;
106
- getLogFileContent(): any;
107
104
  private getTestCaseResult;
108
105
  private onTestCaseFinished;
109
106
  private onTestRunFinished;
@@ -1,10 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const path_1 = __importDefault(require("path"));
8
3
  class ReportGenerator {
9
4
  constructor() {
10
5
  this.report = {
@@ -228,7 +223,6 @@ class ReportGenerator {
228
223
  status: 'STARTED',
229
224
  startTime: this.getTimeStamp(timestamp),
230
225
  },
231
- webLog: [],
232
226
  });
233
227
  this.report.testCases.push(this.testCaseReportMap.get(id));
234
228
  }
@@ -266,15 +260,6 @@ class ReportGenerator {
266
260
  return;
267
261
  const stepProgess = this.stepReportMap.get(testStep.pickleStepId);
268
262
  const prevStepResult = stepProgess.result;
269
- let data = {};
270
- if (fs_1.default.existsSync(path_1.default.join(this.reportFolder, 'data.json'))) {
271
- try {
272
- data = JSON.parse(fs_1.default.readFileSync(path_1.default.join(this.reportFolder, 'data.json'), 'utf8'));
273
- }
274
- catch (error) {
275
- console.log('Error reading data.json');
276
- }
277
- }
278
263
  stepProgess.result = {
279
264
  status: testStepResult.status,
280
265
  startTime: prevStepResult.startTime,
@@ -282,33 +267,6 @@ class ReportGenerator {
282
267
  message: testStepResult.message,
283
268
  // exception: testStepResult.exception,
284
269
  };
285
- if (Object.keys(data).length > 0) {
286
- stepProgess.data = data;
287
- }
288
- }
289
- getLogFileContent() {
290
- let projectPath = process.cwd();
291
- if (process.env.PROJECT_PATH) {
292
- projectPath = process.env.PROJECT_PATH;
293
- }
294
- const logFolder = path_1.default.join(projectPath, 'logs', 'web');
295
- if (!fs_1.default.existsSync(logFolder)) {
296
- return [];
297
- }
298
- let nextId = 1;
299
- while (fs_1.default.existsSync(path_1.default.join(logFolder, `${nextId}.json`))) {
300
- nextId++;
301
- }
302
- if (nextId === 1) {
303
- return [];
304
- }
305
- try {
306
- const logFileContent = fs_1.default.readFileSync(path_1.default.join(logFolder, `${nextId - 1}.json`), 'utf8');
307
- return JSON.parse(logFileContent);
308
- }
309
- catch (error) {
310
- return [];
311
- }
312
270
  }
313
271
  getTestCaseResult(steps) {
314
272
  for (const step of steps) {
@@ -343,7 +301,6 @@ class ReportGenerator {
343
301
  startTime: prevResult.startTime,
344
302
  endTime: this.getTimeStamp(timestamp),
345
303
  };
346
- testProgress.webLog = this.getLogFileContent();
347
304
  }
348
305
  onTestRunFinished(testRunFinished) {
349
306
  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;AAqGvB,MAAqB,eAAe;IAApC;QACU,WAAM,GAAe;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;aAClB;YACD,SAAS,EAAE,EAAwB;SACpC,CAAA;QACO,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAA;QAChE,YAAO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CAAA;QACzD,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;QAClE,MAAM,UAAU,GAAG,YAAY,CAAC,MAG/B,CAAA;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;QAC5C,YAAY,CAAC,MAAM,GAAG;YACpB,GAAG,MAAM;YACT,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;SACtC,CAAA;QACD,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;IAChD,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;AA9WD,kCA8WC","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}\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}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n}\n\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\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 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 })\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 }\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) return\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 if (fs.existsSync(path.join(this.reportFolder, 'data.json'))) {\n try {\n data = JSON.parse(\n fs.readFileSync(path.join(this.reportFolder, 'data.json'), 'utf8')\n )\n } catch (error) {\n console.log('Error reading data.json')\n }\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.getLogFileContent()\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":";;AAmGA,MAAqB,eAAe;IAApC;QACU,WAAM,GAAe;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,SAAS;aAClB;YACD,SAAS,EAAE,EAAwB;SACpC,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,GAA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AAC,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;AArUD,kCAqUC","sourcesContent":["import * as messages from '@cucumber/messages'\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}\nexport type JsonStep = {\n keyword: string\n type: JsonStepType\n text: string\n commands: JsonCommand[]\n result: JsonStepResult\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}\n\nexport type JsonReport = {\n testCases: JsonTestProgress[]\n result: JsonReportResult\n}\n\nexport default class ReportGenerator {\n private report: JsonReport = {\n result: {\n status: 'UNKNOWN',\n },\n testCases: [] as JsonTestProgress[],\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 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 })\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 }\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) return\n const stepProgess = this.stepReportMap.get(testStep.pickleStepId)\n const prevStepResult = stepProgess.result as {\n status: 'STARTED'\n startTime: JsonTimestamp\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 }\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 }\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"]}
@@ -7,7 +7,7 @@ declare class RunUploadService {
7
7
  createRunDocument(name: string): Promise<any>;
8
8
  upload(formData: FormData): Promise<void>;
9
9
  getPreSignedUrls(fileUris: string[], runId: string): Promise<any>;
10
- uploadFile(filePath: string, preSignedUrl: string): Promise<boolean>;
10
+ uploadFile(filePath: string, preSignedUrl: string): Promise<void>;
11
11
  uploadComplete(runId: string, report: JsonReport): Promise<void>;
12
12
  }
13
13
  export { RunUploadService };
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RunUploadService = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
7
  const fs_1 = require("fs");
9
8
  const promises_1 = __importDefault(require("fs/promises"));
9
+ const axios_client_1 = require("../../configuration/axios_client");
10
10
  class RunUploadService {
11
11
  constructor(runsApiBaseURL, accessToken) {
12
12
  this.runsApiBaseURL = runsApiBaseURL;
13
13
  this.accessToken = accessToken;
14
14
  }
15
15
  async createRunDocument(name) {
16
- const runDocResult = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/create', {
16
+ const runDocResult = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/create', {
17
17
  name: name ? name : 'TEST',
18
18
  }, {
19
19
  headers: {
@@ -30,7 +30,7 @@ class RunUploadService {
30
30
  return runDocResult.data.run;
31
31
  }
32
32
  async upload(formData) {
33
- const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/upload', formData, {
33
+ const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/upload', formData, {
34
34
  headers: {
35
35
  ...formData.getHeaders(),
36
36
  Authorization: 'Bearer ' + this.accessToken,
@@ -45,7 +45,7 @@ class RunUploadService {
45
45
  }
46
46
  }
47
47
  async getPreSignedUrls(fileUris, runId) {
48
- const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/generateuploadurls', {
48
+ const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/generateuploadurls', {
49
49
  fileUris,
50
50
  runId,
51
51
  }, {
@@ -64,30 +64,26 @@ class RunUploadService {
64
64
  }
65
65
  async uploadFile(filePath, preSignedUrl) {
66
66
  const fileStream = (0, fs_1.createReadStream)(filePath);
67
- let success = true;
68
67
  try {
69
68
  const fileStats = await promises_1.default.stat(filePath);
70
69
  const fileSize = fileStats.size;
71
- await axios_1.default.put(preSignedUrl, fileStream, {
70
+ await axios_client_1.axiosClient.put(preSignedUrl, fileStream, {
72
71
  headers: {
73
72
  'Content-Type': 'application/octet-stream',
74
73
  'Content-Length': fileSize,
75
74
  },
76
75
  });
76
+ console.log('Uploaded successfully:\n', filePath);
77
77
  }
78
78
  catch (error) {
79
- if (process.env.NODE_ENV_BLINQ === 'dev') {
80
- console.error('Error uploading file:', error);
81
- }
82
- success = false;
79
+ console.error('Error uploading file:', error);
83
80
  }
84
81
  finally {
85
82
  fileStream.close();
86
83
  }
87
- return success;
88
84
  }
89
85
  async uploadComplete(runId, report) {
90
- const response = await axios_1.default.post(this.runsApiBaseURL + '/cucumber-runs/uploadcomplete', {
86
+ const response = await axios_client_1.axiosClient.post(this.runsApiBaseURL + '/cucumber-runs/uploadcomplete', {
91
87
  runId,
92
88
  report,
93
89
  }, {
@@ -1 +1 @@
1
- {"version":3,"file":"upload_serivce.js","sourceRoot":"","sources":["../../../src/formatter/helpers/upload_serivce.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAEzB,2BAAqC;AACrC,2DAA4B;AAE5B,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,MAAM,YAAY,GAAG,MAAM,eAAK,CAAC,IAAI,CACnC,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;YACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;SAC3B,EACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAE,aAAa;aAC1B;SACF,CACF,CAAA;QACD,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;QACD,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;QACD,OAAO,YAAY,CAAC,IAAI,CA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nimport fs from 'fs/promises'\nimport { JsonReport } from './report_generator'\nclass RunUploadService {\n constructor(private runsApiBaseURL: string, private accessToken: string) {}\n async createRunDocument(name: string) {\n const runDocResult = await axios.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 }\n async upload(formData: FormData) {\n const response = await axios.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 !== 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 axios.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 !== 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 axios.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, report: JsonReport) {\n const response = await axios.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadcomplete',\n {\n runId,\n report,\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,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,MAAM,YAAY,GAAG,MAAM,0BAAW,CAAC,IAAI,CACzC,IAAI,CAAC,cAAc,GAAG,uBAAuB,EAC7C;YACE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;SAC3B,EACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,WAAW;gBAC3C,UAAU,EAAE,aAAa;aAC1B;SACF,CACF,CAAA;QACD,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;QACD,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;SAC/D;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAA;IAC9B,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,QAAkB;QAC7B,MAAM,QAAQ,GAAG,MAAM,0BAAW,CAAC,IAAI,CACrC,IAA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AAG,SAAS,CAAC,IAAI,CAAA;YAE/B,MAAM,0BAAW,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE;gBAC9C,OAAO,EAAE;oBACP,cAAc,EAAE,0BAA0B;oBAC1C,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC,CAAA;YACF,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA;SAClD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;SAC9C;gBAAS;YACR,UAAU,CAAC,KAAK,EAAE,CAAA;SACnB;IACH,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,KAAa,EAAE,MAAkB;QACpD,MAAM,QAAQ,GAAG,MAAM,0BAAW,CAAC,IAAI,CACrC,IAAI,CAAC,cAAc,GAAG,+BAA+B,EACrD;YACE,KAAK;YACL,MAAM;SACP,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 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 }\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 !== 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 !== 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\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 console.log('Uploaded successfully:\\n', filePath)\n } catch (error) {\n console.error('Error uploading file:', error)\n } finally {\n fileStream.close()\n }\n }\n async uploadComplete(runId: string, report: JsonReport) {\n const response = await axiosClient.post(\n this.runsApiBaseURL + '/cucumber-runs/uploadcomplete',\n {\n runId,\n report,\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"]}
@@ -15,8 +15,6 @@ const URL = process.env.NODE_ENV_BLINQ === 'dev'
15
15
  ? 'http://localhost:5001/api/runs'
16
16
  : 'https://api.blinq.io/api/runs';
17
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
18
  const REPORT_SERVICE_TOKEN = (_b = process.env.TOKEN) !== null && _b !== void 0 ? _b : process.env.REPORT_SERVICE_TOKEN;
21
19
  class ReportUploader {
22
20
  constructor(reportGenerator) {
@@ -43,20 +41,11 @@ class ReportUploader {
43
41
  const fileUris = getFileUrisScreenShotDir(reportFolder);
44
42
  try {
45
43
  const preSignedUrls = await this.uploadService.getPreSignedUrls(fileUris, runDocId);
46
- for (let i = 0; i < fileUris.length; i += BATCH_SIZE) {
47
- const batch = fileUris.slice(i, Math.min(i + BATCH_SIZE, fileUris.length));
48
- await Promise.all(batch
49
- .filter((fileUri) => preSignedUrls[fileUri])
50
- .map(async (fileUri) => {
51
- for (let j = 0; j < MAX_RETRIES; j++) {
52
- const success = await this.uploadService.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
53
- if (success) {
54
- return;
55
- }
56
- }
57
- console.error('Failed to upload file:', fileUri);
58
- }));
59
- }
44
+ await Promise.all(fileUris
45
+ .filter((fileUri) => preSignedUrls[fileUri])
46
+ .map((fileUri) => {
47
+ return this.uploadService.uploadFile(path_1.default.join(reportFolder, fileUri), preSignedUrls[fileUri]);
48
+ }));
60
49
  await this.uploadService.uploadComplete(runDocId, report);
61
50
  }
62
51
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/formatter/helpers/uploader.ts"],"names":[],"mappings":";;;;;;AACA,qDAAmD;AAEnD,0DAAgC;AAChC,4CAAmB;AACnB,kDAAyB;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E,aAAa,CAAC,EACtC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAChC,CAAA;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAlFD,iCAkFC;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 from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : 'https://api.blinq.io/api/runs'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\nconst BATCH_SIZE = 10\nconst MAX_RETRIES = 3\nconst REPORT_SERVICE_TOKEN =\n process.env.TOKEN ?? process.env.REPORT_SERVICE_TOKEN\n\nexport default class ReportUploader {\n private uploadService = new RunUploadService(\n REPORT_SERVICE_URL,\n REPORT_SERVICE_TOKEN\n )\n private reportGenerator: ReportGenerator\n constructor(reportGenerator: ReportGenerator) {\n if (!REPORT_SERVICE_URL || !REPORT_SERVICE_TOKEN) {\n throw new Error('REPORT_SERVICE_URL and REPORT_SERVICE_TOKEN must be set')\n }\n this.reportGenerator = reportGenerator\n }\n\n async uploadRun(report: JsonReport, runName: string) {\n const runDoc = await this.uploadService.createRunDocument(runName)\n const runDocId = runDoc._id\n const reportFolder = this.reportGenerator.reportFolder\n if (!fs.existsSync(reportFolder)) {\n fs.mkdirSync(reportFolder)\n }\n 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 = getFileUrisScreenShotDir(reportFolder)\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, report)\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 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,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AAG,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 from 'fs'\nimport JSZip from 'jszip'\nimport path from 'path'\nconst URL =\n process.env.NODE_ENV_BLINQ === 'dev'\n ? 'https://dev.api.blinq.io/api/runs'\n : process.env.NODE_ENV_BLINQ === 'local'\n ? 'http://localhost:5001/api/runs'\n : 'https://api.blinq.io/api/runs'\n\nconst REPORT_SERVICE_URL = process.env.REPORT_SERVICE_URL ?? URL\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 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 = getFileUrisScreenShotDir(reportFolder)\n try {\n const preSignedUrls = await this.uploadService.getPreSignedUrls(\n fileUris,\n runDocId\n )\n await Promise.all(\n fileUris\n .filter((fileUri) => preSignedUrls[fileUri])\n .map((fileUri) => {\n return this.uploadService.uploadFile(\n path.join(reportFolder, fileUri),\n preSignedUrls[fileUri]\n )\n })\n )\n await this.uploadService.uploadComplete(runDocId, report)\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 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"]}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.0.61";
1
+ export declare const version = "1.0.62";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '1.0.61';
5
+ exports.version = '1.0.62';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.61'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '1.0.62'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "1.0.61",
11
+ "version": "1.0.62",
12
12
  "homepage": "https://github.com/blinq-io/cucumber-js",
13
13
  "author": "blinq.io",
14
14
  "contributors": [
@@ -60,6 +60,7 @@
60
60
  "@cucumber/messages": "22.0.0",
61
61
  "@cucumber/tag-expressions": "5.0.1",
62
62
  "@faker-js/faker": "^8.0.2",
63
+ "@types/tunnel": "^0.0.7",
63
64
  "assertion-error-formatter": "^3.0.0",
64
65
  "axios": "^1.6.2",
65
66
  "capital-case": "^1.0.4",
@@ -89,6 +90,7 @@
89
90
  "supports-color": "^8.1.1",
90
91
  "tmp": "^0.2.1",
91
92
  "tmp-promise": "^3.0.3",
93
+ "tunnel": "^0.0.6",
92
94
  "util-arity": "^1.1.0",
93
95
  "verror": "^1.10.0",
94
96
  "xmlbuilder": "^15.1.1",