@detiq/crawler 1.1.16 → 1.1.17
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/dist/job-queue.js +13 -4
- package/dist/job-queue.js.map +2 -2
- package/package.json +1 -1
- package/src/job-queue.ts +17 -4
package/package.json
CHANGED
package/src/job-queue.ts
CHANGED
|
@@ -3092,7 +3092,7 @@ async function processCreatePRJob(jobId: string, config: any) {
|
|
|
3092
3092
|
const { decrypt } = await import('@detiq/core');
|
|
3093
3093
|
const token = decrypt(conn.tokenEnc);
|
|
3094
3094
|
|
|
3095
|
-
const { pushScriptsAsPR } = await import('@detiq/agents');
|
|
3095
|
+
const { pushScriptsAsPR, getFileContent, mergeSpecContent } = await import('@detiq/agents');
|
|
3096
3096
|
|
|
3097
3097
|
const framework = conn.detectedFramework ?? 'playwright-ts';
|
|
3098
3098
|
|
|
@@ -3117,11 +3117,24 @@ async function processCreatePRJob(jobId: string, config: any) {
|
|
|
3117
3117
|
|
|
3118
3118
|
if (scripts.length === 0) throw new Error('No generated scripts found to push.');
|
|
3119
3119
|
|
|
3120
|
-
|
|
3120
|
+
// For each file, check if it already exists in the repo and merge if so
|
|
3121
|
+
const files = await Promise.all(scripts.map(async (s: any) => {
|
|
3121
3122
|
const path = s.testCase?.repoTargetPath
|
|
3122
3123
|
?? deriveFallbackTargetPath(s.testCase?.ref ?? s.testCase?.title ?? s.id, framework);
|
|
3123
|
-
|
|
3124
|
-
|
|
3124
|
+
let content = s.code;
|
|
3125
|
+
|
|
3126
|
+
// Spec files: attempt to merge with existing content
|
|
3127
|
+
const isSpecFile = /\.(spec|test|cy)\.(ts|js|py|java)$/.test(path) || /_test\.py$/.test(path);
|
|
3128
|
+
if (isSpecFile) {
|
|
3129
|
+
const existing = await getFileContent(token, conn.repoFullName, path, conn.defaultBranch).catch(() => null);
|
|
3130
|
+
if (existing && existing.trim().length > 0) {
|
|
3131
|
+
logger.info({ path }, '[create-pr] merging new tests into existing spec file');
|
|
3132
|
+
content = mergeSpecContent(existing, s.code);
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
return { path, content };
|
|
3137
|
+
}));
|
|
3125
3138
|
|
|
3126
3139
|
if (files.length === 0) throw new Error('No scripts to push.');
|
|
3127
3140
|
|