@empiricalrun/test-gen 0.30.0 → 0.30.3
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 +21 -0
- package/dist/agent/codegen/run.d.ts.map +1 -1
- package/dist/agent/codegen/run.js +1 -1
- package/dist/agent/codegen/update-flow.d.ts.map +1 -1
- package/dist/agent/codegen/update-flow.js +1 -1
- package/dist/bin/utils/platform/web/index.d.ts +1 -1
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +2 -2
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/reporter/index.js +1 -0
- package/dist/uploader/index.d.ts.map +1 -1
- package/dist/uploader/index.js +4 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.30.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 76d50f7: chore: add logs for file upload
|
|
8
|
+
- 76d50f7: chore: add logs for file upload
|
|
9
|
+
|
|
10
|
+
## 0.30.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [0541f38]
|
|
15
|
+
- @empiricalrun/reporter@0.19.0
|
|
16
|
+
|
|
17
|
+
## 0.30.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- e07dd51: fix: remove redundant suites arg from stripAndPrependImports util
|
|
22
|
+
- 69f3aa9: fix: add test for injectCodeSnippetBySuiteChain util
|
|
23
|
+
|
|
3
24
|
## 0.30.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAuGrB"}
|
|
@@ -77,7 +77,7 @@ async function generateTest(testCase, file, options) {
|
|
|
77
77
|
logger.success("Test generated successfully!");
|
|
78
78
|
const readWriteFileSpan = trace.span({ name: "write-to-file" });
|
|
79
79
|
let contents = fs_extra_1.default.readFileSync(file, "utf-8");
|
|
80
|
-
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response, testCase?.name
|
|
80
|
+
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(response, testCase?.name);
|
|
81
81
|
let updatedContent = prependContent +
|
|
82
82
|
(0, web_1.injectCodeSnippetBySuiteChain)({
|
|
83
83
|
testFileContent: contents,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-flow.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/update-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAmB3B,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI7D,KAAK,eAAe,GAAG,QAAQ,GAAG;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;
|
|
1
|
+
{"version":3,"file":"update-flow.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/update-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAmB3B,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI7D,KAAK,eAAe,GAAG,QAAQ,GAAG;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAkHF,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,GAAE,OAAc,EACvB,QAAQ,GAAE,OAAc,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC,CAuF5B;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,KAAK,EACL,aAAoB,GACrB,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAiE7B"}
|
|
@@ -30,7 +30,7 @@ async function applyFileChanges({ validateTypes = true, trace, testCase, fileCha
|
|
|
30
30
|
// maintaining the previous accuracy of the test case update
|
|
31
31
|
const readWriteFileSpan = trace.span({ name: "write-to-file" });
|
|
32
32
|
let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
|
|
33
|
-
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name
|
|
33
|
+
const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name);
|
|
34
34
|
let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
|
|
35
35
|
const { testBlock } = (0, web_1.getTypescriptTestBlock)({
|
|
36
36
|
scenarioName: testCase?.name,
|
|
@@ -40,7 +40,7 @@ export declare function getTypescriptTestBlock({ scenarioName, suites, content,
|
|
|
40
40
|
export declare function findFirstSerialDescribeBlock(node: Node | undefined): Node | undefined;
|
|
41
41
|
export declare function appendToTestBlock(testBlock: string, content: string): string;
|
|
42
42
|
export declare function validateTypescript(filePath: string): string[];
|
|
43
|
-
export declare function stripAndPrependImports(content: string, testName: string
|
|
43
|
+
export declare function stripAndPrependImports(content: string, testName: string): Promise<(string | undefined)[]>;
|
|
44
44
|
export declare function lintErrors(filePath: string): Promise<void>;
|
|
45
45
|
export declare function formatCode(filePath: string): Promise<void>;
|
|
46
46
|
export declare function addNewImport(contents: string, modules: string[], pkg: string): string;
|
|
@@ -1 +1 @@
|
|
|
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,MA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,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"}
|
|
@@ -166,13 +166,13 @@ function validateTypescript(filePath) {
|
|
|
166
166
|
return errors;
|
|
167
167
|
}
|
|
168
168
|
exports.validateTypescript = validateTypescript;
|
|
169
|
-
async function stripAndPrependImports(content, testName
|
|
169
|
+
async function stripAndPrependImports(content, testName) {
|
|
170
170
|
const importRegexp = /import\s+\{[^}]*\}\s+from\s+["'][^"']+["'];?/g;
|
|
171
171
|
const imports = content.match(importRegexp);
|
|
172
172
|
const { testBlock: strippedContent } = getTypescriptTestBlock({
|
|
173
173
|
scenarioName: testName,
|
|
174
174
|
content,
|
|
175
|
-
suites,
|
|
175
|
+
suites: [], // since this method is called on the generated content, not the whole file
|
|
176
176
|
});
|
|
177
177
|
const prependContent = (imports?.join("\n") || "") + "\n\n";
|
|
178
178
|
return [prependContent, strippedContent];
|
|
@@ -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;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;
|
|
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;IA6CK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -51,6 +51,7 @@ class TestGenUpdatesReporter {
|
|
|
51
51
|
if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
|
|
52
52
|
logger.log("Skipped uploading generated test video");
|
|
53
53
|
}
|
|
54
|
+
console.log("Uploading assets for the test genearation");
|
|
54
55
|
const { videoUrls, traceFiles } = await (0, uploader_1.uploadTestResultsUsingPrjRepo)({
|
|
55
56
|
projectRepoName,
|
|
56
57
|
testName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAIpE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,UAErD;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAIpE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,UAErD;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,eAAe,EACf,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC,CA2DD;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
package/dist/uploader/index.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.getRelativeUploadPath = getRelativeUploadPath;
|
|
|
38
38
|
*/
|
|
39
39
|
async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
40
40
|
const uploadDir = getUploadPathForRun(projectRepoName);
|
|
41
|
+
console.log("Current directory for assets upload", process.cwd());
|
|
41
42
|
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
42
43
|
sourceDir: path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA),
|
|
43
44
|
destinationDir: uploadDir,
|
|
@@ -52,6 +53,7 @@ async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
|
52
53
|
});
|
|
53
54
|
// fileNames are relative upload paths
|
|
54
55
|
const fileNames = Object.keys(files);
|
|
56
|
+
console.log("FileNames to be uploaded", fileNames);
|
|
55
57
|
const defaultLocation = path_1.default.join(process.cwd(), "playwright-report", "summary.json");
|
|
56
58
|
const results = (0, reporter_1.parseJsonReport)(defaultLocation);
|
|
57
59
|
const flatTestsList = (0, reporter_1.getFlattenedTestList)(results.suites);
|
|
@@ -72,6 +74,8 @@ async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
|
|
|
72
74
|
}
|
|
73
75
|
const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm") && testAttachmentPaths.includes(fileName));
|
|
74
76
|
const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
|
|
77
|
+
console.log("videoFiles", videoFiles);
|
|
78
|
+
console.log("traceFiles", traceFiles);
|
|
75
79
|
return {
|
|
76
80
|
videoUrls: videoFiles
|
|
77
81
|
.map((fileName) => getFullUploadPath(fileName, uploadDir))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"ts-morph": "^23.0.0",
|
|
45
45
|
"tsx": "^4.16.2",
|
|
46
46
|
"typescript": "^5.3.3",
|
|
47
|
-
"@empiricalrun/
|
|
48
|
-
"@empiricalrun/
|
|
49
|
-
"@empiricalrun/
|
|
47
|
+
"@empiricalrun/reporter": "^0.19.0",
|
|
48
|
+
"@empiricalrun/r2-uploader": "^0.3.1",
|
|
49
|
+
"@empiricalrun/llm": "^0.9.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/detect-port": "^1.3.5",
|