@dev-blinq/cucumber_client 1.0.1421-stage → 1.0.1422-stage

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,
@@ -655,8 +655,21 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
655
655
  protect = true;
656
656
  }
657
657
  }
658
- if (!step.renamedText) {
659
- const infraResult = codePage.addInfraCommand(
658
+
659
+ if (step.renamedText) {
660
+ codePage.addInfraCommandUtil(
661
+ methodName,
662
+ description,
663
+ cucumberStep.parameters,
664
+ generateCodeResult.codeLines,
665
+ step.renamedText,
666
+ step.text,
667
+ protect,
668
+ "recorder",
669
+ path
670
+ );
671
+ } else {
672
+ codePage.addInfraCommand(
660
673
  methodName,
661
674
  description,
662
675
  cucumberStep.getVariablesList(),
@@ -666,6 +679,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
666
679
  path
667
680
  );
668
681
  }
682
+
669
683
  const keyword = (cucumberStep.keywordAlias ?? cucumberStep.keyword).trim();
670
684
  const stepResult = codePage.addCucumberStep(
671
685
  keyword,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1421-stage",
3
+ "version": "1.0.1422-stage",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",