@dev-blinq/cucumber_client 1.0.1444-stage → 1.0.1445-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.
|
@@ -264,8 +264,8 @@ export class BVTStepRunner {
|
|
|
264
264
|
|
|
265
265
|
for (const cmdId of cmdIDs) {
|
|
266
266
|
this.liveExecutionMap.set(cmdId, {
|
|
267
|
-
resolve: () => {
|
|
268
|
-
reject: () => {
|
|
267
|
+
resolve: () => {},
|
|
268
|
+
reject: () => {},
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
|
|
@@ -319,7 +319,10 @@ export class BVTStepRunner {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
if (
|
|
322
|
+
if (
|
|
323
|
+
step.isUtilStep ||
|
|
324
|
+
((!(step.isImplemented && !step.shouldOverride) || step.shouldMakeStepTextUnique) && step.commands.length > 0)
|
|
325
|
+
) {
|
|
323
326
|
const pageName = generatePageName(step.startFrame?.url ?? "default");
|
|
324
327
|
const stepDefinitionFolderPath = path.join(tempFolderPath, "step_definitions");
|
|
325
328
|
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,37 @@ 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
|
+
if (!step.renamedText || step.renamedText === step.text) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
step.text = step.text.trim();
|
|
560
|
+
const { functionName } = stepsDefinitions.findMatchingStep(step.renamedText);
|
|
561
|
+
step.renamedText = functionName;
|
|
562
|
+
const newImportLine = `import { ${functionName} } from "./utils.mjs";\n`;
|
|
552
563
|
|
|
553
|
-
|
|
554
|
-
|
|
564
|
+
if (!codePage.fileContent.includes(newImportLine)) {
|
|
565
|
+
codePage.fileContent = newImportLine + codePage.fileContent;
|
|
566
|
+
}
|
|
555
567
|
}
|
|
556
568
|
}
|
|
557
569
|
}
|
|
558
570
|
|
|
571
|
+
const renamedUtil = step.renamedText && isUtilStep;
|
|
572
|
+
|
|
559
573
|
routesPath = path.join(tmpdir(), "blinq_temp_routes");
|
|
560
574
|
if (process.env.TEMP_RUN === "true") {
|
|
561
575
|
if (existsSync(routesPath)) {
|
|
@@ -631,7 +645,7 @@ export async function saveRecording({
|
|
|
631
645
|
stepsDefinitions
|
|
632
646
|
);
|
|
633
647
|
|
|
634
|
-
if (!
|
|
648
|
+
if (!renamedUtil && !(step.isImplemented && step.shouldOverride)) {
|
|
635
649
|
stepsDefinitions.addStep({
|
|
636
650
|
name: step.text,
|
|
637
651
|
file: result.codePage.sourceFileName,
|
|
@@ -643,13 +657,14 @@ export async function saveRecording({
|
|
|
643
657
|
return result.codePage;
|
|
644
658
|
} else {
|
|
645
659
|
const generateCodeResult = generateCode(recording, codePage, userData, projectDir, methodName);
|
|
646
|
-
|
|
660
|
+
console.log("Generated code for step:", step.text);
|
|
661
|
+
if (!isUtilStep && generateCodeResult.noCode === true) {
|
|
647
662
|
return generateCodeResult.page;
|
|
648
663
|
}
|
|
649
664
|
codePage = generateCodeResult.page;
|
|
650
665
|
methodName = generateCodeResult.methodName;
|
|
651
666
|
|
|
652
|
-
if (!
|
|
667
|
+
if (!renamedUtil) {
|
|
653
668
|
codePage.insertElements(generateCodeResult.elements);
|
|
654
669
|
}
|
|
655
670
|
|
|
@@ -665,19 +680,30 @@ export async function saveRecording({
|
|
|
665
680
|
}
|
|
666
681
|
}
|
|
667
682
|
|
|
668
|
-
if (
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
683
|
+
if (renamedUtil) {
|
|
684
|
+
if (isChangedUtilStepName) {
|
|
685
|
+
const newFileContent = codePage.fileContent
|
|
686
|
+
.replace(`async function ${step.renamedText}`, `async function ${methodName}`)
|
|
687
|
+
.replace(`Then("${step.renamedText}"`, `// Then("${step.renamedText}"`)
|
|
688
|
+
.replace(`When("${step.renamedText}"`, `// When("${step.renamedText}"`)
|
|
689
|
+
.replace(`Given("${step.renamedText}"`, `// Given("${step.renamedText}"`);
|
|
690
|
+
|
|
691
|
+
codePage._init();
|
|
692
|
+
codePage.generateModel(newFileContent);
|
|
693
|
+
} else {
|
|
694
|
+
codePage.addInfraCommandUtil(
|
|
695
|
+
methodName,
|
|
696
|
+
description,
|
|
697
|
+
cucumberStep.parameters,
|
|
698
|
+
generateCodeResult.codeLines,
|
|
699
|
+
step.renamedText,
|
|
700
|
+
step.text,
|
|
701
|
+
parametersMap,
|
|
702
|
+
protect,
|
|
703
|
+
"recorder",
|
|
704
|
+
path
|
|
705
|
+
);
|
|
706
|
+
}
|
|
681
707
|
} else {
|
|
682
708
|
codePage.addInfraCommand(
|
|
683
709
|
methodName,
|
|
@@ -699,7 +725,7 @@ export async function saveRecording({
|
|
|
699
725
|
step.finalTimeout
|
|
700
726
|
);
|
|
701
727
|
|
|
702
|
-
if (!
|
|
728
|
+
if (!renamedUtil && !(step.isImplemented && step.shouldOverride)) {
|
|
703
729
|
stepsDefinitions.addStep({
|
|
704
730
|
name: step.text,
|
|
705
731
|
file: codePage.sourceFileName,
|
|
@@ -760,7 +786,7 @@ export const getCommandsForImplementedStep = (stepName, stepsDefinitions, stepPa
|
|
|
760
786
|
if (error) {
|
|
761
787
|
throw new Error(error);
|
|
762
788
|
}
|
|
763
|
-
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs");
|
|
789
|
+
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs") || codePage.sourceFileName.endsWith("default_page.mjs");
|
|
764
790
|
|
|
765
791
|
if (parametersNames.length !== stepParams.length) {
|
|
766
792
|
// console.log("Parameters mismatch", parametersNames, stepParams);
|
|
@@ -867,7 +893,7 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir,
|
|
|
867
893
|
step.isImplementedWhileRecording = true;
|
|
868
894
|
}
|
|
869
895
|
}
|
|
870
|
-
if ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0) {
|
|
896
|
+
if (!step.isUtilStep && ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0)) {
|
|
871
897
|
let routesPath = path.join(tmpdir(), `blinq_temp_routes`);
|
|
872
898
|
if (process.env.TEMP_RUN === "true") {
|
|
873
899
|
if (existsSync(routesPath)) {
|