@dev-blinq/cucumber_client 1.0.1699-dev → 1.0.1701-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.
|
@@ -276,8 +276,8 @@ export class BVTStepRunner {
|
|
|
276
276
|
|
|
277
277
|
for (const cmdId of cmdIDs) {
|
|
278
278
|
this.liveExecutionMap.set(cmdId, {
|
|
279
|
-
resolve: () => {
|
|
280
|
-
reject: () => {
|
|
279
|
+
resolve: () => {},
|
|
280
|
+
reject: () => {},
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -331,7 +331,10 @@ export class BVTStepRunner {
|
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
if (
|
|
334
|
+
if (
|
|
335
|
+
step.isUtilStep ||
|
|
336
|
+
((!(step.isImplemented && !step.shouldOverride) || step.shouldMakeStepTextUnique) && step.commands.length > 0)
|
|
337
|
+
) {
|
|
335
338
|
const pageName = generatePageName(step.startFrame?.url ?? "default");
|
|
336
339
|
const stepDefinitionFolderPath = path.join(tempFolderPath, "step_definitions");
|
|
337
340
|
if (!existsSync(stepDefinitionFolderPath)) {
|
|
@@ -485,7 +485,11 @@ function makeStepTextUnique(step, stepsDefinitions) {
|
|
|
485
485
|
// console.log("makeStepTextUnique", step.text);
|
|
486
486
|
let stepDef = stepsDefinitions.findMatchingStep(stepText);
|
|
487
487
|
// console.log({ stepDef });
|
|
488
|
-
if (
|
|
488
|
+
if (
|
|
489
|
+
stepDef &&
|
|
490
|
+
(stepDef?.file.endsWith("utils.mjs") || stepDef?.file.endsWith("default_page.mjs")) &&
|
|
491
|
+
!step.shouldMakeStepTextUnique
|
|
492
|
+
) {
|
|
489
493
|
return true;
|
|
490
494
|
}
|
|
491
495
|
while (stepDef) {
|
|
@@ -535,27 +539,38 @@ export async function saveRecording({
|
|
|
535
539
|
return;
|
|
536
540
|
}
|
|
537
541
|
|
|
542
|
+
let isUtilStep = false;
|
|
543
|
+
let isChangedUtilStepName = false;
|
|
544
|
+
|
|
538
545
|
if (step.isImplemented && step.shouldOverride) {
|
|
539
546
|
const stepDef = stepsDefinitions.findMatchingStep(step.text);
|
|
540
547
|
codePage = getCodePage(stepDef.file);
|
|
541
548
|
} else {
|
|
542
|
-
|
|
549
|
+
isUtilStep = makeStepTextUnique(step, stepsDefinitions);
|
|
543
550
|
|
|
544
551
|
if (isUtilStep) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
+
isChangedUtilStepName =
|
|
553
|
+
step.renamedText && stepsDefinitions.findMatchingStep(step.renamedText)?.file.endsWith("default_page.mjs");
|
|
554
|
+
|
|
555
|
+
if (!isChangedUtilStepName) {
|
|
556
|
+
const isUtilStep = stepsDefinitions.findMatchingStep(step.text)?.file.endsWith("utils.mjs");
|
|
557
|
+
if (!step.renamedText || step.renamedText === step.text || isUtilStep) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
step.text = step.text.trim();
|
|
561
|
+
const { functionName } = stepsDefinitions.findMatchingStep(step.renamedText);
|
|
562
|
+
step.renamedText = functionName;
|
|
563
|
+
const newImportLine = `import { ${functionName} } from "./utils.mjs";\n`;
|
|
552
564
|
|
|
553
|
-
|
|
554
|
-
|
|
565
|
+
if (!codePage.fileContent.includes(newImportLine)) {
|
|
566
|
+
codePage.fileContent = newImportLine + codePage.fileContent;
|
|
567
|
+
}
|
|
555
568
|
}
|
|
556
569
|
}
|
|
557
570
|
}
|
|
558
571
|
|
|
572
|
+
const renamedUtil = step.renamedText && isUtilStep;
|
|
573
|
+
|
|
559
574
|
routesPath = path.join(tmpdir(), "blinq_temp_routes");
|
|
560
575
|
if (process.env.TEMP_RUN === "true") {
|
|
561
576
|
if (existsSync(routesPath)) {
|
|
@@ -631,7 +646,7 @@ export async function saveRecording({
|
|
|
631
646
|
stepsDefinitions
|
|
632
647
|
);
|
|
633
648
|
|
|
634
|
-
if (!
|
|
649
|
+
if (!renamedUtil && !(step.isImplemented && step.shouldOverride)) {
|
|
635
650
|
stepsDefinitions.addStep({
|
|
636
651
|
name: step.text,
|
|
637
652
|
file: result.codePage.sourceFileName,
|
|
@@ -644,13 +659,13 @@ export async function saveRecording({
|
|
|
644
659
|
} else {
|
|
645
660
|
const generateCodeResult = generateCode(recording, codePage, userData, projectDir, methodName);
|
|
646
661
|
console.log("Generated code for step:", step.text);
|
|
647
|
-
if (generateCodeResult.noCode === true) {
|
|
662
|
+
if (!isUtilStep && generateCodeResult.noCode === true) {
|
|
648
663
|
return generateCodeResult.page;
|
|
649
664
|
}
|
|
650
665
|
codePage = generateCodeResult.page;
|
|
651
666
|
methodName = generateCodeResult.methodName;
|
|
652
667
|
|
|
653
|
-
if (!
|
|
668
|
+
if (!renamedUtil) {
|
|
654
669
|
codePage.insertElements(generateCodeResult.elements);
|
|
655
670
|
}
|
|
656
671
|
|
|
@@ -666,19 +681,30 @@ export async function saveRecording({
|
|
|
666
681
|
}
|
|
667
682
|
}
|
|
668
683
|
|
|
669
|
-
if (
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
684
|
+
if (renamedUtil) {
|
|
685
|
+
if (isChangedUtilStepName) {
|
|
686
|
+
const newFileContent = codePage.fileContent
|
|
687
|
+
.replace(`async function ${step.renamedText}`, `async function ${methodName}`)
|
|
688
|
+
.replace(`Then("${step.renamedText}"`, `// Then("${step.renamedText}"`)
|
|
689
|
+
.replace(`When("${step.renamedText}"`, `// When("${step.renamedText}"`)
|
|
690
|
+
.replace(`Given("${step.renamedText}"`, `// Given("${step.renamedText}"`);
|
|
691
|
+
|
|
692
|
+
codePage._init();
|
|
693
|
+
codePage.generateModel(newFileContent);
|
|
694
|
+
} else {
|
|
695
|
+
codePage.addInfraCommandUtil(
|
|
696
|
+
methodName,
|
|
697
|
+
description,
|
|
698
|
+
cucumberStep.parameters,
|
|
699
|
+
generateCodeResult.codeLines,
|
|
700
|
+
step.renamedText,
|
|
701
|
+
step.text,
|
|
702
|
+
parametersMap,
|
|
703
|
+
protect,
|
|
704
|
+
"recorder",
|
|
705
|
+
path
|
|
706
|
+
);
|
|
707
|
+
}
|
|
682
708
|
} else {
|
|
683
709
|
codePage.addInfraCommand(
|
|
684
710
|
methodName,
|
|
@@ -700,7 +726,7 @@ export async function saveRecording({
|
|
|
700
726
|
step.finalTimeout
|
|
701
727
|
);
|
|
702
728
|
|
|
703
|
-
if (!
|
|
729
|
+
if (!renamedUtil && !(step.isImplemented && step.shouldOverride)) {
|
|
704
730
|
stepsDefinitions.addStep({
|
|
705
731
|
name: step.text,
|
|
706
732
|
file: codePage.sourceFileName,
|
|
@@ -762,7 +788,7 @@ export const getCommandsForImplementedStep = (stepName, stepsDefinitions, stepPa
|
|
|
762
788
|
if (error) {
|
|
763
789
|
throw new Error(error);
|
|
764
790
|
}
|
|
765
|
-
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs");
|
|
791
|
+
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs") || codePage.sourceFileName.endsWith("default_page.mjs");
|
|
766
792
|
|
|
767
793
|
if (parametersNames.length !== stepParams.length) {
|
|
768
794
|
// console.log("Parameters mismatch", parametersNames, stepParams);
|
|
@@ -869,7 +895,7 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir,
|
|
|
869
895
|
step.isImplementedWhileRecording = true;
|
|
870
896
|
}
|
|
871
897
|
}
|
|
872
|
-
if ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0) {
|
|
898
|
+
if (!step.isUtilStep && ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0)) {
|
|
873
899
|
let routesPath = path.join(tmpdir(), `blinq_temp_routes`);
|
|
874
900
|
if (process.env.TEMP_RUN === "true") {
|
|
875
901
|
if (existsSync(routesPath)) {
|