@dev-blinq/cucumber_client 1.0.1666-dev → 1.0.1667-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.
@@ -370,6 +370,35 @@ export class CodePage {
370
370
  return result;
371
371
  }
372
372
  }
373
+ addInfraCommandUtil(methodName, description, stepVariables, stepCodeLines, renamedText, previousText, protectStep = false, source = null, codePath = "") {
374
+ let code = "\n";
375
+ code += "/**\n";
376
+ code += ` * ${description}\n`;
377
+ const tags = [];
378
+ if (protectStep)
379
+ tags.push("@protect");
380
+ if (source)
381
+ tags.push(`@${source}`);
382
+ if (tags.length > 0)
383
+ code += ` * ${tags.join(" ")}\n`;
384
+ if (codePath !== null)
385
+ code += ` * @path=${escapeForComment(codePath)}\n`;
386
+ const matches = previousText.match(/"[^"]*"/g);
387
+ const countInMethodName = matches ? matches.length : 0;
388
+ code += " */\n";
389
+ code += `async function ${methodName} (${new Array(countInMethodName)
390
+ .fill(0)
391
+ .map((v, index) => `param${index}`)
392
+ .join(", ")}){\n`;
393
+ code += `// source: ${source}\n`;
394
+ code += `// implemented_at: ${new Date().toISOString()}\n`;
395
+ stepCodeLines.forEach((line) => (code += ` ${line}\n`));
396
+ if (renamedText) {
397
+ code += `await ${renamedText}(${stepVariables.map((v) => (isNaN(Number(v.text)) ? `"${v.text}"` : Number(v.text))).join(", ")});\n`;
398
+ }
399
+ code += "}\n";
400
+ return this._injectMethod(methodName, code);
401
+ }
373
402
  addInfraCommand(methodName, description, stepVarables, stepCodeLines, protectStep = false, source = null, codePath = "") {
374
403
  let code = "\n";
375
404
  code += "/**\n";
@@ -458,7 +458,7 @@ export function getCodePage(stepDefsFilePath) {
458
458
  export function getCucumberStep({ step }) {
459
459
  const cucumberStep = new Step();
460
460
  cucumberStep.loadFromJson({
461
- text: step.text,
461
+ text: step.renamedText ? step.renamedText : step.text,
462
462
  keyword: step.keyword,
463
463
  keywordType: step.keywordType,
464
464
  parameters: [],
@@ -577,7 +577,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
577
577
 
578
578
  const userData = {}; // TODO: get user data
579
579
 
580
- let methodName = step.renamedText ? step.renamedText : toMethodName(step.text);
580
+ let methodName = toMethodName(step.text);
581
581
  if (step.isApiStep) {
582
582
  const {
583
583
  url,
@@ -656,8 +656,21 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
656
656
  protect = true;
657
657
  }
658
658
  }
659
- if (!step.renamedText) {
660
- const infraResult = codePage.addInfraCommand(
659
+
660
+ if (step.renamedText) {
661
+ codePage.addInfraCommandUtil(
662
+ methodName,
663
+ description,
664
+ cucumberStep.parameters,
665
+ generateCodeResult.codeLines,
666
+ step.renamedText,
667
+ step.text,
668
+ protect,
669
+ "recorder",
670
+ path
671
+ );
672
+ } else {
673
+ codePage.addInfraCommand(
661
674
  methodName,
662
675
  description,
663
676
  cucumberStep.getVariablesList(),
@@ -667,6 +680,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
667
680
  path
668
681
  );
669
682
  }
683
+
670
684
  const keyword = (cucumberStep.keywordAlias ?? cucumberStep.keyword).trim();
671
685
  const stepResult = codePage.addCucumberStep(
672
686
  keyword,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1666-dev",
3
+ "version": "1.0.1667-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",