@dev-blinq/cucumber_client 1.0.1324-dev → 1.0.1326-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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// define the jsdoc type for the input
|
|
2
2
|
import { closeContext, initContext, _getDataFile, resetTestData } from "automation_model";
|
|
3
|
-
import { existsSync,
|
|
3
|
+
import { existsSync, readdirSync, readFileSync, rmSync } from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import url from "url";
|
|
6
|
-
import { getImplementedSteps,
|
|
6
|
+
import { getImplementedSteps, parseRouteFiles } from "./implemented_steps.js";
|
|
7
7
|
import { NamesService } from "./services.js";
|
|
8
8
|
import { BVTStepRunner } from "./step_runner.js";
|
|
9
9
|
import { readFile, writeFile } from "fs/promises";
|
|
@@ -201,6 +201,10 @@ export class BVTRecorder {
|
|
|
201
201
|
console.log("Sending cmdExecutionFailure event for cmdId:", data);
|
|
202
202
|
this.sendEvent(this.events.cmdExecutionFailure, data);
|
|
203
203
|
break;
|
|
204
|
+
case "interceptResults":
|
|
205
|
+
console.log("Sending interceptResults event");
|
|
206
|
+
this.sendEvent(this.events.interceptResults, data);
|
|
207
|
+
break;
|
|
204
208
|
default:
|
|
205
209
|
console.warn("Unknown command execution status type:", data.type);
|
|
206
210
|
break;
|
|
@@ -211,7 +215,7 @@ export class BVTRecorder {
|
|
|
211
215
|
this.pageSet = new Set();
|
|
212
216
|
this.lastKnownUrlPath = "";
|
|
213
217
|
// TODO: what is world?
|
|
214
|
-
this.world = { attach: () => {
|
|
218
|
+
this.world = { attach: () => {} };
|
|
215
219
|
this.shouldTakeScreenshot = true;
|
|
216
220
|
this.watcher = null;
|
|
217
221
|
}
|
|
@@ -227,6 +231,7 @@ export class BVTRecorder {
|
|
|
227
231
|
cmdExecutionStart: "BVTRecorder.cmdExecutionStart",
|
|
228
232
|
cmdExecutionSuccess: "BVTRecorder.cmdExecutionSuccess",
|
|
229
233
|
cmdExecutionFailure: "BVTRecorder.cmdExecutionFailure",
|
|
234
|
+
interceptResults: "BVTRecorder.interceptResults",
|
|
230
235
|
};
|
|
231
236
|
bindings = {
|
|
232
237
|
__bvt_recordCommand: async ({ frame, page, context }, event) => {
|
|
@@ -319,7 +324,7 @@ export class BVTRecorder {
|
|
|
319
324
|
process.env.CDP_LISTEN_PORT = this.#remoteDebuggerPort;
|
|
320
325
|
|
|
321
326
|
this.stepRunner.setRemoteDebugPort(this.#remoteDebuggerPort);
|
|
322
|
-
this.world = { attach: () => {
|
|
327
|
+
this.world = { attach: () => {} };
|
|
323
328
|
|
|
324
329
|
const ai_config_file = path.join(this.projectDir, "ai_config.json");
|
|
325
330
|
let ai_config = {};
|
|
@@ -707,7 +712,7 @@ export class BVTRecorder {
|
|
|
707
712
|
if (this.shouldTakeScreenshot) {
|
|
708
713
|
await this.storeScreenshot(event);
|
|
709
714
|
}
|
|
710
|
-
|
|
715
|
+
|
|
711
716
|
this.sendEvent(this.events.onNewCommand, cmdEvent);
|
|
712
717
|
this._updateUrlPath();
|
|
713
718
|
}
|
|
@@ -725,7 +730,7 @@ export class BVTRecorder {
|
|
|
725
730
|
}
|
|
726
731
|
async closeBrowser() {
|
|
727
732
|
delete process.env.TEMP_RUN;
|
|
728
|
-
await this.watcher.close().then(() => {
|
|
733
|
+
await this.watcher.close().then(() => {});
|
|
729
734
|
this.watcher = null;
|
|
730
735
|
this.previousIndex = null;
|
|
731
736
|
this.previousHistoryLength = null;
|
|
@@ -826,6 +831,7 @@ export class BVTRecorder {
|
|
|
826
831
|
};
|
|
827
832
|
|
|
828
833
|
this.bvtContext.navigate = true;
|
|
834
|
+
this.bvtContext.loadedRoutes = null;
|
|
829
835
|
for (const [key, value] of Object.entries(_env)) {
|
|
830
836
|
process.env[key] = value;
|
|
831
837
|
}
|
|
@@ -1017,52 +1023,6 @@ export class BVTRecorder {
|
|
|
1017
1023
|
return getCommandsForImplementedStep(stepName, step_definitions, stepParams).commands;
|
|
1018
1024
|
}
|
|
1019
1025
|
|
|
1020
|
-
parseRouteFiles(step) {
|
|
1021
|
-
const routeFolder = path.join(this.projectDir, "data", "routes");
|
|
1022
|
-
const templateRouteMap = new Map();
|
|
1023
|
-
|
|
1024
|
-
// Go over all the files in the route folder and parse them
|
|
1025
|
-
const routeFiles = readdirSync(routeFolder).filter((file) => file.endsWith(".json"));
|
|
1026
|
-
for (const file of routeFiles) {
|
|
1027
|
-
const filePath = path.join(routeFolder, file);
|
|
1028
|
-
const routeData = JSON.parse(readFileSync(filePath, "utf8"));
|
|
1029
|
-
if (routeData && routeData.template) {
|
|
1030
|
-
const template = routeData.template;
|
|
1031
|
-
const routes = routeData.routes;
|
|
1032
|
-
|
|
1033
|
-
templateRouteMap.set(template, routes);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
if (!existsSync(routeFolder)) {
|
|
1038
|
-
return null;
|
|
1039
|
-
} else if (step && step.text) {
|
|
1040
|
-
// Convert the step text to cucumber template
|
|
1041
|
-
const cucumberStep = new Step();
|
|
1042
|
-
cucumberStep.text = step.text;
|
|
1043
|
-
const template = cucumberStep.getTemplate();
|
|
1044
|
-
if (templateRouteMap.has(template)) {
|
|
1045
|
-
const routeItems = templateRouteMap.get(template);
|
|
1046
|
-
console.log("Route Items from template:", routeItems);
|
|
1047
|
-
routeItems.forEach((item) => {
|
|
1048
|
-
const filters = item.filters || {};
|
|
1049
|
-
const queryParams = filters?.queryParams || {};
|
|
1050
|
-
console.log("Query Params:", queryParams);
|
|
1051
|
-
const queryParamsArray = Object.keys(queryParams).map((key) => ({
|
|
1052
|
-
paramKey: key,
|
|
1053
|
-
paramValue: queryParams[key],
|
|
1054
|
-
}));
|
|
1055
|
-
console.log("Query Params Array:", queryParamsArray);
|
|
1056
|
-
filters.queryParams = queryParamsArray || [];
|
|
1057
|
-
});
|
|
1058
|
-
step.routeItems = routeItems;
|
|
1059
|
-
console.log("Route Items:", step.routeItems);
|
|
1060
|
-
} else {
|
|
1061
|
-
step.routeItems = null;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
1026
|
loadExistingScenario({ featureName, scenarioName }) {
|
|
1067
1027
|
const step_definitions = loadStepDefinitions(this.projectDir);
|
|
1068
1028
|
const featureFilePath = path.join(this.projectDir, "features", featureName);
|
|
@@ -1091,7 +1051,7 @@ export class BVTRecorder {
|
|
|
1091
1051
|
..._s,
|
|
1092
1052
|
keyword: step.keyword.trim(),
|
|
1093
1053
|
};
|
|
1094
|
-
this.
|
|
1054
|
+
parseRouteFiles(this.projectDir, _step);
|
|
1095
1055
|
steps.push(_step);
|
|
1096
1056
|
}
|
|
1097
1057
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from "@cucumber/gherkin";
|
|
2
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync } from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import url from "url";
|
|
5
5
|
import { findFilesWithExtension, StepsDefinitions } from "../cucumber/steps_definitions.js";
|
|
6
|
-
import { Feature } from "../cucumber/feature.js";
|
|
6
|
+
import { Feature, Step } from "../cucumber/feature.js";
|
|
7
7
|
import { CodePage } from "../code_gen/page_reflection.js";
|
|
8
8
|
import { getCommandsForImplementedStep, loadStepDefinitions } from "./step_utils.js";
|
|
9
9
|
import { parseStepTextParameters } from "../cucumber/utils.js";
|
|
@@ -57,6 +57,48 @@ function memorySizeOf(obj) {
|
|
|
57
57
|
return sizeOf(obj);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export function parseRouteFiles(projectDir, step) {
|
|
61
|
+
const routeFolder = path.join(projectDir, "data", "routes");
|
|
62
|
+
const templateRouteMap = new Map();
|
|
63
|
+
|
|
64
|
+
// Go over all the files in the route folder and parse them
|
|
65
|
+
const routeFiles = readdirSync(routeFolder).filter((file) => file.endsWith(".json"));
|
|
66
|
+
for (const file of routeFiles) {
|
|
67
|
+
const filePath = path.join(routeFolder, file);
|
|
68
|
+
const routeData = JSON.parse(readFileSync(filePath, "utf8"));
|
|
69
|
+
if (routeData && routeData.template) {
|
|
70
|
+
const template = routeData.template;
|
|
71
|
+
const routes = routeData.routes;
|
|
72
|
+
|
|
73
|
+
templateRouteMap.set(template, routes);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!existsSync(routeFolder)) {
|
|
78
|
+
return null;
|
|
79
|
+
} else if (step && step.text) {
|
|
80
|
+
// Convert the step text to cucumber template
|
|
81
|
+
const cucumberStep = new Step();
|
|
82
|
+
cucumberStep.text = step.text;
|
|
83
|
+
const template = cucumberStep.getTemplate();
|
|
84
|
+
if (templateRouteMap.has(template)) {
|
|
85
|
+
const routeItems = templateRouteMap.get(template);
|
|
86
|
+
routeItems.forEach((item) => {
|
|
87
|
+
const filters = item.filters || {};
|
|
88
|
+
const queryParams = filters?.queryParams || {};
|
|
89
|
+
const queryParamsArray = Object.keys(queryParams).map((key) => ({
|
|
90
|
+
paramKey: key,
|
|
91
|
+
paramValue: queryParams[key],
|
|
92
|
+
}));
|
|
93
|
+
filters.queryParams = queryParamsArray || [];
|
|
94
|
+
});
|
|
95
|
+
step.routeItems = routeItems;
|
|
96
|
+
} else {
|
|
97
|
+
step.routeItems = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
60
102
|
export const getImplementedSteps = async (projectDir) => {
|
|
61
103
|
const foundErrors = [];
|
|
62
104
|
try {
|
|
@@ -168,7 +210,10 @@ export const getImplementedSteps = async (projectDir) => {
|
|
|
168
210
|
}
|
|
169
211
|
stepLineSet.add(stepLine);
|
|
170
212
|
step.templateIndex = implementedSteps.length;
|
|
171
|
-
|
|
213
|
+
|
|
214
|
+
parseRouteFiles(projectDir, step);
|
|
215
|
+
|
|
216
|
+
const implementedStep = {
|
|
172
217
|
keyword: step.keyword.trim(),
|
|
173
218
|
keywordAlias: step.keywordAlias?.trim(),
|
|
174
219
|
text: updateStepText(template.pattern, step.parameters),
|
|
@@ -179,7 +224,10 @@ export const getImplementedSteps = async (projectDir) => {
|
|
|
179
224
|
templateIndex: step.templateIndex,
|
|
180
225
|
pattern: template.pattern,
|
|
181
226
|
paths: template.paths,
|
|
182
|
-
|
|
227
|
+
routeItems: step.routeItems,
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
implementedSteps.push(implementedStep);
|
|
183
231
|
}
|
|
184
232
|
}
|
|
185
233
|
|
|
@@ -186,6 +186,14 @@ export class BVTStepRunner {
|
|
|
186
186
|
// }
|
|
187
187
|
// }
|
|
188
188
|
// }
|
|
189
|
+
} else if (attachment.mediaType === "application/json+intercept-results" && attachment.body) {
|
|
190
|
+
const body = JSON.parse(attachment.body);
|
|
191
|
+
if (body) {
|
|
192
|
+
this.sendExecutionStatus({
|
|
193
|
+
type: "interceptResults",
|
|
194
|
+
interceptResults: body,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
}
|
|
191
199
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-blinq/cucumber_client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1326-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@cucumber/tag-expressions": "^6.1.1",
|
|
33
33
|
"@dev-blinq/cucumber-js": "1.0.178-dev",
|
|
34
34
|
"@faker-js/faker": "^8.1.0",
|
|
35
|
-
"automation_model": "1.0.
|
|
35
|
+
"automation_model": "1.0.780-dev",
|
|
36
36
|
"axios": "^1.7.4",
|
|
37
37
|
"chokidar": "^3.6.0",
|
|
38
38
|
"create-require": "^1.1.1",
|