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