@empiricalrun/test-gen 0.29.2 → 0.30.0
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/CHANGELOG.md +18 -0
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +6 -0
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +6 -1
- package/dist/bin/index.js +1 -0
- package/dist/bin/utils/platform/web/index.d.ts +5 -0
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +45 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/reporter/index.d.ts +1 -0
- package/dist/reporter/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c367dcb: feat: support nested new test-block creation via master agent
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 56f3d2f: feat: support nested new test-block creation via coding agent
|
|
12
|
+
|
|
13
|
+
## 0.29.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- c180953: fix: use test-case-id to get testCase detail
|
|
18
|
+
- Updated dependencies [c180953]
|
|
19
|
+
- @empiricalrun/reporter@0.18.5
|
|
20
|
+
|
|
3
21
|
## 0.29.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAYvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK5C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAsDD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,MAAM,CAAC,CA2CjB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAiBxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QA6BjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,CAAC,CA8CjB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,YAAiB,EACjB,IAAS,EACT,eAAoB,EACpB,gBAAqB,EACrB,UAAyC,GAC1C,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,8EASA"}
|
|
@@ -92,6 +92,12 @@ async function prepareFileForMasterAgent(genConfig) {
|
|
|
92
92
|
options: genConfig.options,
|
|
93
93
|
});
|
|
94
94
|
await fs_extra_1.default.writeFile(specPath, `${existingContents} \n\n ${newTestBlock}`, "utf-8");
|
|
95
|
+
const updatedContent = (0, web_1.injectCodeSnippetBySuiteChain)({
|
|
96
|
+
testFileContent: existingContents,
|
|
97
|
+
suites: testCase.suites,
|
|
98
|
+
codeSnippet: `\n\n${newTestBlock}`,
|
|
99
|
+
});
|
|
100
|
+
await fs_extra_1.default.writeFile(specPath, updatedContent, "utf-8");
|
|
95
101
|
}
|
|
96
102
|
await prepareFileForUpdateScenario(genConfig);
|
|
97
103
|
return specPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI7D,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAwGrB"}
|
|
@@ -78,7 +78,12 @@ async function generateTest(testCase, file, options) {
|
|
|
78
78
|
const readWriteFileSpan = trace.span({ name: "write-to-file" });
|
|
79
79
|
let contents = fs_extra_1.default.readFileSync(file, "utf-8");
|
|
80
80
|
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response, testCase?.name, []);
|
|
81
|
-
let updatedContent = prependContent +
|
|
81
|
+
let updatedContent = prependContent +
|
|
82
|
+
(0, web_1.injectCodeSnippetBySuiteChain)({
|
|
83
|
+
testFileContent: contents,
|
|
84
|
+
suites: testCase?.suites,
|
|
85
|
+
codeSnippet: `\n\n${strippedContent}`,
|
|
86
|
+
});
|
|
82
87
|
await fs_extra_1.default.writeFile(file, updatedContent, "utf-8");
|
|
83
88
|
readWriteFileSpan.end({ output: { updatedContent } });
|
|
84
89
|
logger.log("Linting generated code...");
|
package/dist/bin/index.js
CHANGED
|
@@ -52,6 +52,7 @@ async function runAgent(testGenConfig) {
|
|
|
52
52
|
}
|
|
53
53
|
const { testGenConfig } = await (0, utils_2.parseCliArgs)();
|
|
54
54
|
(0, reporter_1.setReporterConfig)({
|
|
55
|
+
testCaseId: testGenConfig.testCase.id,
|
|
55
56
|
testCaseName: testGenConfig.testCase.name,
|
|
56
57
|
testGroup: testGenConfig.testCase.group,
|
|
57
58
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
|
@@ -48,4 +48,9 @@ export declare function removeTestOnly(filePath: string): Promise<void>;
|
|
|
48
48
|
export declare function getFixtureImportPath(filePath: string): string;
|
|
49
49
|
export declare function getPageVariableNameFromCreateTest(filePath: string): Promise<string | undefined>;
|
|
50
50
|
export declare function replaceCreateTestWithNewCode(filePath: string, contents: string, generatedCode: string): string;
|
|
51
|
+
export declare const injectCodeSnippetBySuiteChain: ({ testFileContent, codeSnippet, suites, }: {
|
|
52
|
+
testFileContent: string;
|
|
53
|
+
codeSnippet: string;
|
|
54
|
+
suites: string[];
|
|
55
|
+
}) => string;
|
|
51
56
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,IAAI,EAIL,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAY,EACZ,MAAM,EACN,OAAO,GACR,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;CAC5B,CAuCA;AAwBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,IAAI,GAAG,SAAS,CA4BlB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CA8C7D;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,mCAWjB;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAShD;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,iBAQhD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,UAE5E;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,iBAMpD;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,UAcpD;AAED,wBAAsB,iCAAiC,CAAC,QAAQ,EAAE,MAAM,+BAmBvE;AAED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,UA0CtB;AAED,eAAO,MAAM,6BAA6B;qBAKvB,MAAM;iBACV,MAAM;YACX,MAAM,EAAE;YA2DjB,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.replaceCreateTestWithNewCode = exports.getPageVariableNameFromCreateTest = exports.getFixtureImportPath = exports.removeTestOnly = exports.addNewImport = exports.formatCode = exports.lintErrors = exports.stripAndPrependImports = exports.validateTypescript = exports.appendToTestBlock = exports.findFirstSerialDescribeBlock = exports.getTypescriptTestBlock = void 0;
|
|
6
|
+
exports.injectCodeSnippetBySuiteChain = exports.replaceCreateTestWithNewCode = exports.getPageVariableNameFromCreateTest = exports.getFixtureImportPath = exports.removeTestOnly = exports.addNewImport = exports.formatCode = exports.lintErrors = exports.stripAndPrependImports = exports.validateTypescript = exports.appendToTestBlock = exports.findFirstSerialDescribeBlock = exports.getTypescriptTestBlock = void 0;
|
|
7
7
|
const eslint_1 = require("eslint");
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
@@ -272,3 +272,47 @@ function replaceCreateTestWithNewCode(filePath, contents, generatedCode) {
|
|
|
272
272
|
return updatedTestFile;
|
|
273
273
|
}
|
|
274
274
|
exports.replaceCreateTestWithNewCode = replaceCreateTestWithNewCode;
|
|
275
|
+
const injectCodeSnippetBySuiteChain = ({ testFileContent, codeSnippet, suites, }) => {
|
|
276
|
+
const project = new ts_morph_1.Project();
|
|
277
|
+
// Add the source file content directly into memory
|
|
278
|
+
const sourceFile = project.createSourceFile("test-file.ts", testFileContent);
|
|
279
|
+
// Function to insert the test into the appropriate describe block
|
|
280
|
+
let parentNode = sourceFile;
|
|
281
|
+
if (!suites.length) {
|
|
282
|
+
parentNode.addStatements(codeSnippet);
|
|
283
|
+
return sourceFile.getFullText();
|
|
284
|
+
}
|
|
285
|
+
suites.forEach((suiteName, index) => {
|
|
286
|
+
// Try to find the describe block with the given name
|
|
287
|
+
let describeBlock = parentNode
|
|
288
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
|
|
289
|
+
.find((callExpr) => {
|
|
290
|
+
const expression = callExpr.getExpression();
|
|
291
|
+
const firstArg = callExpr?.getArguments()?.[0];
|
|
292
|
+
return (expression?.getText() === "test.describe" &&
|
|
293
|
+
firstArg?.getLiteralText() === suiteName);
|
|
294
|
+
});
|
|
295
|
+
// If the describe block doesn't exist, create it
|
|
296
|
+
if (!describeBlock) {
|
|
297
|
+
const newDescribe = `\n\ntest.describe("${suiteName}", () => {});`;
|
|
298
|
+
parentNode.addStatements(newDescribe);
|
|
299
|
+
describeBlock = parentNode
|
|
300
|
+
.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
|
|
301
|
+
.find((callExpr) => {
|
|
302
|
+
const expression = callExpr.getExpression();
|
|
303
|
+
const firstArg = callExpr?.getArguments()?.[0];
|
|
304
|
+
return (expression?.getText() === "test.describe" &&
|
|
305
|
+
firstArg?.getLiteralText() === suiteName);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
// If it's the last in the chain, add the test block inside this describe
|
|
309
|
+
if (index === suites.length - 1) {
|
|
310
|
+
const block = describeBlock?.getArguments()[1];
|
|
311
|
+
block.addStatements(codeSnippet);
|
|
312
|
+
}
|
|
313
|
+
// Update parentNode to navigate deeper into nested describe blocks
|
|
314
|
+
parentNode = describeBlock.getArguments()[1];
|
|
315
|
+
});
|
|
316
|
+
return sourceFile.getFullText();
|
|
317
|
+
};
|
|
318
|
+
exports.injectCodeSnippetBySuiteChain = injectCodeSnippetBySuiteChain;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAalC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAalC,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,iBA2BxD"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ async function createTest(task, page) {
|
|
|
19
19
|
const testConfigArg = process.env.TEST_GEN_TOKEN;
|
|
20
20
|
const { testGenConfig } = await (0, utils_1.parseCliArgs)(testConfigArg);
|
|
21
21
|
(0, reporter_1.setReporterConfig)({
|
|
22
|
+
testCaseId: testGenConfig.testCase.id,
|
|
22
23
|
testCaseName: testGenConfig.testCase.name,
|
|
23
24
|
testGroup: testGenConfig.testCase.group,
|
|
24
25
|
projectRepoName: testGenConfig.options?.metadata.projectRepoName,
|
package/dist/reporter/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":";AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":";AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IA4CK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"tsx": "^4.16.2",
|
|
46
46
|
"typescript": "^5.3.3",
|
|
47
47
|
"@empiricalrun/llm": "^0.9.2",
|
|
48
|
-
"@empiricalrun/
|
|
49
|
-
"@empiricalrun/
|
|
48
|
+
"@empiricalrun/reporter": "^0.18.5",
|
|
49
|
+
"@empiricalrun/r2-uploader": "^0.3.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/detect-port": "^1.3.5",
|