@dev-blinq/cucumber_client 1.0.1444-dev → 1.0.1444-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.
- package/bin/assets/bundled_scripts/recorder.js +73 -73
- package/bin/assets/preload/css_gen.js +10 -10
- package/bin/assets/preload/toolbar.js +27 -29
- package/bin/assets/preload/unique_locators.js +1 -1
- package/bin/assets/preload/yaml.js +288 -275
- package/bin/assets/scripts/aria_snapshot.js +223 -220
- package/bin/assets/scripts/dom_attr.js +329 -329
- package/bin/assets/scripts/dom_parent.js +169 -174
- package/bin/assets/scripts/event_utils.js +94 -94
- package/bin/assets/scripts/pw.js +2050 -1949
- package/bin/assets/scripts/recorder.js +70 -45
- package/bin/assets/scripts/snapshot_capturer.js +147 -147
- package/bin/assets/scripts/unique_locators.js +170 -49
- package/bin/assets/scripts/yaml.js +796 -783
- package/bin/assets/templates/_hooks_template.txt +6 -2
- package/bin/assets/templates/utils_template.txt +16 -16
- package/bin/client/code_cleanup/find_step_definition_references.js +0 -1
- package/bin/client/code_cleanup/utils.js +16 -7
- package/bin/client/code_gen/api_codegen.js +2 -2
- package/bin/client/code_gen/code_inversion.js +119 -2
- package/bin/client/code_gen/duplication_analysis.js +2 -1
- package/bin/client/code_gen/function_signature.js +4 -0
- package/bin/client/code_gen/page_reflection.js +52 -11
- package/bin/client/code_gen/playwright_codeget.js +163 -75
- package/bin/client/cucumber/feature.js +4 -17
- package/bin/client/cucumber/feature_data.js +2 -2
- package/bin/client/cucumber/project_to_document.js +8 -2
- package/bin/client/cucumber/steps_definitions.js +19 -3
- package/bin/client/local_agent.js +1 -0
- package/bin/client/parse_feature_file.js +23 -26
- package/bin/client/playground/projects/env.json +2 -2
- package/bin/client/recorderv3/bvt_init.js +305 -0
- package/bin/client/recorderv3/bvt_recorder.js +1024 -58
- package/bin/client/recorderv3/implemented_steps.js +2 -0
- package/bin/client/recorderv3/index.js +3 -283
- package/bin/client/recorderv3/services.js +818 -142
- package/bin/client/recorderv3/step_runner.js +20 -6
- package/bin/client/recorderv3/step_utils.js +542 -73
- package/bin/client/recorderv3/update_feature.js +87 -39
- package/bin/client/recorderv3/wbr_entry.js +61 -0
- package/bin/client/recording.js +1 -0
- package/bin/client/upload-service.js +4 -2
- package/bin/client/utils/app_dir.js +21 -0
- package/bin/client/utils/socket_logger.js +87 -125
- package/bin/index.js +4 -1
- package/package.json +11 -5
- package/bin/client/recorderv3/app_dir.js +0 -23
- package/bin/client/recorderv3/network.js +0 -299
- package/bin/client/recorderv3/scriptTest.js +0 -5
- package/bin/client/recorderv3/ws_server.js +0 -72
|
@@ -170,7 +170,7 @@ export class CodePage {
|
|
|
170
170
|
this.generateModel(fileContentNew);
|
|
171
171
|
}
|
|
172
172
|
catch (e) {
|
|
173
|
-
logger.
|
|
173
|
+
logger.error("failed to format the code");
|
|
174
174
|
logger.debug(e);
|
|
175
175
|
}
|
|
176
176
|
if (!existsSync(this.sourceFileName)) {
|
|
@@ -288,6 +288,11 @@ export class CodePage {
|
|
|
288
288
|
codePart.name = node.id.name;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
+
findKey(funcString, key) {
|
|
292
|
+
const sourceRegex = new RegExp(`${key}:\\s*(.*)`);
|
|
293
|
+
const match = funcString.match(sourceRegex);
|
|
294
|
+
return match ? match[1] : null;
|
|
295
|
+
}
|
|
291
296
|
collectAllTemplates() {
|
|
292
297
|
const templates = [];
|
|
293
298
|
if (this.cucumberCalls.length > 0) {
|
|
@@ -300,10 +305,12 @@ export class CodePage {
|
|
|
300
305
|
const stepType = cucumberCall["stepType"];
|
|
301
306
|
let firstFind = true;
|
|
302
307
|
const stepPaths = [];
|
|
308
|
+
let source = null;
|
|
303
309
|
for (let j = 0; j < this.methods.length; j++) {
|
|
304
310
|
const method = this.methods[j];
|
|
305
311
|
if (method.name === methodName) {
|
|
306
312
|
if (firstFind) {
|
|
313
|
+
source = this.findKey(method.codePart, "source");
|
|
307
314
|
foundMethod = true;
|
|
308
315
|
const paramsObj = (method.node?.params ?? []);
|
|
309
316
|
if (paramsObj && paramsObj.length > 0) {
|
|
@@ -315,7 +322,7 @@ export class CodePage {
|
|
|
315
322
|
}
|
|
316
323
|
}
|
|
317
324
|
if (foundMethod) {
|
|
318
|
-
templates.push({ pattern, methodName, params, stepType, paths: stepPaths });
|
|
325
|
+
templates.push({ pattern, methodName, params, stepType, paths: stepPaths, source });
|
|
319
326
|
}
|
|
320
327
|
}
|
|
321
328
|
}
|
|
@@ -363,6 +370,39 @@ export class CodePage {
|
|
|
363
370
|
return result;
|
|
364
371
|
}
|
|
365
372
|
}
|
|
373
|
+
addInfraCommandUtil(methodName, description, stepVariables, stepCodeLines, renamedText, previousText, parametersMap, protectStep = false, source = null, codePath = "") {
|
|
374
|
+
let code = "\n";
|
|
375
|
+
code += "/**\n";
|
|
376
|
+
code += ` * ${description}\n`;
|
|
377
|
+
const tags = [];
|
|
378
|
+
if (protectStep)
|
|
379
|
+
tags.push("@protect");
|
|
380
|
+
if (source)
|
|
381
|
+
tags.push(`@${source}`);
|
|
382
|
+
if (tags.length > 0)
|
|
383
|
+
code += ` * ${tags.join(" ")}\n`;
|
|
384
|
+
if (codePath !== null)
|
|
385
|
+
code += ` * @path=${escapeForComment(codePath)}\n`;
|
|
386
|
+
const matches = previousText.match(/"[^"]*"/g);
|
|
387
|
+
const countInMethodName = matches ? matches.length : 0;
|
|
388
|
+
code += " */\n";
|
|
389
|
+
code += `async function ${methodName} (${new Array(countInMethodName)
|
|
390
|
+
.fill(0)
|
|
391
|
+
.map((v, index) => `param${index}`)
|
|
392
|
+
.join(", ")}){\n`;
|
|
393
|
+
code += `// source: ${source}\n`;
|
|
394
|
+
code += `// implemented_at: ${new Date().toISOString()}\n`;
|
|
395
|
+
stepCodeLines.forEach((line) => (code += ` ${line}\n`));
|
|
396
|
+
if (renamedText === "verify_page_title" || renamedText === "verify_page_url") {
|
|
397
|
+
const parameters = stepVariables.map((v) => parametersMap[v.text.replace(/[<>]/g, "")]);
|
|
398
|
+
code += `await ${renamedText}(${parameters.map((v) => (isNaN(Number(v)) ? `"${v}"` : Number(v))).join(", ")});\n`;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
code += `await ${renamedText}(${stepVariables.map((v) => (isNaN(Number(v.text)) ? `"${v.text}"` : Number(v.text))).join(", ")});\n`;
|
|
402
|
+
}
|
|
403
|
+
code += "}\n";
|
|
404
|
+
return this._injectMethod(methodName, code);
|
|
405
|
+
}
|
|
366
406
|
addInfraCommand(methodName, description, stepVarables, stepCodeLines, protectStep = false, source = null, codePath = "") {
|
|
367
407
|
let code = "\n";
|
|
368
408
|
code += "/**\n";
|
|
@@ -528,12 +568,13 @@ export class CodePage {
|
|
|
528
568
|
for (let j = i - 1; j >= 0; j--) {
|
|
529
569
|
const nextElement = elements[keys[j]];
|
|
530
570
|
if (this._isSimilarElement(currentElement, nextElement)) {
|
|
531
|
-
mergedElements[currentElement.element_key] = currentElement;
|
|
532
|
-
replacedKeys[nextElement.element_key] = currentElement.element_key
|
|
571
|
+
// mergedElements[currentElement.element_key!] = currentElement;
|
|
572
|
+
// replacedKeys[nextElement.element_key!] = currentElement.element_key!;
|
|
533
573
|
foundMatch = true;
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
574
|
+
break;
|
|
575
|
+
// keys.splice(j, 1);
|
|
576
|
+
// i--;
|
|
577
|
+
// j++;
|
|
537
578
|
}
|
|
538
579
|
}
|
|
539
580
|
if (!foundMatch) {
|
|
@@ -543,7 +584,7 @@ export class CodePage {
|
|
|
543
584
|
if (Object.keys(replacedKeys).length === 0)
|
|
544
585
|
return;
|
|
545
586
|
for (const key in replacedKeys) {
|
|
546
|
-
const regexp = new RegExp(`elements
|
|
587
|
+
const regexp = new RegExp(`elements\\[\\s*["']${key}["']\\s*\\]`, "g");
|
|
547
588
|
this.fileContent = this.fileContent.replace(regexp, () => `elements["${replacedKeys[key]}"]`);
|
|
548
589
|
}
|
|
549
590
|
this.insertElements(mergedElements);
|
|
@@ -620,7 +661,7 @@ export class CodePage {
|
|
|
620
661
|
let locatorsMetadataFileName = this.sourceFileName.replace(".mjs", ".json");
|
|
621
662
|
const config = getAiConfig();
|
|
622
663
|
if (config && config.locatorsMetadataDir) {
|
|
623
|
-
locatorsMetadataFileName = path.join(
|
|
664
|
+
locatorsMetadataFileName = locatorsMetadataFileName.replace(path.join("features", "step_definitions"), path.join(config.locatorsMetadataDir));
|
|
624
665
|
if (!existsSync(path.dirname(locatorsMetadataFileName))) {
|
|
625
666
|
mkdirSync(path.dirname(locatorsMetadataFileName), { recursive: true });
|
|
626
667
|
}
|
|
@@ -632,7 +673,7 @@ export class CodePage {
|
|
|
632
673
|
}
|
|
633
674
|
}
|
|
634
675
|
catch {
|
|
635
|
-
logger.
|
|
676
|
+
logger.error("failed to read locators metadata file", locatorsMetadataFileName);
|
|
636
677
|
}
|
|
637
678
|
const keys = Object.keys(locatorsMetadata);
|
|
638
679
|
keys.forEach((key) => {
|
|
@@ -642,7 +683,7 @@ export class CodePage {
|
|
|
642
683
|
writeFileSync(locatorsMetadataFileName, JSON.stringify(metadata, null, 2), "utf8");
|
|
643
684
|
}
|
|
644
685
|
catch {
|
|
645
|
-
logger.
|
|
686
|
+
logger.error("failed to write locators metadata file", locatorsMetadataFileName);
|
|
646
687
|
}
|
|
647
688
|
}
|
|
648
689
|
_getVariableStartEnd(variableName) {
|