@dev-blinq/cucumber_client 1.0.1433-dev → 1.0.1433-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 +1009 -47
- 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 +27 -8
- package/bin/client/recorderv3/step_utils.js +514 -39
- package/bin/client/recorderv3/update_feature.js +32 -13
- 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
|
@@ -235,6 +235,7 @@ export const getImplementedSteps = async (projectDir) => {
|
|
|
235
235
|
pattern: template.pattern,
|
|
236
236
|
paths: template.paths,
|
|
237
237
|
routeItems: step.routeItems,
|
|
238
|
+
isApiStep: template.source === "api",
|
|
238
239
|
};
|
|
239
240
|
|
|
240
241
|
implementedSteps.push(implementedStep);
|
|
@@ -260,6 +261,7 @@ export const getImplementedSteps = async (projectDir) => {
|
|
|
260
261
|
mjsFile: template.mjsFile,
|
|
261
262
|
pattern: template.pattern,
|
|
262
263
|
paths: template.paths,
|
|
264
|
+
isApiStep: template.source === "api",
|
|
263
265
|
};
|
|
264
266
|
// reconstruct the parameters
|
|
265
267
|
const parameters = [];
|
|
@@ -1,276 +1,5 @@
|
|
|
1
1
|
import { loadArgs, showUsage, validateCLIArg } from "../cli_helpers.js";
|
|
2
|
-
import {
|
|
3
|
-
import { BVTRecorder } from "./bvt_recorder.js";
|
|
4
|
-
import { compareWithScenario } from "../code_gen/duplication_analysis.js";
|
|
5
|
-
import { getAppDataDir } from "./app_dir.js";
|
|
6
|
-
import { readdir } from "fs/promises";
|
|
7
|
-
import socketLogger from "../utils/socket_logger.js";
|
|
8
|
-
|
|
9
|
-
let port = process.env.EDITOR_PORT || 3003;
|
|
10
|
-
const WS_URL = "http://localhost:" + port;
|
|
11
|
-
|
|
12
|
-
class PromisifiedSocketServer {
|
|
13
|
-
constructor(socket, routes) {
|
|
14
|
-
this.socket = socket;
|
|
15
|
-
this.routes = routes;
|
|
16
|
-
}
|
|
17
|
-
init() {
|
|
18
|
-
this.socket.on("request", async (data) => {
|
|
19
|
-
const { event, input, id, roomId, socketId } = data;
|
|
20
|
-
if (event !== "recorderWindow.getCurrentChromiumPath") {
|
|
21
|
-
socketLogger.info("Received request", { event, input, id, roomId, socketId });
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
const handler = this.routes[event];
|
|
25
|
-
if (!handler) {
|
|
26
|
-
console.error(`No handler found for event: ${event}`);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const response = await handler(input);
|
|
30
|
-
if (event !== "recorderWindow.getCurrentChromiumPath") {
|
|
31
|
-
socketLogger.info(`Sending response`, { event, id, value: response, roomId, socketId });
|
|
32
|
-
}
|
|
33
|
-
this.socket.emit("response", { id, value: response, roomId, socketId });
|
|
34
|
-
} catch (error) {
|
|
35
|
-
socketLogger.error("Error handling request", { event, input, id, roomId, socketId, error });
|
|
36
|
-
this.socket.emit("response", {
|
|
37
|
-
id,
|
|
38
|
-
error: {
|
|
39
|
-
message: error?.message,
|
|
40
|
-
code: error?.code,
|
|
41
|
-
info: error?.info,
|
|
42
|
-
stack: error?.stack,
|
|
43
|
-
},
|
|
44
|
-
roomId,
|
|
45
|
-
socketId,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const init = ({ envName, projectDir, roomId, TOKEN }) => {
|
|
53
|
-
console.log("Connecting to " + WS_URL);
|
|
54
|
-
const socket = io(WS_URL);
|
|
55
|
-
socketLogger.init(socket, { context: "BVTRecorder", eventName: "BVTRecorder.log" });
|
|
56
|
-
socket.on("connect", () => {
|
|
57
|
-
socketLogger.info("Connected to BVTRecorder server");
|
|
58
|
-
console.log("Connected to BVTRecorder server");
|
|
59
|
-
});
|
|
60
|
-
socket.on("disconnect", () => {
|
|
61
|
-
socketLogger.info("Disconnected from server");
|
|
62
|
-
console.log("Disconnected from server");
|
|
63
|
-
});
|
|
64
|
-
socket.emit("joinRoom", { id: roomId, window: "cucumber_client/bvt_recorder" });
|
|
65
|
-
const recorder = new BVTRecorder({
|
|
66
|
-
envName,
|
|
67
|
-
projectDir,
|
|
68
|
-
TOKEN,
|
|
69
|
-
sendEvent: (event, data) => {
|
|
70
|
-
socketLogger.info("Sending event", { event, data, roomId });
|
|
71
|
-
socket.emit(event, data, roomId);
|
|
72
|
-
},
|
|
73
|
-
logger: socketLogger,
|
|
74
|
-
});
|
|
75
|
-
recorder
|
|
76
|
-
.openBrowser()
|
|
77
|
-
.then(() => {
|
|
78
|
-
socketLogger.info("BVTRecorder.browserOpened");
|
|
79
|
-
socket.emit("BVTRecorder.browserOpened", null, roomId);
|
|
80
|
-
})
|
|
81
|
-
.catch((e) => {
|
|
82
|
-
socketLogger.error("BVTRecorder.browserLaunchFailed", e);
|
|
83
|
-
socket.emit("BVTRecorder.browserLaunchFailed", e, roomId);
|
|
84
|
-
});
|
|
85
|
-
const timeOutForFunction = async (promise, timeout = 5000) => {
|
|
86
|
-
const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(), timeout));
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const res = await Promise.race([promise, timeoutPromise]);
|
|
90
|
-
return res;
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error(error);
|
|
93
|
-
socketLogger.error(error);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const promisifiedSocketServer = new PromisifiedSocketServer(socket, {
|
|
99
|
-
"recorderWindow.openBrowser": async (input) => {
|
|
100
|
-
return recorder
|
|
101
|
-
.openBrowser(input)
|
|
102
|
-
.then(() => {
|
|
103
|
-
socketLogger.info("BVTRecorder.browserOpened");
|
|
104
|
-
console.info("BVTRecorder.browserOpened");
|
|
105
|
-
socket.emit("BVTRecorder.browserOpened", { roomId, window: "cucumber_client/bvt_recorder" });
|
|
106
|
-
})
|
|
107
|
-
.catch((e) => {
|
|
108
|
-
socketLogger.error("Error opening browser", e);
|
|
109
|
-
console.error("BVTRecorder.browserLaunchFailed", e);
|
|
110
|
-
socket.emit("BVTRecorder.browserLaunchFailed", { roomId, window: "cucumber_client/bvt_recorder" });
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
"recorderWindow.closeBrowser": async (input) => {
|
|
114
|
-
return recorder.closeBrowser(input);
|
|
115
|
-
},
|
|
116
|
-
"recorderWindow.reOpenBrowser": async (input) => {
|
|
117
|
-
return recorder
|
|
118
|
-
.reOpenBrowser(input)
|
|
119
|
-
.then(() => {
|
|
120
|
-
socketLogger.info("BVTRecorder.browserOpened");
|
|
121
|
-
console.log("BVTRecorder.browserOpened");
|
|
122
|
-
socket.emit("BVTRecorder.browserOpened", null, roomId);
|
|
123
|
-
})
|
|
124
|
-
.catch((e) => {
|
|
125
|
-
socketLogger.info("BVTRecorder.browserLaunchFailed");
|
|
126
|
-
console.error("BVTRecorder.browserLaunchFailed", e);
|
|
127
|
-
socket.emit("BVTRecorder.browserLaunchFailed", null, roomId);
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
"recorderWindow.startRecordingInput": async (input) => {
|
|
131
|
-
return timeOutForFunction(recorder.startRecordingInput(input));
|
|
132
|
-
},
|
|
133
|
-
"recorderWindow.stopRecordingInput": async (input) => {
|
|
134
|
-
return timeOutForFunction(recorder.stopRecordingInput(input));
|
|
135
|
-
},
|
|
136
|
-
"recorderWindow.startRecordingText": async (input) => {
|
|
137
|
-
// console.log("--- {{ }} -- : recorderWindow.startRecordingText", input);
|
|
138
|
-
return timeOutForFunction(recorder.startRecordingText(input));
|
|
139
|
-
},
|
|
140
|
-
"recorderWindow.stopRecordingText": async (input) => {
|
|
141
|
-
return timeOutForFunction(recorder.stopRecordingText(input));
|
|
142
|
-
},
|
|
143
|
-
"recorderWindow.startRecordingContext": async (input) => {
|
|
144
|
-
return timeOutForFunction(recorder.startRecordingContext(input));
|
|
145
|
-
},
|
|
146
|
-
"recorderWindow.stopRecordingContext": async (input) => {
|
|
147
|
-
return timeOutForFunction(recorder.stopRecordingContext(input));
|
|
148
|
-
},
|
|
149
|
-
"recorderWindow.runStep": async (input) => {
|
|
150
|
-
return recorder.runStep(input);
|
|
151
|
-
},
|
|
152
|
-
"recorderWindow.saveScenario": async (input) => {
|
|
153
|
-
return recorder.saveScenario(input);
|
|
154
|
-
},
|
|
155
|
-
"recorderWindow.getImplementedSteps": async (input) => {
|
|
156
|
-
// console.log("recorderWindow.getImplementedSteps", input);
|
|
157
|
-
return (await recorder.getImplementedSteps(input)).implementedSteps;
|
|
158
|
-
},
|
|
159
|
-
"recorderWindow.getImplementedScenarios": async (input) => {
|
|
160
|
-
// console.log("recorderWindow.getImplementedScenarios", input);
|
|
161
|
-
return (await recorder.getImplementedSteps(input)).scenarios;
|
|
162
|
-
},
|
|
163
|
-
"recorderWindow.getCurrentChromiumPath": async () => {
|
|
164
|
-
// console.log("recorderWindow.getCurrentChromiumPath");
|
|
165
|
-
return await recorder.getCurrentChromiumPath();
|
|
166
|
-
},
|
|
167
|
-
"recorderWindow.overwriteTestData": async (input) => {
|
|
168
|
-
// console.log("recorderWindow.overwriteTestData");
|
|
169
|
-
return await recorder.overwriteTestData(input);
|
|
170
|
-
},
|
|
171
|
-
"recorderWindow.generateStepName": async (input) => {
|
|
172
|
-
return recorder.generateStepName(input);
|
|
173
|
-
},
|
|
174
|
-
"recorderWindow.getFeatureAndScenario": async (input) => {
|
|
175
|
-
return recorder.generateScenarioAndFeatureNames(input);
|
|
176
|
-
},
|
|
177
|
-
"recorderWindow.generateCommandName": async (input) => {
|
|
178
|
-
return recorder.generateCommandName(input);
|
|
179
|
-
},
|
|
180
|
-
"recorderWindow.loadTestData": async (input) => {
|
|
181
|
-
return recorder.loadTestData(input);
|
|
182
|
-
},
|
|
183
|
-
"recorderWindow.discard": async (input) => {
|
|
184
|
-
return await recorder.discardTestData(input);
|
|
185
|
-
},
|
|
186
|
-
"recorderWindow.addToTestData": async (input) => {
|
|
187
|
-
return await recorder.addToTestData(input);
|
|
188
|
-
},
|
|
189
|
-
"recorderWindow.getScenarios": async () => {
|
|
190
|
-
return recorder.getScenarios();
|
|
191
|
-
},
|
|
192
|
-
"recorderWindow.setShouldTakeScreenshot": async (input) => {
|
|
193
|
-
return recorder.setShouldTakeScreenshot(input);
|
|
194
|
-
},
|
|
195
|
-
"recorderWindow.compareWithScenario": async ({ projectDir, scenario }, roomId) => {
|
|
196
|
-
return await compareWithScenario(getAppDataDir(projectDir), scenario);
|
|
197
|
-
},
|
|
198
|
-
"recorderWindow.getCommandsForImplementedStep": async (input) => {
|
|
199
|
-
return recorder.getCommandsForImplementedStep(input);
|
|
200
|
-
},
|
|
201
|
-
"recorderWindow.getNumberOfOccurrences": async (input) => {
|
|
202
|
-
return recorder.getNumberOfOccurrences(input);
|
|
203
|
-
},
|
|
204
|
-
"recorderWindow.abortExecution": async (input) => {
|
|
205
|
-
return recorder.abortExecution(input);
|
|
206
|
-
},
|
|
207
|
-
"recorderWindow.pauseExecution": async (input) => {
|
|
208
|
-
return recorder.pauseExecution(input);
|
|
209
|
-
},
|
|
210
|
-
"recorderWindow.resumeExecution": async (input) => {
|
|
211
|
-
return recorder.resumeExecution(input);
|
|
212
|
-
},
|
|
213
|
-
"recorderWindow.loadExistingScenario": async (input) => {
|
|
214
|
-
return recorder.loadExistingScenario(input);
|
|
215
|
-
},
|
|
216
|
-
"recorderWindow.findRelatedTextInAllFrames": async (input) => {
|
|
217
|
-
return recorder.findRelatedTextInAllFrames(input);
|
|
218
|
-
},
|
|
219
|
-
"recorderWindow.getReportFolder": async (input) => {
|
|
220
|
-
return recorder.getReportFolder();
|
|
221
|
-
},
|
|
222
|
-
"recorderWindow.getSnapshotFiles": async (input) => {
|
|
223
|
-
const snapshotFolder = recorder.getSnapshotFolder();
|
|
224
|
-
if (snapshotFolder) {
|
|
225
|
-
const files = await readdir(snapshotFolder);
|
|
226
|
-
const ymlFiles = files.filter((file) => file.endsWith(".yml") || file.endsWith(".yaml"));
|
|
227
|
-
return { folder: snapshotFolder, files: ymlFiles };
|
|
228
|
-
} else return { folder: null, files: [] };
|
|
229
|
-
},
|
|
230
|
-
"recorderWindow.getCurrentPageTitle": async (input) => {
|
|
231
|
-
return await recorder.getCurrentPageTitle();
|
|
232
|
-
},
|
|
233
|
-
"recorderWindow.getCurrentPageUrl": async (input) => {
|
|
234
|
-
return await recorder.getCurrentPageUrl();
|
|
235
|
-
},
|
|
236
|
-
"recorderWindow.sendAriaSnapshot": async (input) => {
|
|
237
|
-
const snapshot = input?.snapshot;
|
|
238
|
-
const deselect = input?.deselect;
|
|
239
|
-
if (deselect === true) {
|
|
240
|
-
return await recorder.deselectAriaElements();
|
|
241
|
-
}
|
|
242
|
-
if (snapshot !== null) {
|
|
243
|
-
return await recorder.processAriaSnapshot(snapshot);
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
"recorderWindow.revertMode": async (input) => {
|
|
247
|
-
await recorder.revertMode();
|
|
248
|
-
},
|
|
249
|
-
"recorderWindow.setMode": async (input) => {
|
|
250
|
-
const mode = input?.mode;
|
|
251
|
-
return recorder.setMode(mode);
|
|
252
|
-
},
|
|
253
|
-
"recorderWindow.getStepsAndCommandsForScenario": async (input) => {
|
|
254
|
-
return await recorder.getStepsAndCommandsForScenario(input);
|
|
255
|
-
},
|
|
256
|
-
"recorderWindow.getNetworkEvents": async (input) => {
|
|
257
|
-
return await recorder.getNetworkEvents(input);
|
|
258
|
-
},
|
|
259
|
-
"recorderWindow.initExecution": async (input) => {
|
|
260
|
-
return await recorder.initExecution(input);
|
|
261
|
-
},
|
|
262
|
-
"recorderWindow.cleanupExecution": async (input) => {
|
|
263
|
-
return await recorder.cleanupExecution(input);
|
|
264
|
-
},
|
|
265
|
-
"recorderWindow.resetExecution": async (input) => {
|
|
266
|
-
return await recorder.resetExecution(input);
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
socket.on("targetBrowser.command.event", async (input) => {
|
|
270
|
-
return recorder.onAction(input);
|
|
271
|
-
});
|
|
272
|
-
promisifiedSocketServer.init();
|
|
273
|
-
};
|
|
2
|
+
import { BVTRecorderInit } from "./bvt_init.js";
|
|
274
3
|
|
|
275
4
|
const usage = `Usage: node bvt_recorder.js <projectDir> <envName> <roomId>`;
|
|
276
5
|
const args = loadArgs();
|
|
@@ -279,6 +8,7 @@ const envName = args[1].split("=")[1];
|
|
|
279
8
|
const roomId = args[2];
|
|
280
9
|
const shouldTakeScreenshot = args[3];
|
|
281
10
|
const TOKEN = process.env.TOKEN;
|
|
11
|
+
|
|
282
12
|
try {
|
|
283
13
|
validateCLIArg(projectDir, "projectDir");
|
|
284
14
|
validateCLIArg(envName, "envName");
|
|
@@ -290,14 +20,4 @@ try {
|
|
|
290
20
|
} catch (error) {
|
|
291
21
|
showUsage(error, usage);
|
|
292
22
|
}
|
|
293
|
-
|
|
294
|
-
init({
|
|
295
|
-
envName,
|
|
296
|
-
projectDir,
|
|
297
|
-
roomId,
|
|
298
|
-
TOKEN,
|
|
299
|
-
shouldTakeScreenshot: shouldTakeScreenshot ? shouldTakeScreenshot === "true" : false,
|
|
300
|
-
});
|
|
301
|
-
} catch (error) {
|
|
302
|
-
console.error(error);
|
|
303
|
-
}
|
|
23
|
+
BVTRecorderInit({ envName, projectDir, roomId, TOKEN });
|