@dev-blinq/cucumber_client 1.0.1523-dev → 1.0.1525-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.
@@ -475,6 +475,65 @@ const invertStableCommand = (call, elements, stepParams) => {
475
475
  }
476
476
  break;
477
477
  }
478
+
479
+ case "conditionalWait": {
480
+ step.type = Types.CONDITIONAL_WAIT;
481
+ step.element = extractElement(call.arguments[0]);
482
+ const condition = call.arguments[1].value;
483
+
484
+ const _timeout = parseDataSource(call.arguments[2], stepParams);
485
+ let timeout = 30;
486
+ if (_timeout.type === "literal") {
487
+ if (isNaN(_timeout.value)) {
488
+ throw new Error(`Timeout value must be a number, got ${_timeout.value}`);
489
+ }
490
+ timeout = Number(_timeout.value) * 1000;
491
+ } else {
492
+ step.dataSource = _timeout.dataSource;
493
+ step.dataKey = _timeout.dataKey;
494
+ timeout = toVariableName(_timeout.dataKey);
495
+ }
496
+ // step.timeout = timeout;
497
+ // step.value = "true";
498
+ step.parameters = [timeout, condition, step.value];
499
+ // step.condition = condition;
500
+ break;
501
+ }
502
+
503
+ case "sleep": {
504
+ step.type = Types.SLEEP;
505
+ const duration = parseDataSource(call.arguments[0], stepParams);
506
+ if (duration.type === "literal") {
507
+ if (isNaN(duration.value)) {
508
+ throw new Error(`Sleep duration must be a number, got ${duration.value}`);
509
+ }
510
+ step.parameters = [Number(duration.value)];
511
+ } else {
512
+ step.dataSource = duration.dataSource;
513
+ step.dataKey = duration.dataKey;
514
+ step.parameters = [toVariableName(duration.dataKey)];
515
+ }
516
+ break;
517
+ }
518
+ case "verify_file_exists": {
519
+ step.type = Types.VERIFY_FILE_EXISTS;
520
+ const filePath = parseDataSource(call.arguments[0], stepParams);
521
+ if (filePath.type === "literal") {
522
+ step.parameters = [filePath.value];
523
+ } else {
524
+ step.dataSource = filePath.dataSource;
525
+ step.dataKey = filePath.dataKey;
526
+ step.parameters = [toVariableName(filePath.dataKey)];
527
+ }
528
+ break;
529
+ }
530
+
531
+ // case "verifyPagePath":
532
+ // {
533
+ // step.type = Types.VERIFY_PAGE_PATH;
534
+ // step.parameters = [call.arguments[0].value];
535
+ // break;
536
+ // }
478
537
  default:
479
538
  return; // Skip if no matching method
480
539
  }
@@ -727,26 +727,35 @@ export const getCommandsForImplementedStep = (stepName, stepsDefinitions, stepPa
727
727
  if (error) {
728
728
  throw new Error(error);
729
729
  }
730
+ isUtilStep = codePage.sourceFileName.endsWith("utils.mjs");
730
731
 
731
732
  if (parametersNames.length !== stepParams.length) {
732
733
  // console.log("Parameters mismatch", parametersNames, stepParams);
733
734
  throw new Error("Parameters mismatch");
734
735
  }
735
- for (let i = 0; i < parametersNames.length; i++) {
736
- stepParams[i].argumentName = parametersNames[i];
737
- }
738
736
 
739
- isUtilStep = codePage.sourceFileName.endsWith("utils.mjs");
740
- for (const { code } of codeCommands) {
741
- const command = invertCodeToCommand(code, elements, stepParams, stepsDefinitions, codePage, stepName)[0];
742
- if (command === undefined || command.type === null) continue;
743
- if (command.element) {
744
- const key = command.element.key;
745
- if (key && locatorsJson[key]) {
746
- command.allStrategyLocators = locatorsJson[key];
737
+ const pattern = step.name;
738
+ if (isUtilStep && pattern === "Verify the file {string} exists") {
739
+ commands.push({
740
+ type: "verify_file_exists",
741
+ parameters: [stepParams[0].text],
742
+ });
743
+ } else {
744
+ for (let i = 0; i < parametersNames.length; i++) {
745
+ stepParams[i].argumentName = parametersNames[i];
746
+ }
747
+
748
+ for (const { code } of codeCommands) {
749
+ const command = invertCodeToCommand(code, elements, stepParams, stepsDefinitions, codePage, stepName)[0];
750
+ if (command === undefined || command.type === null) continue;
751
+ if (command.element) {
752
+ const key = command.element.key;
753
+ if (key && locatorsJson[key]) {
754
+ command.allStrategyLocators = locatorsJson[key];
755
+ }
747
756
  }
757
+ commands.push(command);
748
758
  }
749
- commands.push(command);
750
759
  }
751
760
  } catch (error) {
752
761
  console.error(error);
@@ -53,6 +53,7 @@ const Types = {
53
53
  SET_INPUT_FILES: "set_input_files",
54
54
  VERIFY_PAGE_SNAPSHOT: "verify_page_snapshot",
55
55
  CONDITIONAL_WAIT: "conditional_wait",
56
+ SLEEP: "sleep",
56
57
  };
57
58
  class Recording {
58
59
  steps = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1523-dev",
3
+ "version": "1.0.1525-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "@cucumber/tag-expressions": "^6.1.1",
40
40
  "@dev-blinq/cucumber-js": "1.0.195-dev",
41
41
  "@faker-js/faker": "^8.4.1",
42
- "automation_model": "1.0.871-dev",
42
+ "automation_model": "1.0.872-dev",
43
43
  "axios": "^1.7.4",
44
44
  "chokidar": "^3.6.0",
45
45
  "create-require": "^1.1.1",