@dev-blinq/cucumber_client 1.0.1638-dev → 1.0.1640-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.
@@ -12,7 +12,7 @@ import path from "path";
12
12
  * @param {string} text the text to verify exists in page
13
13
  * @protect
14
14
  */
15
- async function verifyTextExistsInPage(text) {
15
+ export async function verifyTextExistsInPage(text) {
16
16
  await context.web.verifyTextExistInPage(text, null, this);
17
17
  }
18
18
  Then("Verify the text {string} can be found in the page", verifyTextExistsInPage);
@@ -22,7 +22,7 @@ Then("Verify the text {string} can be found in the page", verifyTextExistsInPage
22
22
  * @param {string} elementDescription element description
23
23
  * @protect
24
24
  */
25
- async function clickOnElement(elementDescription) {
25
+ export async function clickOnElement(elementDescription) {
26
26
  await context.web.simpleClick(elementDescription, null, null, this);
27
27
  }
28
28
  When("click on {string}", clickOnElement);
@@ -36,7 +36,7 @@ When("Click {string}", clickOnElement);
36
36
  * @param {string} value value to fill the element with
37
37
  * @protect
38
38
  */
39
- async function fillElement(elementDescription, value) {
39
+ export async function fillElement(elementDescription, value) {
40
40
  await context.web.simpleClickType(elementDescription, value, null, null, this);
41
41
  }
42
42
  When("fill {string} with {string}", fillElement);
@@ -47,7 +47,7 @@ When("Fill {string} with {string}", fillElement);
47
47
  * @param {string} text the text to verify does not exist in page
48
48
  * @protect
49
49
  */
50
- async function verifyTextNotExistsInPage(text) {
50
+ export async function verifyTextNotExistsInPage(text) {
51
51
  await context.web.waitForTextToDisappear(text, null, this);
52
52
  }
53
53
  Then("Verify the text {string} cannot be found in the page", verifyTextNotExistsInPage);
@@ -57,7 +57,7 @@ Then("Verify the text {string} cannot be found in the page", verifyTextNotExists
57
57
  * @param {string} url URL to navigate
58
58
  * @protect
59
59
  */
60
- async function navigateTo(url) {
60
+ export async function navigateTo(url) {
61
61
  await context.web.goto(url, this);
62
62
  }
63
63
  When("Navigate to {string}", navigateTo);
@@ -66,7 +66,7 @@ When("Navigate to {string}", navigateTo);
66
66
  * Navigate to the current page
67
67
  * @protect
68
68
  */
69
- async function browserNavigateBack() {
69
+ export async function browserNavigateBack() {
70
70
  await context.web.goBack({}, this);
71
71
  }
72
72
  Then("Browser navigate back", browserNavigateBack);
@@ -75,7 +75,7 @@ Then("Browser navigate back", browserNavigateBack);
75
75
  * Navigate forward in browser history
76
76
  * @protect
77
77
  */
78
- async function browserNavigateForward() {
78
+ export async function browserNavigateForward() {
79
79
  await context.web.goForward({}, this);
80
80
  }
81
81
  Then("Browser navigate forward", browserNavigateForward);
@@ -85,7 +85,7 @@ Then("Browser navigate forward", browserNavigateForward);
85
85
  * @param {string} filePath the file path or empty to store in the test data file
86
86
  * @protect
87
87
  */
88
- async function storeBrowserSession(filePath) {
88
+ export async function storeBrowserSession(filePath) {
89
89
  await context.web.saveStoreState(filePath, this);
90
90
  }
91
91
  When("Store browser session {string}", storeBrowserSession);
@@ -95,7 +95,7 @@ When("Store browser session {string}", storeBrowserSession);
95
95
  * @param {string} filePath the file path or empty
96
96
  * @protect
97
97
  */
98
- async function resetBrowserSession(filePath) {
98
+ export async function resetBrowserSession(filePath) {
99
99
  await context.web.restoreSaveState(filePath, this);
100
100
  }
101
101
  When("Reset browser session {string}", resetBrowserSession);
@@ -107,7 +107,7 @@ When("Reset browser session {string}", resetBrowserSession);
107
107
  * @param {string} textToVerify the target text to verify
108
108
  * @protect
109
109
  */
110
- async function verifyTextRelatedToText(textAnchor, climb, textToVerify) {
110
+ export async function verifyTextRelatedToText(textAnchor, climb, textToVerify) {
111
111
  await context.web.verifyTextRelatedToText(textAnchor, climb, textToVerify, null, this);
112
112
  }
113
113
  Then(
@@ -120,7 +120,7 @@ Then(
120
120
  * @requestName the name of the bruno request file
121
121
  * @protect
122
122
  */
123
- async function runBrunoRequest(requestName) {
123
+ export async function runBrunoRequest(requestName) {
124
124
  await executeBrunoRequest(requestName, {}, context, this);
125
125
  }
126
126
  When("Bruno - {string}", runBrunoRequest);
@@ -131,7 +131,7 @@ When("bruno - {string}", runBrunoRequest);
131
131
  * @param {string} fileName the downloaded file to verify
132
132
  * @protect
133
133
  */
134
- async function verify_the_downloaded_file_exists(fileName) {
134
+ export async function verify_the_downloaded_file_exists(fileName) {
135
135
  const downloadFolder = path.join(context.reportFolder, "downloads");
136
136
  const downloadFile = path.join(downloadFolder, fileName);
137
137
  await verifyFileExists(downloadFile, {}, context, this);
@@ -148,7 +148,7 @@ When("Noop", async function () {});
148
148
  * @param {string} url URL to be verified against current URL
149
149
  * @protect
150
150
  */
151
- async function verify_page_url(url) {
151
+ export async function verify_page_url(url) {
152
152
  await context.web.verifyPagePath(url, {}, this);
153
153
  }
154
154
  Then("Verify the page url is {string}", verify_page_url);
@@ -158,7 +158,7 @@ Then("Verify the page url is {string}", verify_page_url);
158
158
  * @param {string} title Title to be verified against current Title
159
159
  * @protect
160
160
  */
161
- async function verify_page_title(title) {
161
+ export async function verify_page_title(title) {
162
162
  await context.web.verifyPageTitle(title, {}, this);
163
163
  }
164
164
  Then("Verify the page title is {string}", verify_page_title);
@@ -170,7 +170,7 @@ Then("Verify the page title is {string}", verify_page_title);
170
170
  * @param {world} - Optional world context
171
171
  * @returns Promise that resolves after the specified duration
172
172
  */
173
- async function sleep(duration) {
173
+ export async function sleep(duration) {
174
174
  await context.web.sleep(duration, {}, this);
175
175
  }
176
176
  Then("Sleep for {string} ms", { timeout: -1 }, sleep);
@@ -104,20 +104,20 @@ async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN, socket = nu
104
104
  },
105
105
  logger: socketLogger,
106
106
  });
107
- try {
108
- await recorder.openBrowser();
109
- socketLogger.info("BVTRecorder.browserOpened");
110
- socket.emit("BVTRecorder.browserOpened", null, roomId);
111
- } catch (e) {
112
- if (e instanceof Error) {
113
- socketLogger.error("BVTRecorder.browserLaunchFailed", e);
114
- socket.emit("BVTRecorder.browserLaunchFailed", e, roomId);
115
- } else {
116
- socketLogger.error("BVTRecorder.browserLaunchFailed", JSON.stringify(e));
117
- socket.emit("BVTRecorder.browserLaunchFailed", JSON.stringify(e), roomId);
118
- }
119
- console.error("Browser launch failed", e);
120
- }
107
+ // try {
108
+ // await recorder.openBrowser();
109
+ // socketLogger.info("BVTRecorder.browserOpened");
110
+ // socket.emit("BVTRecorder.browserOpened", null, roomId);
111
+ // } catch (e) {
112
+ // if (e instanceof Error) {
113
+ // socketLogger.error("BVTRecorder.browserLaunchFailed", e);
114
+ // socket.emit("BVTRecorder.browserLaunchFailed", e, roomId);
115
+ // } else {
116
+ // socketLogger.error("BVTRecorder.browserLaunchFailed", JSON.stringify(e));
117
+ // socket.emit("BVTRecorder.browserLaunchFailed", JSON.stringify(e), roomId);
118
+ // }
119
+ // console.error("Browser launch failed", e);
120
+ // }
121
121
 
122
122
  const promisifiedSocketServer = new PromisifiedSocketServer(socket, {
123
123
  "recorderWindow.openBrowser": async (input) => {
@@ -670,7 +670,8 @@ export class BVTRecorder {
670
670
  ],
671
671
  };
672
672
 
673
- const bvtContext = await initContext(url, false, false, this.world, 450, initScripts, this.envName);
673
+ const scenario = { pickle: this.scenarioDoc };
674
+ const bvtContext = await initContext(url, false, false, this.world, 450, initScripts, this.envName, scenario);
674
675
  this.bvtContext = bvtContext;
675
676
  this.stepRunner = new BVTStepRunner({
676
677
  projectDir: this.projectDir,
@@ -1491,6 +1492,7 @@ export class BVTRecorder {
1491
1492
  const featureFilePath = path.join(this.projectDir, "features", featureName);
1492
1493
  const gherkinDoc = this.parseFeatureFile(featureFilePath);
1493
1494
  const scenario = gherkinDoc.feature.children.find((child) => child.scenario.name === scenarioName)?.scenario;
1495
+ this.scenarioDoc = scenario;
1494
1496
 
1495
1497
  const steps = [];
1496
1498
  const parameters = [];
@@ -476,7 +476,7 @@ export function getCucumberStep({ step }) {
476
476
 
477
477
  function makeStepTextUnique(step, stepsDefinitions) {
478
478
  // const utilsFilePath = path.join("features", "step_definitions", "utils.mjs");
479
- let stepText = step.text;
479
+ let stepText = step.renamedText ? step.renamedText : step.text;
480
480
  let stepIndex = 1;
481
481
  // console.log("makeStepTextUnique", step.text);
482
482
  let stepDef = stepsDefinitions.findMatchingStep(stepText);
@@ -532,7 +532,16 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
532
532
  const isUtilStep = makeStepTextUnique(step, stepsDefinitions);
533
533
 
534
534
  if (isUtilStep) {
535
- return;
535
+ if (!step.renamedText) {
536
+ return;
537
+ }
538
+ const { functionName } = stepsDefinitions.findMatchingStep(step.renamedText);
539
+ step.renamedText = functionName;
540
+ const newImportLine = `import { ${functionName} } from "./utils.mjs";\n`;
541
+
542
+ if (!codePage.fileContent.includes(newImportLine)) {
543
+ codePage.fileContent = newImportLine + codePage.fileContent;
544
+ }
536
545
  }
537
546
  }
538
547
 
@@ -568,7 +577,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
568
577
 
569
578
  const userData = {}; // TODO: get user data
570
579
 
571
- let methodName = toMethodName(step.text);
580
+ let methodName = step.renamedText ? step.renamedText : toMethodName(step.text);
572
581
  if (step.isApiStep) {
573
582
  const {
574
583
  url,
@@ -631,7 +640,10 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
631
640
  }
632
641
  codePage = generateCodeResult.page;
633
642
  methodName = generateCodeResult.methodName;
634
- codePage.insertElements(generateCodeResult.elements);
643
+
644
+ if (!step.renamedText) {
645
+ codePage.insertElements(generateCodeResult.elements);
646
+ }
635
647
 
636
648
  const description = cucumberStep.text;
637
649
  let path = null;
@@ -644,15 +656,17 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
644
656
  protect = true;
645
657
  }
646
658
  }
647
- const infraResult = codePage.addInfraCommand(
648
- methodName,
649
- description,
650
- cucumberStep.getVariablesList(),
651
- generateCodeResult.codeLines,
652
- protect,
653
- "recorder",
654
- path
655
- );
659
+ if (!step.renamedText) {
660
+ const infraResult = codePage.addInfraCommand(
661
+ methodName,
662
+ description,
663
+ cucumberStep.getVariablesList(),
664
+ generateCodeResult.codeLines,
665
+ protect,
666
+ "recorder",
667
+ path
668
+ );
669
+ }
656
670
  const keyword = (cucumberStep.keywordAlias ?? cucumberStep.keyword).trim();
657
671
  const stepResult = codePage.addCucumberStep(
658
672
  keyword,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1638-dev",
3
+ "version": "1.0.1640-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",