@dev-blinq/cucumber_client 1.0.1728-dev → 1.0.1729-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.
|
@@ -147,7 +147,7 @@ export class NamesService {
|
|
|
147
147
|
}
|
|
148
148
|
return result.data;
|
|
149
149
|
}
|
|
150
|
-
async generateLocatorDescriptions({ locatorsObj }) {
|
|
150
|
+
async generateLocatorDescriptions({ locatorsObj, }) {
|
|
151
151
|
const url = `${getRunsServiceBaseURL()}/locate/generate_locator_summaries`;
|
|
152
152
|
const result = await axiosClient({
|
|
153
153
|
url,
|
|
@@ -172,6 +172,7 @@ export class PublishService {
|
|
|
172
172
|
constructor(TOKEN) {
|
|
173
173
|
this.TOKEN = TOKEN;
|
|
174
174
|
}
|
|
175
|
+
//! deprecated
|
|
175
176
|
async saveScenario({ scenario, featureName, override, branch, isEditing, projectId, env, AICode }) {
|
|
176
177
|
const runsURL = getRunsServiceBaseURL();
|
|
177
178
|
const workspaceURL = runsURL.replace("/runs", "/workspace");
|
|
@@ -863,87 +863,104 @@ export async function executeStep({ stepsDefinitions, cucumberStep, context, cod
|
|
|
863
863
|
throw new Error(`Step definition not found for "${cucumberStep.text}"`);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
|
|
866
|
+
class DomainError extends Error {
|
|
867
|
+
constructor(message) {
|
|
868
|
+
super(message);
|
|
869
|
+
this.name = this.constructor.name;
|
|
870
|
+
this.statusCode = 500; // default, can override in subclasses
|
|
871
|
+
if (typeof Object.setPrototypeOf === "function") {
|
|
872
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
867
876
|
export async function updateStepDefinitions({ scenario, featureName, projectDir, logger }) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
}
|
|
875
|
-
const utilsTemplateFilePath = path.join(__dirname, "../../assets", "templates", "utils_template.txt");
|
|
876
|
-
const utilsContent = readFileSync(utilsTemplateFilePath, "utf8");
|
|
877
|
-
writeFileSync(utilsFilePath, utilsContent, "utf8");
|
|
878
|
-
const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
|
|
879
|
-
if (existsSync(hooksTemplateFilePath)) {
|
|
880
|
-
const hooksFilePath = path.join(stepDefinitionFolderPath, "_hooks.mjs");
|
|
881
|
-
const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
|
|
882
|
-
writeFileSync(hooksFilePath, hooksContent, "utf8");
|
|
883
|
-
}
|
|
884
|
-
const steps = scenario.steps;
|
|
877
|
+
try {
|
|
878
|
+
const utilsFilePath = path.join(projectDir, "features", "step_definitions", "utils.mjs");
|
|
879
|
+
const stepDefinitionFolderPath = path.join(projectDir, "features", "step_definitions");
|
|
880
|
+
if (!existsSync(stepDefinitionFolderPath)) {
|
|
881
|
+
mkdirSync(stepDefinitionFolderPath, { recursive: true });
|
|
882
|
+
}
|
|
885
883
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
step.isImplementedWhileRecording = true;
|
|
896
|
-
}
|
|
884
|
+
const utilsTemplateFilePath = path.join(__dirname, "../../assets", "templates", "utils_template.txt");
|
|
885
|
+
const utilsContent = readFileSync(utilsTemplateFilePath, "utf8");
|
|
886
|
+
writeFileSync(utilsFilePath, utilsContent, "utf8");
|
|
887
|
+
|
|
888
|
+
const hooksTemplateFilePath = path.join(__dirname, "../../assets", "templates", "_hooks_template.txt");
|
|
889
|
+
if (existsSync(hooksTemplateFilePath)) {
|
|
890
|
+
const hooksFilePath = path.join(stepDefinitionFolderPath, "_hooks.mjs");
|
|
891
|
+
const hooksContent = readFileSync(hooksTemplateFilePath, "utf8");
|
|
892
|
+
writeFileSync(hooksFilePath, hooksContent, "utf8");
|
|
897
893
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
894
|
+
|
|
895
|
+
const steps = scenario.steps;
|
|
896
|
+
const stepsDefinitions = new StepsDefinitions(projectDir);
|
|
897
|
+
const featureFolder = path.join(projectDir, "features");
|
|
898
|
+
|
|
899
|
+
stepsDefinitions.load(false);
|
|
900
|
+
|
|
901
|
+
for (const step of steps) {
|
|
902
|
+
if (step.internalImplementedStepId) {
|
|
903
|
+
const si = steps.findIndex((s) => s.id === step.internalImplementedStepId);
|
|
904
|
+
if (si !== -1) {
|
|
905
|
+
step.isImplementedWhileRecording = true;
|
|
904
906
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
if (!step.isUtilStep && ((step.isImplemented && !step.shouldOverride) || step.commands.length === 0)) {
|
|
910
|
+
let routesPath = path.join(tmpdir(), `blinq_temp_routes`);
|
|
911
|
+
if (process.env.TEMP_RUN === "true") {
|
|
912
|
+
if (existsSync(routesPath)) rmSync(routesPath, { recursive: true });
|
|
913
|
+
mkdirSync(routesPath, { recursive: true });
|
|
914
|
+
saveRoutes({ step, folderPath: routesPath }, logger);
|
|
915
|
+
} else {
|
|
916
|
+
if (existsSync(routesPath)) {
|
|
917
|
+
try {
|
|
918
|
+
rmSync(routesPath, { recursive: true });
|
|
919
|
+
} catch (error) {
|
|
920
|
+
logger.error(`❌ Error removing temp routes folder: ${getErrorMessage(error)}`);
|
|
921
|
+
}
|
|
913
922
|
}
|
|
923
|
+
routesPath = path.join(projectDir, "data", "routes");
|
|
924
|
+
if (!existsSync(routesPath)) mkdirSync(routesPath, { recursive: true });
|
|
925
|
+
saveRoutes({ step, folderPath: routesPath }, logger);
|
|
914
926
|
}
|
|
915
|
-
|
|
916
|
-
if (
|
|
917
|
-
|
|
927
|
+
|
|
928
|
+
if (step.commands && Array.isArray(step.commands)) {
|
|
929
|
+
step.commands = step.commands.map((cmd) => toRecordingStep(cmd, scenario.parametersMap));
|
|
918
930
|
}
|
|
919
|
-
|
|
931
|
+
|
|
932
|
+
continue;
|
|
920
933
|
}
|
|
921
|
-
|
|
922
|
-
|
|
934
|
+
|
|
935
|
+
const cucumberStep = getCucumberStep({ step });
|
|
936
|
+
const pageName = generatePageName(step.startFrame?.url ?? "default", step.isUtilStep);
|
|
937
|
+
const stepDefsFilePath = locateDefinitionPath(featureFolder, pageName);
|
|
938
|
+
let codePage = getCodePage(stepDefsFilePath);
|
|
939
|
+
|
|
940
|
+
codePage = await saveRecording({
|
|
941
|
+
step,
|
|
942
|
+
cucumberStep,
|
|
943
|
+
codePage,
|
|
944
|
+
projectDir,
|
|
945
|
+
stepsDefinitions,
|
|
946
|
+
parametersMap: scenario.parametersMap,
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
if (!codePage) continue;
|
|
950
|
+
|
|
951
|
+
const res = await codePage.save();
|
|
952
|
+
if (!res) {
|
|
953
|
+
throw new DomainError(
|
|
954
|
+
`Failed to save step definition for "${cucumberStep.text}" in "${codePage.sourceFileName}"`
|
|
955
|
+
);
|
|
923
956
|
}
|
|
924
|
-
continue;
|
|
925
|
-
}
|
|
926
|
-
const cucumberStep = getCucumberStep({ step });
|
|
927
|
-
const pageName = generatePageName(step.startFrame?.url ?? "default", step.isUtilStep);
|
|
928
|
-
const stepDefsFilePath = locateDefinitionPath(featureFolder, pageName);
|
|
929
|
-
let codePage = getCodePage(stepDefsFilePath);
|
|
930
|
-
codePage = await saveRecording({
|
|
931
|
-
step,
|
|
932
|
-
cucumberStep,
|
|
933
|
-
codePage,
|
|
934
|
-
projectDir,
|
|
935
|
-
stepsDefinitions,
|
|
936
|
-
parametersMap: scenario.parametersMap,
|
|
937
|
-
});
|
|
938
|
-
if (!codePage) {
|
|
939
|
-
continue;
|
|
940
|
-
}
|
|
941
|
-
const res = await codePage.save();
|
|
942
|
-
if (!res) {
|
|
943
|
-
throw new Error(`Failed to save step definition for "${cucumberStep.text}" in "${codePage.sourceFileName}"`);
|
|
944
957
|
}
|
|
958
|
+
|
|
959
|
+
writeFileSync(utilsFilePath, utilsContent, "utf8");
|
|
960
|
+
} catch (error) {
|
|
961
|
+
logger.error(`❌ updateStepDefinitions() failed: ${error?.message ?? String(error)}`);
|
|
962
|
+
throw error instanceof DomainError ? error : new DomainError(error?.message ?? "Unknown error");
|
|
945
963
|
}
|
|
946
|
-
writeFileSync(utilsFilePath, utilsContent, "utf8");
|
|
947
964
|
}
|
|
948
965
|
|
|
949
966
|
export function saveRoutes({ step, folderPath }, logger) {
|