@dev-blinq/cucumber_client 1.0.1319-dev → 1.0.1321-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.
@@ -731,9 +731,9 @@ const generateCode = (recording, codePage, userData, projectDir, methodName) =>
731
731
  return;
732
732
  }
733
733
 
734
- if (process.env.TEMP_RUN === "true") {
735
- codeLines.push(...generateReportCommand("start", recordingStep.cmdId));
736
- }
734
+ // if (process.env.TEMP_RUN === "true") {
735
+ // codeLines.push(...generateReportCommand("start", recordingStep.cmdId));
736
+ // }
737
737
  const result = _generateCodeFromCommand(recordingStep, elements, userData);
738
738
  if (process.env.TEMP_RUN) {
739
739
  // Add try catch block to the generated code, should attach commandId to world object
@@ -743,9 +743,9 @@ const generateCode = (recording, codePage, userData, projectDir, methodName) =>
743
743
  );
744
744
  }
745
745
  codeLines.push(...result.codeLines);
746
- if (process.env.TEMP_RUN === "true") {
747
- codeLines.push(...generateReportCommand("end", recordingStep.cmdId));
748
- }
746
+ // if (process.env.TEMP_RUN === "true") {
747
+ // codeLines.push(...generateReportCommand("end", recordingStep.cmdId));
748
+ // }
749
749
  if (result.elements) {
750
750
  elements = result.elements;
751
751
  }
