@dev-blinq/cucumber_client 1.0.1213-dev → 1.0.1215-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.
@@ -632,4 +632,23 @@ function findFilesWithExtension(folderPath, extension, rootFolder = null) {
632
632
 
633
633
  return result;
634
634
  }
635
+ export function locateDefinitionPath(featureFolder, pageName) {
636
+ if (!pageName) {
637
+ return null;
638
+ }
639
+ if (!pageName.endsWith("_page.mjs")) {
640
+ pageName = pageName + "_page.mjs";
641
+ }
642
+ // search for files with the pageName
643
+ const stepDefinitionFolderPath = path.join(featureFolder, "step_definitions");
644
+ const files = findFilesWithExtension(stepDefinitionFolderPath, "mjs");
645
+ for (let i = 0; i < files.length; i++) {
646
+ const file = files[i];
647
+ if (file.includes(pageName)) {
648
+ return path.join(stepDefinitionFolderPath, file);
649
+ }
650
+ }
651
+ return path.join(stepDefinitionFolderPath, pageName);
652
+ }
653
+
635
654
  export { StepsDefinitions, findFilesWithExtension };
@@ -4,6 +4,7 @@ import { CodePage } from "./code_gen/page_reflection.js";
4
4
  import logger from "../logger.js";
5
5
  import path from "path";
6
6
  import { fileURLToPath } from "url";
7
+ import { findFilesWithExtension } from "./cucumber/steps_definitions.js";
7
8
  const __filename = fileURLToPath(import.meta.url);
8
9
  const __dirname = path.dirname(__filename);
9
10
 
@@ -85,7 +86,10 @@ class Project {
85
86
  logger.error("Error loading utils_template");
86
87
  }
87
88
 
88
- let files = readdirSync(this.stepsFolder);
89
+ const files = findFilesWithExtension(this.stepsFolder, "mjs");
90
+
91
+ //let files = readdirSync(this.stepsFolder);
92
+
89
93
  for (let i = 0; i < files.length; i++) {
90
94
  let file = files[i];
91
95
  if (file.startsWith("_")) {
@@ -11,6 +11,7 @@ import {
11
11
  saveRecording,
12
12
  } from "./step_utils.js";
13
13
  import { escapeString, getExamplesContent } from "./update_feature.js";
14
+ import { locateDefinitionPath } from "../cucumber/steps_definitions.js";
14
15
 
15
16
  // let copiedCodeToTemp = false;
16
17
  async function withAbort(fn, signal) {
@@ -96,7 +97,8 @@ export class BVTStepRunner {
96
97
  if (!existsSync(stepDefinitionFolderPath)) {
97
98
  mkdirSync(stepDefinitionFolderPath, { recursive: true });
98
99
  }
99
- const stepDefsFilePath = path.join(stepDefinitionFolderPath, pageName + "_page.mjs");
100
+ const stepDefsFilePath = locateDefinitionPath(tempFolderPath, pageName);
101
+ //path.join(stepDefinitionFolderPath, pageName + "_page.mjs");
100
102
  codePage = getCodePage(stepDefsFilePath);
101
103
  codePage = await saveRecording({ step, cucumberStep, codePage, projectDir: this.projectDir, stepsDefinitions });
102
104
  if (codePage) {
@@ -6,7 +6,7 @@ import { CodePage } from "../code_gen/page_reflection.js";
6
6
  import { generateCode, generatePageName } from "../code_gen/playwright_codeget.js";
7
7
  import { invertCodeToCommand } from "../code_gen/code_inversion.js";
8
8
  import { Step } from "../cucumber/feature.js";
9
- import { StepsDefinitions } from "../cucumber/steps_definitions.js";
9
+ import { locateDefinitionPath, StepsDefinitions } from "../cucumber/steps_definitions.js";
10
10
  import { Recording } from "../recording.js";
11
11
  import { generateApiCode } from "../code_gen/api_codegen.js";
12
12
 
@@ -299,6 +299,7 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir
299
299
  const steps = scenario.steps;
300
300
 
301
301
  const stepsDefinitions = new StepsDefinitions(projectDir);
302
+ const featureFolder = path.join(projectDir, "features");
302
303
  stepsDefinitions.load(false);
303
304
  // const parameters = scenario.parameters;
304
305
  // await saveRecordings({ steps, parameters, codePage, projectDir });
@@ -314,7 +315,8 @@ export async function updateStepDefinitions({ scenario, featureName, projectDir
314
315
  }
315
316
  const cucumberStep = getCucumberStep({ step });
316
317
  const pageName = generatePageName(step.startFrame?.url ?? "default");
317
- const stepDefsFilePath = path.join(stepDefinitionFolderPath, pageName + "_page.mjs");
318
+ const stepDefsFilePath = locateDefinitionPath(featureFolder, pageName);
319
+ // path.join(stepDefinitionFolderPath, pageName + "_page.mjs");
318
320
  let codePage = getCodePage(stepDefsFilePath);
319
321
 
320
322
  codePage = await saveRecording({ step, cucumberStep, codePage, projectDir, stepsDefinitions });
@@ -396,6 +396,7 @@ const runCucumber = async (
396
396
  logger.error(e.stack);
397
397
  message = e.message + "\n" + e.stack;
398
398
  }
399
+ aiAgent.scenarioReport.updateLastCommand({ status: false, error: message });
399
400
  // Write logs to file on error
400
401
  const logsFilePath = path.join(result.scenarioPath, "editorLogs.log");
401
402
  writeLogsToFile(logsFilePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1213-dev",
3
+ "version": "1.0.1215-dev",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",