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