@dev-blinq/cucumber_client 1.0.1403-dev → 1.0.1403-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 +105 -105
- 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 +163 -44
- 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 +5 -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 +846 -906
- package/bin/client/code_gen/playwright_codeget.js +27 -3
- package/bin/client/cucumber/feature.js +4 -0
- 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 +6 -3
- package/bin/client/cucumber_selector.js +17 -1
- 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/project.js +186 -202
- package/bin/client/recorderv3/bvt_init.js +349 -0
- package/bin/client/recorderv3/bvt_recorder.js +1069 -104
- package/bin/client/recorderv3/implemented_steps.js +2 -0
- package/bin/client/recorderv3/index.js +4 -303
- package/bin/client/recorderv3/scriptTest.js +1 -1
- package/bin/client/recorderv3/services.js +814 -154
- package/bin/client/recorderv3/step_runner.js +315 -206
- package/bin/client/recorderv3/step_utils.js +499 -37
- package/bin/client/recorderv3/update_feature.js +9 -5
- package/bin/client/recorderv3/wbr_entry.js +61 -0
- package/bin/client/recording.js +1 -0
- package/bin/client/upload-service.js +3 -2
- package/bin/client/utils/socket_logger.js +132 -0
- package/bin/index.js +4 -1
- package/bin/logger.js +3 -2
- package/bin/min/consoleApi.min.cjs +2 -3
- package/bin/min/injectedScript.min.cjs +16 -16
- package/package.json +19 -9
|
@@ -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
|
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} SocketLoggerEventPayload
|
|
3
|
+
* @property {string} level Log level (e.g. "info", "warn", "error", "debug")
|
|
4
|
+
* @property {string} context Log context/subsystem (e.g. "BVTRecorder")
|
|
5
|
+
* @property {*} data The log message payload (string, object, etc)
|
|
6
|
+
* @property {string} timestamp ISO string when the log was emitted
|
|
7
|
+
* @property {number} dataSize Size of data in bytes (-1 if unknown)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} SocketLoggerInitOptions
|
|
12
|
+
* @property {string=} context Default context for all logs (optional)
|
|
13
|
+
* @property {string=} eventName Default event name (default: "recorder.log")
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* SocketLogger - Singleton for structured socket-based logging.
|
|
18
|
+
*
|
|
19
|
+
* @namespace SocketLogger
|
|
20
|
+
* @property {function(import('socket.io-client').Socket|import('socket.io').Socket, SocketLoggerInitOptions=):void} init
|
|
21
|
+
* @property {function(string, (string|*), Object=, string=, string=):void} log
|
|
22
|
+
* @property {function((string|*), Object=):void} info
|
|
23
|
+
* @property {function((string|*), Object=):void} warn
|
|
24
|
+
* @property {function((string|*), Object=):void} debug
|
|
25
|
+
* @property {function((string|*), Object=):void} error
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import logger from "./socket_logger.js";
|
|
29
|
+
* logger.init(socket, { context: "BVTRecorder" });
|
|
30
|
+
* logger.info("Step started", { step: 2 });
|
|
31
|
+
* logger.error("Failed!", { error: "bad stuff" });
|
|
32
|
+
*/
|
|
33
|
+
const SocketLogger = (function () {
|
|
34
|
+
/** @type {import('socket.io-client').Socket|import('socket.io').Socket|null} */
|
|
35
|
+
let socket = null;
|
|
36
|
+
/** @type {string} */
|
|
37
|
+
let defaultContext = "";
|
|
38
|
+
/** @type {string} */
|
|
39
|
+
let defaultEventName = "recorder.log";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Initialize the logger (call once).
|
|
43
|
+
* @param {import('socket.io-client').Socket|import('socket.io').Socket} sock
|
|
44
|
+
* @param {SocketLoggerInitOptions=} opts
|
|
45
|
+
*/
|
|
46
|
+
function init(sock, opts) {
|
|
47
|
+
socket = sock;
|
|
48
|
+
defaultContext = (opts && opts.context) || "";
|
|
49
|
+
defaultEventName = (opts && opts.eventName) || "recorder.log";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Low-level log method (most users use info/warn/debug/error).
|
|
54
|
+
* @param {string} level Log level ("info", "warn", "debug", "error")
|
|
55
|
+
* @param {string|*} message The log message or object
|
|
56
|
+
* @param {Object=} extra Extra fields (will be merged into log payload)
|
|
57
|
+
* @param {string=} eventName Override event name for this log (default: "recorder.log")
|
|
58
|
+
* @param {string=} context Override log context for this log (default: set in init)
|
|
59
|
+
*/
|
|
60
|
+
function log(level, message, extra, eventName, context) {
|
|
61
|
+
if (!socket || typeof socket.emit !== "function") return;
|
|
62
|
+
/** @type {*} */
|
|
63
|
+
var data = typeof message === "object" ? message : { message: message };
|
|
64
|
+
/** @type {number} */
|
|
65
|
+
var dataSize = 0;
|
|
66
|
+
try {
|
|
67
|
+
dataSize = Buffer.byteLength(JSON.stringify(data || ""), "utf8");
|
|
68
|
+
} catch (e) {
|
|
69
|
+
dataSize = -1;
|
|
70
|
+
}
|
|
71
|
+
/** @type {SocketLoggerEventPayload} */
|
|
72
|
+
var eventPayload = Object.assign(
|
|
73
|
+
{
|
|
74
|
+
level: level,
|
|
75
|
+
context: context || defaultContext,
|
|
76
|
+
data: JSON.stringify(data),
|
|
77
|
+
timestamp: new Date().toISOString(),
|
|
78
|
+
dataSize: dataSize,
|
|
79
|
+
},
|
|
80
|
+
extra || {}
|
|
81
|
+
);
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
try {
|
|
84
|
+
if (socket) {
|
|
85
|
+
socket.emit(eventName || defaultEventName, eventPayload);
|
|
86
|
+
}
|
|
87
|
+
} catch (e) {
|
|
88
|
+
console.error("Socket logging error:", e);
|
|
89
|
+
console.log("Socket event payload:", eventPayload);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Write an info-level log event.
|
|
95
|
+
* @param {string|*} msg The message or object
|
|
96
|
+
* @param {Object=} ext Any extra fields/metadata
|
|
97
|
+
*/
|
|
98
|
+
function info(msg, ext) {
|
|
99
|
+
log("info", msg, ext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Write a warn-level log event.
|
|
104
|
+
* @param {string|*} msg The message or object
|
|
105
|
+
* @param {Object=} ext Any extra fields/metadata
|
|
106
|
+
*/
|
|
107
|
+
function warn(msg, ext) {
|
|
108
|
+
log("warn", msg, ext);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Write a debug-level log event.
|
|
113
|
+
* @param {string|*} msg The message or object
|
|
114
|
+
* @param {Object=} ext Any extra fields/metadata
|
|
115
|
+
*/
|
|
116
|
+
function debug(msg, ext) {
|
|
117
|
+
log("debug", msg, ext);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Write an error-level log event.
|
|
122
|
+
* @param {string|*} msg The message or object
|
|
123
|
+
* @param {Object=} ext Any extra fields/metadata
|
|
124
|
+
*/
|
|
125
|
+
function error(msg, ext) {
|
|
126
|
+
log("error", msg, ext);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { init, log, info, warn, debug, error };
|
|
130
|
+
})();
|
|
131
|
+
|
|
132
|
+
export default SocketLogger;
|
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/bin/logger.js
CHANGED
|
@@ -17,8 +17,8 @@ function formatWithInspect(val) {
|
|
|
17
17
|
let alignColorsAndTime = null;
|
|
18
18
|
let fileRotateTransport = null;
|
|
19
19
|
let errorFileRotateTransport = null;
|
|
20
|
-
export let logger = null;
|
|
21
20
|
function initLogger() {
|
|
21
|
+
let logger = null;
|
|
22
22
|
try {
|
|
23
23
|
alignColorsAndTime = format.combine(
|
|
24
24
|
format.timestamp({
|
|
@@ -59,9 +59,10 @@ function initLogger() {
|
|
|
59
59
|
console.log(error);
|
|
60
60
|
logger = console;
|
|
61
61
|
}
|
|
62
|
+
return logger;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
initLogger();
|
|
65
|
+
export const logger = initLogger();
|
|
65
66
|
const changeToTaskLogger = (logFile) => {
|
|
66
67
|
logger.remove(fileRotateTransport);
|
|
67
68
|
fileRotateTransport.filename = logFile;
|