@dev-blinq/cucumber_client 1.0.1437-dev → 1.0.1437-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_gen/api_codegen.js +2 -2
- package/bin/client/code_gen/code_inversion.js +63 -2
- 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 +28 -22
- 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 +3 -2
- 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 +363 -0
- package/bin/client/recorderv3/bvt_recorder.js +1033 -50
- package/bin/client/recorderv3/implemented_steps.js +2 -0
- package/bin/client/recorderv3/index.js +3 -283
- package/bin/client/recorderv3/scriptTest.js +1 -1
- package/bin/client/recorderv3/services.js +818 -142
- package/bin/client/recorderv3/step_runner.js +19 -5
- package/bin/client/recorderv3/step_utils.js +514 -39
- package/bin/client/recorderv3/update_feature.js +45 -15
- 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/socket_logger.js +1 -1
- package/bin/index.js +4 -1
- package/package.json +6 -4
|
@@ -108,7 +108,18 @@ export function getCommandContent(command) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
export function getExamplesContent(parametersMap) {
|
|
111
|
+
export function getExamplesContent(parametersMap, datasets) {
|
|
112
|
+
if (datasets && datasets.length > 0) {
|
|
113
|
+
let result = ''
|
|
114
|
+
const keys = Object.keys(parametersMap);
|
|
115
|
+
result += "\t\tExamples:\n";
|
|
116
|
+
|
|
117
|
+
result += `\t\t| ${keys.join(" | ")} |\n`;
|
|
118
|
+
for (const dataset of datasets) {
|
|
119
|
+
result += `\t\t| ${dataset.data.map(d => escapeNonPrintables(d.value)).join(" | ")} |\n`;
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
112
123
|
const keys = Object.keys(parametersMap);
|
|
113
124
|
const l = keys.length;
|
|
114
125
|
let result = "\t\tExamples:\n";
|
|
@@ -164,7 +175,7 @@ export function getScenarioContent({ scenario }, featureFileObject) {
|
|
|
164
175
|
scenarioContent += `\t${step.keyword} ${escapeString(step.text)}\n`;
|
|
165
176
|
}
|
|
166
177
|
if (!isParmatersMapEmpty) {
|
|
167
|
-
scenarioContent += getExamplesContent(prametersMap);
|
|
178
|
+
scenarioContent += getExamplesContent(prametersMap, scenario.datasets);
|
|
168
179
|
}
|
|
169
180
|
return scenarioContent;
|
|
170
181
|
}
|
|
@@ -235,7 +246,7 @@ const GherkinToObject = (gherkin) => {
|
|
|
235
246
|
skipEmptyLines();
|
|
236
247
|
|
|
237
248
|
if (idx >= lines.length) {
|
|
238
|
-
return
|
|
249
|
+
return scenario;
|
|
239
250
|
}
|
|
240
251
|
|
|
241
252
|
while (
|
|
@@ -292,25 +303,46 @@ const GherkinToObject = (gherkin) => {
|
|
|
292
303
|
|
|
293
304
|
// remove lines starting with "Scenario:" or "Scenario Outline:" that contain the scenario name until the next scenario and then append the new scenario content
|
|
294
305
|
// assumes that there are no multiple scenarios with the same name and having comments and tags in each scenario
|
|
295
|
-
function updateExistingScenario({
|
|
306
|
+
function updateExistingScenario({
|
|
307
|
+
featureFileContent,
|
|
308
|
+
scenarioName: newScenarioName,
|
|
309
|
+
scenarioContent: newScenarioContent,
|
|
310
|
+
}) {
|
|
296
311
|
const featureFileObject = GherkinToObject(featureFileContent);
|
|
297
312
|
if (featureFileObject.error) return "error";
|
|
313
|
+
|
|
298
314
|
const results = [];
|
|
299
|
-
let skipScenarioIndex = -1;
|
|
300
315
|
results.push(`Feature: ${featureFileObject.featureName}`);
|
|
316
|
+
|
|
317
|
+
let indexOfScenarioToUpdate = -1;
|
|
318
|
+
|
|
319
|
+
for (let i = 0; i < featureFileObject.scenarios.length; i++) {
|
|
320
|
+
if (featureFileObject.scenarios[i].name === newScenarioName) {
|
|
321
|
+
indexOfScenarioToUpdate = i;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
301
326
|
for (let i = 0; i < featureFileObject.scenarios.length; i++) {
|
|
302
327
|
const scenario = featureFileObject.scenarios[i];
|
|
303
|
-
|
|
304
|
-
|
|
328
|
+
|
|
329
|
+
if (i === indexOfScenarioToUpdate) {
|
|
330
|
+
results.push("");
|
|
331
|
+
results.push(newScenarioContent.trim());
|
|
332
|
+
results.push("");
|
|
305
333
|
continue;
|
|
306
334
|
}
|
|
307
|
-
|
|
335
|
+
|
|
336
|
+
let scenarioHeader = `${scenario.hasParams ? "Scenario Outline" : "Scenario"}: ${scenario.name}`;
|
|
308
337
|
let tagsLine;
|
|
338
|
+
|
|
309
339
|
if (scenario.tags?.length > 0) {
|
|
310
|
-
tagsLine =
|
|
340
|
+
tagsLine = scenario.tags.map((t) => `@${t}`).join(" ");
|
|
311
341
|
}
|
|
342
|
+
|
|
312
343
|
if (tagsLine) results.push("\t" + tagsLine);
|
|
313
|
-
results.push(`\t${
|
|
344
|
+
results.push(`\t${scenarioHeader}`);
|
|
345
|
+
|
|
314
346
|
for (const step of scenario.steps) {
|
|
315
347
|
if (step.type === "examples") {
|
|
316
348
|
results.push(`\t\tExamples:`);
|
|
@@ -323,12 +355,10 @@ function updateExistingScenario({ featureFileContent, scenarioName, scenarioCont
|
|
|
323
355
|
}
|
|
324
356
|
results.push("");
|
|
325
357
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
finalContent = results.join("\n") + "\n" + scenarioContent;
|
|
329
|
-
}
|
|
330
|
-
return finalContent;
|
|
358
|
+
|
|
359
|
+
return results.join("\n");
|
|
331
360
|
}
|
|
361
|
+
|
|
332
362
|
export async function updateFeatureFile({ featureName, scenario, override, projectDir }) {
|
|
333
363
|
const featureFilePath = path.join(projectDir, "features", featureName + ".feature");
|
|
334
364
|
const isFeatureFileExists = existsSync(featureFilePath);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { io } from "socket.io-client";
|
|
2
|
+
import { BVTRecorderInit } from "./bvt_init.js";
|
|
3
|
+
import { loadArgs, showUsage, validateCLIArg } from "../cli_helpers.js";
|
|
4
|
+
const requiredEnvVars = ["PROJECT_ID", "BLINQ_TOKEN", "SESSION_ID", "WORKER_WS_SERVER_URL", "REMOTE_ORIGINS_URL"];
|
|
5
|
+
function validateEnvVariables() {
|
|
6
|
+
const missingVars = requiredEnvVars.filter((varName) => !process.env[varName]);
|
|
7
|
+
if (missingVars.length > 0) {
|
|
8
|
+
throw new Error(`Missing required environment variables: ${missingVars.join(", ")}`);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
console.log("All required environment variables are set.");
|
|
12
|
+
requiredEnvVars.forEach((varName) => {
|
|
13
|
+
console.log(`${varName}: ${process.env[varName]}`);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getEnvironmentConfig() {
|
|
18
|
+
const args = loadArgs();
|
|
19
|
+
const projectDir = args[0] || process.env.PROJECT_ID;
|
|
20
|
+
const envName = args[1]?.split("=")[1] || process.env.ENV_NAME;
|
|
21
|
+
const roomId = args[2] || process.env.SESSION_ID;
|
|
22
|
+
const shouldTakeScreenshot = args[3] || process.env.SHOULD_TAKE_SCREENSHOT;
|
|
23
|
+
const TOKEN = process.env.BLINQ_TOKEN;
|
|
24
|
+
try {
|
|
25
|
+
validateCLIArg(projectDir, "projectDir");
|
|
26
|
+
validateCLIArg(envName, "envName");
|
|
27
|
+
validateCLIArg(roomId, "roomId");
|
|
28
|
+
validateCLIArg(shouldTakeScreenshot, "shouldTakeScreenshot");
|
|
29
|
+
if (!TOKEN) {
|
|
30
|
+
throw new Error("BLINQ_TOKEN env variable not set");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const usage = `Usage: node bvt_recorder.js <projectDir> <envName> <roomId>`;
|
|
35
|
+
if (error instanceof Error) {
|
|
36
|
+
showUsage(error, usage);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const unknownError = new Error("An unknown error occurred");
|
|
40
|
+
showUsage(unknownError, usage);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { envName, projectDir, roomId, TOKEN };
|
|
44
|
+
}
|
|
45
|
+
function initWebBVTRecorder() {
|
|
46
|
+
const socket = io(process.env.WORKER_WS_SERVER_URL, {
|
|
47
|
+
path: "/ws",
|
|
48
|
+
transports: ["websocket", "polling"],
|
|
49
|
+
reconnection: true,
|
|
50
|
+
});
|
|
51
|
+
validateEnvVariables();
|
|
52
|
+
const { envName, projectDir, roomId, TOKEN } = getEnvironmentConfig();
|
|
53
|
+
BVTRecorderInit({
|
|
54
|
+
envName: envName,
|
|
55
|
+
projectDir,
|
|
56
|
+
roomId,
|
|
57
|
+
TOKEN,
|
|
58
|
+
socket: socket,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
initWebBVTRecorder();
|
package/bin/client/recording.js
CHANGED
|
@@ -12,6 +12,7 @@ class ScenarioUploadService {
|
|
|
12
12
|
this.runsApiBaseURL + "/scenarios/create",
|
|
13
13
|
{
|
|
14
14
|
name,
|
|
15
|
+
branch: process.env.GIT_BRANCH ? process.env.GIT_BRANCH : "main",
|
|
15
16
|
},
|
|
16
17
|
{
|
|
17
18
|
headers: {
|
|
@@ -37,7 +38,7 @@ class ScenarioUploadService {
|
|
|
37
38
|
},
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
if(response.status === 401) {
|
|
41
|
+
if (response.status === 401) {
|
|
41
42
|
throw new Error("Your trial plan has ended. Cannot upload reports and perform retraining");
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -63,7 +64,7 @@ class ScenarioUploadService {
|
|
|
63
64
|
}
|
|
64
65
|
);
|
|
65
66
|
|
|
66
|
-
if(response.status === 403) {
|
|
67
|
+
if (response.status === 403) {
|
|
67
68
|
throw new Error("Your trial plan has ended. Cannot upload reports and perform retraining");
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -107,6 +108,7 @@ class ScenarioUploadService {
|
|
|
107
108
|
{
|
|
108
109
|
scenarioId,
|
|
109
110
|
projectId,
|
|
111
|
+
testcase_id: process.env.TESTCASE_ID,
|
|
110
112
|
},
|
|
111
113
|
{
|
|
112
114
|
headers: {
|
package/bin/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./client/code_gen/page_reflection.js";
|
|
2
|
+
|
|
2
3
|
export * from "./client/code_gen/playwright_codeget.js";
|
|
3
4
|
export * from "./client/cucumber/feature.js";
|
|
4
5
|
export * from "./client/cucumber/project_to_document.js";
|
|
@@ -13,5 +14,7 @@ export * from "./client/cucumber/feature_data.js";
|
|
|
13
14
|
export * from "./client/cucumber/steps_definitions.js";
|
|
14
15
|
export * from "./client/profiler.js";
|
|
15
16
|
export * from "./client/code_cleanup/utils.js";
|
|
16
|
-
|
|
17
17
|
export * from "./client/code_cleanup/find_step_definition_references.js";
|
|
18
|
+
export * from "./client/recorderv3/step_utils.js";
|
|
19
|
+
export * from "./client/recorderv3/update_feature.js";
|
|
20
|
+
export * from "./client/recorderv3/bvt_init.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-blinq/cucumber_client",
|
|
3
|
-
"version": "1.0.1437-
|
|
3
|
+
"version": "1.0.1437-stage",
|
|
4
4
|
"description": " ",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@babel/traverse": "^7.27.1",
|
|
38
38
|
"@babel/types": "^7.27.1",
|
|
39
39
|
"@cucumber/tag-expressions": "^6.1.1",
|
|
40
|
-
"@dev-blinq/cucumber-js": "1.0.
|
|
41
|
-
"@faker-js/faker": "^8.1
|
|
42
|
-
"automation_model": "1.0.
|
|
40
|
+
"@dev-blinq/cucumber-js": "1.0.121-stage",
|
|
41
|
+
"@faker-js/faker": "^8.4.1",
|
|
42
|
+
"automation_model": "1.0.798-stage",
|
|
43
43
|
"axios": "^1.7.4",
|
|
44
44
|
"chokidar": "^3.6.0",
|
|
45
45
|
"create-require": "^1.1.1",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"pureimage": "0.4.9",
|
|
58
58
|
"socket.io": "^4.7.5",
|
|
59
59
|
"socket.io-client": "^4.7.5",
|
|
60
|
+
"strip-comments": "^2.0.1",
|
|
60
61
|
"tunnel": "^0.0.6",
|
|
61
62
|
"unzipper": "^0.12.3",
|
|
62
63
|
"win-ca": "^3.5.1",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"mocha": "^10.2.0",
|
|
75
76
|
"ncp": "^2.0.0",
|
|
76
77
|
"readline-sync": "^1.4.10",
|
|
78
|
+
"ts-node": "^10.9.2",
|
|
77
79
|
"tsup": "^8.5.0",
|
|
78
80
|
"typescript": "^5.9.2"
|
|
79
81
|
}
|