@@ -190,16 +190,16 @@ export class BVTRecorder {
190
190
  if (data && data.type) {
191
191
  switch (data.type) {
192
192
  case "cmdExecutionStart":
193
- console.log("Sending cmdExecutionStart event for cmdId:", data.cmdId);
194
- this.sendEvent(this.events.cmdExecutionStart, data.cmdId);
193
+ console.log("Sending cmdExecutionStart event for cmdId:", data);
194
+ this.sendEvent(this.events.cmdExecutionStart, data);
195
195
  break;
196
196
  case "cmdExecutionSuccess":
197
- console.log("Sending cmdExecutionSuccess event for cmdId:", data.cmdId);
198
- this.sendEvent(this.events.cmdExecutionSuccess, data.cmdId);
197
+ console.log("Sending cmdExecutionSuccess event for cmdId:", data);
198
+ this.sendEvent(this.events.cmdExecutionSuccess, data);
199
199
  break;
200
200
  case "cmdExecutionFailure":
201
- console.log("Sending cmdExecutionFailure event for cmdId:", data.cmdId);
202
- this.sendEvent(this.events.cmdExecutionFailure, data.cmdId);
201
+ console.log("Sending cmdExecutionFailure event for cmdId:", data);
202
+ this.sendEvent(this.events.cmdExecutionFailure, data);
203
203
  break;
204
204
  default:
205
205
  console.warn("Unknown command execution status type:", data.type);
@@ -211,7 +211,7 @@ export class BVTRecorder {
211
211
  this.pageSet = new Set();
212
212
  this.lastKnownUrlPath = "";
213
213
  // TODO: what is world?
214
- this.world = { attach: () => {} };
214
+ this.world = { attach: () => { } };
215
215
  this.shouldTakeScreenshot = true;
216
216
  this.watcher = null;
217
217
  }
@@ -319,7 +319,7 @@ export class BVTRecorder {
319
319
  process.env.CDP_LISTEN_PORT = this.#remoteDebuggerPort;
320
320
 
321
321
  this.stepRunner.setRemoteDebugPort(this.#remoteDebuggerPort);
322
- this.world = { attach: () => {} };
322
+ this.world = { attach: () => { } };
323
323
 
324
324
  const ai_config_file = path.join(this.projectDir, "ai_config.json");
325
325
  let ai_config = {};
@@ -725,7 +725,7 @@ export class BVTRecorder {
725
725
  }
726
726
  async closeBrowser() {
727
727
  delete process.env.TEMP_RUN;
728
- await this.watcher.close().then(() => {});
728
+ await this.watcher.close().then(() => { });
729
729
  this.watcher = null;
730
730
  this.previousIndex = null;
731
731
  this.previousHistoryLength = null;
@@ -132,7 +132,7 @@ export class BVTStepRunner {
132
132
  }
133
133
  if (testStepResult.status === "UNDEFINED") {
134
134
  if (!errorMesssage) {
135
- errorMesssage = `step ${JSON.stringify(stepText)} is ${testStepResult.status}`;
135
+ errorMesssage = stepText ? `step ${JSON.stringify(stepText)} is ${testStepResult.status}` : testStepResult.message;
136
136
  if (info) {
137
137
  errInfo = info;
138
138
  }
@@ -144,33 +144,46 @@ export class BVTStepRunner {
144
144
  if (attachment.mediaType === "application/json" && attachment.body) {
145
145
  const body = JSON.parse(attachment.body);
146
146
  info = body.info;
147
+ const result = body.result;
147
148
 
148
- if (body && body.payload) {
149
- const payload = body.payload;
150
- const content = payload.content;
151
- const type = payload.type;
152
- if (type === "cmdReport") {
153
- if (content) {
154
- const report = JSON.parse(content);
155
- switch (report.status) {
156
- case "start":
157
- this.sendExecutionStatus({
158
- type: "cmdExecutionStart",
159
- cmdId: report.cmdId,
160
- });
161
- break;
162
- case "end":
163
- this.sendExecutionStatus({
164
- type: "cmdExecutionSuccess",
165
- cmdId: report.cmdId,
166
- });
167
- break;
168
- default:
169
- console.warn("Unknown command report status:", report.status);
170
- }
171
- }
172
- }
149
+ if (result.status === "PASSED") {
150
+ this.sendExecutionStatus({
151
+ type: "cmdExecutionSuccess",
152
+ cmdId: body.cmdId,
153
+ });
154
+ } else {
155
+ this.sendExecutionStatus({
156
+ type: "cmdExecutionError",
157
+ cmdId: body.cmdId,
158
+ error: result.error,
159
+ });
173
160
  }
161
+ // if (body && body.payload) {
162
+ // const payload = body.payload;
163
+ // const content = payload.content;
164
+ // const type = payload.type;
165
+ // if (type === "cmdReport") {
166
+ // if (content) {
167
+ // const report = JSON.parse(content);
168
+ // switch (report.status) {
169
+ // case "start":
170
+ // this.sendExecutionStatus({
171
+ // type: "cmdExecutionStart",
172
+ // cmdId: report.cmdId,
173
+ // });
174
+ // break;
175
+ // case "end":
176
+ // this.sendExecutionStatus({
177
+ // type: "cmdExecutionSuccess",
178
+ // cmdId: report.cmdId,
179
+ // });
180
+ // break;
181
+ // default:
182
+ // console.warn("Unknown command report status:", report.status);
183
+ // }
184
+ // }
185
+ // }
186
+ // }
174
187
  }
175
188
  }
176
189
  });
@@ -191,6 +204,20 @@ export class BVTStepRunner {
191
204
  };
192
205
 
193
206
  async runStep({ step, parametersMap, envPath, tags }, bvtContext, options) {
207
+ let cmdIDs = (step.commands || []).map((cmd) => cmd.cmdId);
208
+ if (bvtContext.web) {
209
+ bvtContext.web.getCmdId = () => {
210
+ if (cmdIDs.length === 0) {
211
+ cmdIDs = (step.commands || []).map((cmd) => cmd.cmdId);
212
+ }
213
+ const cId = cmdIDs.shift();
214
+ this.sendExecutionStatus({
215
+ type: "cmdExecutionStart",
216
+ cmdId: cId,
217
+ })
218
+ return cId;
219
+ }
220
+ }
194
221
  let codePage; // = getCodePage();
195
222
  // const tempFolderPath = process.env.tempFeaturesFolderPath;
196
223
  const __temp_features_FolderName = "__temp_features" + Math.random().toString(36).substring(2, 7);
@@ -259,28 +286,28 @@ export class BVTStepRunner {
259
286
  }
260
287
  saveRoutes({ step, folderPath: routesPath });
261
288
  }
262
- const feature_file_path = await this.writeTempFeatureFile({ step, parametersMap, tempFolderPath, tags });
263
- // console.log({ feature_file_path, step_text: step.text });
264
-
265
- const stepExecController = new AbortController();
266
- this.#currentStepController = stepExecController;
267
- const { result, info } = await withAbort(async () => {
268
- return await stepsDefinitions.executeStepRemote(
269
- {
270
- feature_file_path,
271
- tempFolderPath,
272
- stepText: step.text,
273
- scenario: "Temp Scenario",
274
- },
275
- options
276
- );
277
- }, stepExecController.signal).finally(() => {
278
- // rm temp folder
279
- if (fs.existsSync(tempFolderPath)) {
280
- fs.rmSync(tempFolderPath, { recursive: true });
281
- }
282
- });
283
- return { result, info };
284
289
  }
290
+ const feature_file_path = await this.writeTempFeatureFile({ step, parametersMap, tempFolderPath, tags });
291
+ // console.log({ feature_file_path, step_text: step.text });
292
+
293
+ const stepExecController = new AbortController();
294
+ this.#currentStepController = stepExecController;
295
+ const { result, info } = await withAbort(async () => {
296
+ return await stepsDefinitions.executeStepRemote(
297
+ {
298
+ feature_file_path,
299
+ tempFolderPath,
300
+ stepText: step.text,
301
+ scenario: "Temp Scenario",
302
+ },
303
+ options
304
+ );
305
+ }, stepExecController.signal).finally(() => {
306
+ // rm temp folder
307
+ if (fs.existsSync(tempFolderPath)) {
308
+ fs.rmSync(tempFolderPath, { recursive: true });
309
+ }
310
+ });
311
+ return { result, info };
285
312
  }
286
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1319-dev",
3
+ "version": "1.0.1321-dev",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",