@dev-blinq/cucumber_client 1.0.1698-dev → 1.0.1700-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,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,
|
|
@@ -644,13 +658,13 @@ export async function saveRecording({
|
|
|
644
658
|
} else {
|
|
645
659
|
const generateCodeResult = generateCode(recording, codePage, userData, projectDir, methodName);
|
|
646
660
|
console.log("Generated code for step:", step.text);
|
|
647
|
-
if (generateCodeResult.noCode === true) {
|
|
661
|
+
if (!isUtilStep && generateCodeResult.noCode === true) {
|
|
648
662
|
return generateCodeResult.page;
|
|
649
663
|
}
|
|
650
664
|
codePage = generateCodeResult.page;
|
|
651
665
|
methodName = generateCodeResult.methodName;
|
|
652
666
|
|
|
653
|
-
if (!
|
|
667
|
+
if (!renamedUtil) {
|
|
654
668
|
codePage.insertElements(generateCodeResult.elements);
|
|
655
669
|
}
|
|
656
670
|
|
|
@@ -666,19 +680,30 @@ export async function saveRecording({
|
|
|
666
680
|
}
|
|
667
681
|
}
|
|
668
682
|
|
|
669
|
-
if (
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
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
|
+
}
|
|
682
707
|
} else {
|
|
683
708
|
codePage.addInfraCommand(
|
|
684
709
|
methodName,
|
|
@@ -700,7 +725,7 @@ export async function saveRecording({
|
|
|
700
725
|
step.finalTimeout
|
|
701
726
|
);
|
|
702
727
|
|
|
703
|
-
if (!
|
|
728
|
+
if (!renamedUtil && !(step.isImplemented && step.shouldOverride)) {
|
|
704
729
|
stepsDefinitions.addStep({
|
|
705
730
|
name: step.text,
|
|
706
731
|
file: codePage.sourceFileName,
|
|
@@ -762,7 +787,7 @@ export const getCommandsForImplementedStep = (stepName, stepsDefinitions, stepPa
|
|
|
762
787
|
if (error) {
|
|
763
788
|
throw new Error(error);
|
|
764
789
|
}
|
|
765
|
-
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs");
|
|
790
|
+
isUtilStep = codePage.sourceFileName.endsWith("utils.mjs") || codePage.sourceFileName.endsWith("default_page.mjs");
|
|
766
791
|
|
|
767
792
|
if (parametersNames.length !== stepParams.length) {
|
|
768
793
|
// console.log("Parameters mismatch", parametersNames, stepParams);
|
|
@@ -869,7 +894,7 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir,
|
|
|
869
894
|
step.isImplementedWhileRecording = true;
|
|
870
895
|
}
|
|
871
896
|
}
|
|
872
|
-
if ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0) {
|
|
897
|
+
if (!step.isUtilStep && ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0)) {
|
|
873
898
|
let routesPath = path.join(tmpdir(), `blinq_temp_routes`);
|
|
874
899
|
if (process.env.TEMP_RUN === "true") {
|
|
875
900
|
if (existsSync(routesPath)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-blinq/cucumber_client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1700-dev",
|
|
4
4
|
"description": " ",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@babel/traverse": "^7.27.1",
|
|
40
40
|
"@babel/types": "^7.27.1",
|
|
41
41
|
"@cucumber/tag-expressions": "^6.1.1",
|
|
42
|
-
"@dev-blinq/cucumber-js": "1.0.
|
|
42
|
+
"@dev-blinq/cucumber-js": "1.0.216-dev",
|
|
43
43
|
"@faker-js/faker": "^8.4.1",
|
|
44
44
|
"automation_model": "1.0.922-dev",
|
|
45
45
|
"axios": "^1.7.4",
|