@empiricalrun/test-gen 0.17.5 → 0.18.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 +13 -0
- package/dist/bin/index.js +1 -0
- package/dist/reporter/index.d.ts +2 -1
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/reporter/index.js +3 -2
- package/dist/uploader/index.d.ts +10 -5
- package/dist/uploader/index.d.ts.map +1 -1
- package/dist/uploader/index.js +31 -9
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4390c31: fix: filter video based on test name
|
|
8
|
+
|
|
9
|
+
## 0.17.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [7b00d84]
|
|
14
|
+
- @empiricalrun/reporter@0.12.2
|
|
15
|
+
|
|
3
16
|
## 0.17.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/bin/index.js
CHANGED
|
@@ -29,6 +29,7 @@ async function runAgent(sourceFile, testGenConfig) {
|
|
|
29
29
|
await (0, run_1.generateTestsUsingBrowsingAgent)(specPath);
|
|
30
30
|
await (0, reporter_1.reportTestGenVideos)({
|
|
31
31
|
projectRepoName: testGenConfig.options.metadata.projectRepoName,
|
|
32
|
+
testName: testCase.name,
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
else {
|
package/dist/reporter/index.d.ts
CHANGED
|
@@ -10,8 +10,9 @@ export declare function getReporter(): Reporter | undefined;
|
|
|
10
10
|
* }
|
|
11
11
|
* @returns Promise<void> returns void
|
|
12
12
|
*/
|
|
13
|
-
export declare function reportTestGenVideos({ projectRepoName, }: {
|
|
13
|
+
export declare function reportTestGenVideos({ projectRepoName, testName, }: {
|
|
14
14
|
projectRepoName: string;
|
|
15
|
+
testName: string;
|
|
15
16
|
}): Promise<void>;
|
|
16
17
|
export declare function setReporterConfig(config: any): void;
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAW5E,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAW5E,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,eAAe,EACf,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBA6BA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAGnD"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.getReporter = getReporter;
|
|
|
28
28
|
* }
|
|
29
29
|
* @returns Promise<void> returns void
|
|
30
30
|
*/
|
|
31
|
-
async function reportTestGenVideos({ projectRepoName, }) {
|
|
31
|
+
async function reportTestGenVideos({ projectRepoName, testName, }) {
|
|
32
32
|
const logger = new logger_1.CustomLogger();
|
|
33
33
|
try {
|
|
34
34
|
if (!(0, uploader_1.checkIfResultsUploadAllowed)()) {
|
|
@@ -36,6 +36,7 @@ async function reportTestGenVideos({ projectRepoName, }) {
|
|
|
36
36
|
}
|
|
37
37
|
const { videoUrls } = await (0, uploader_1.uploadTestResultsUsingPrjtRepo)({
|
|
38
38
|
projectRepoName,
|
|
39
|
+
testName,
|
|
39
40
|
});
|
|
40
41
|
const reporter = getReporter();
|
|
41
42
|
const reporterMessage = `
|
|
@@ -44,7 +45,7 @@ async function reportTestGenVideos({ projectRepoName, }) {
|
|
|
44
45
|
|
|
45
46
|
${videoUrls
|
|
46
47
|
.map((url) => `
|
|
47
|
-
<video src="${url}" autoplay="true" muted="true" controls
|
|
48
|
+
<video src="${url}" autoplay="true" muted="true" controls playsinline></video>`)
|
|
48
49
|
.join("\n")}
|
|
49
50
|
`;
|
|
50
51
|
await reporter?.report(new reporter_1.ProcessLogMessageBuilder({ message: reporterMessage }));
|
package/dist/uploader/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param {
|
|
5
|
-
* @
|
|
2
|
+
* Function to upload test results to R2 using the project repo name and test name.
|
|
3
|
+
* This function uploads both the JSON summary of test results and associated video files.
|
|
4
|
+
* @param {Object} params - The parameters for the function.
|
|
5
|
+
* @param {string} params.projectRepoName - Name of the project repository.
|
|
6
|
+
* @param {string} params.testName - Name of the testcase which called this test-gen.
|
|
7
|
+
* @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
|
|
8
|
+
* @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
|
|
9
|
+
* @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
|
|
6
10
|
*/
|
|
7
|
-
export declare function uploadTestResultsUsingPrjtRepo({ projectRepoName, }: {
|
|
11
|
+
export declare function uploadTestResultsUsingPrjtRepo({ projectRepoName, testName, }: {
|
|
8
12
|
projectRepoName: string;
|
|
13
|
+
testName: string;
|
|
9
14
|
}): Promise<{
|
|
10
15
|
videoUrls: string[];
|
|
11
16
|
summaryUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAAC,EACnD,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;CACpB,CAAC,CAgDD;AAED,wBAAgB,2BAA2B,uBAQ1C"}
|
package/dist/uploader/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkIfResultsUploadAllowed = exports.uploadTestResultsUsingPrjtRepo = void 0;
|
|
7
|
+
const reporter_1 = require("@empiricalrun/reporter");
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const r2_1 = require("./r2");
|
|
9
10
|
// json summary of test results
|
|
@@ -15,12 +16,16 @@ function getFullUploadPath(filePath, uploadDir) {
|
|
|
15
16
|
return `${UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @
|
|
19
|
+
* Function to upload test results to R2 using the project repo name and test name.
|
|
20
|
+
* This function uploads both the JSON summary of test results and associated video files.
|
|
21
|
+
* @param {Object} params - The parameters for the function.
|
|
22
|
+
* @param {string} params.projectRepoName - Name of the project repository.
|
|
23
|
+
* @param {string} params.testName - Name of the testcase which called this test-gen.
|
|
24
|
+
* @returns {Promise<Object>} An object containing arrays of video URLs and the summary JSON URL.
|
|
25
|
+
* @returns {string[]} returns.videoUrls - URLs of the uploaded video files.
|
|
26
|
+
* @returns {string} returns.summaryUrl - URL of the uploaded summary JSON file.
|
|
22
27
|
*/
|
|
23
|
-
async function uploadTestResultsUsingPrjtRepo({ projectRepoName, }) {
|
|
28
|
+
async function uploadTestResultsUsingPrjtRepo({ projectRepoName, testName, }) {
|
|
24
29
|
const uploadUniqueId = crypto.randomUUID();
|
|
25
30
|
// project repo name is the github repo name
|
|
26
31
|
// the folder names in r2 are the github repo name without the `-tests` suffix
|
|
@@ -30,12 +35,29 @@ async function uploadTestResultsUsingPrjtRepo({ projectRepoName, }) {
|
|
|
30
35
|
destinationDir: uploadDir,
|
|
31
36
|
uploadBucket: UPLOAD_BUCKET,
|
|
32
37
|
});
|
|
33
|
-
const fileNames = Object.keys(files);
|
|
34
|
-
|
|
38
|
+
const fileNames = Object.keys(files); // fileNames are absolute paths of the input files
|
|
39
|
+
const defaultLocation = path_1.default.join(process.cwd(), "test-results", "summary.json");
|
|
40
|
+
const results = (0, reporter_1.parseJsonReport)(defaultLocation);
|
|
41
|
+
const flatTestsList = (0, reporter_1.getFlattenedTestList)(results.suites);
|
|
42
|
+
const testVideos = [];
|
|
43
|
+
for (const test of flatTestsList) {
|
|
44
|
+
if (test.title === testName) {
|
|
45
|
+
if (test.tests[0]) {
|
|
46
|
+
if (test.tests[0].results[0]) {
|
|
47
|
+
// results array is basically made by retries
|
|
48
|
+
for (const attachments of test.tests[0].results[0].attachments) {
|
|
49
|
+
if (attachments.path) {
|
|
50
|
+
testVideos.push(attachments.path);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
35
57
|
// current assumption
|
|
36
58
|
// - test gen will only run on a single spec file
|
|
37
|
-
// - the video files
|
|
38
|
-
const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm"));
|
|
59
|
+
// - the video files are of the format - <some-directory>/video.webm
|
|
60
|
+
const videoFiles = fileNames.filter((fileName) => fileName.endsWith(".webm") && testVideos.includes(fileName));
|
|
39
61
|
return {
|
|
40
62
|
videoUrls: videoFiles.map((fileName) => getFullUploadPath(fileName, uploadDir)),
|
|
41
63
|
summaryUrl: getFullUploadPath("/test-results/summary.json", uploadDir),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@actions/core": "^1.10.1",
|
|
19
19
|
"@aws-sdk/client-s3": "^3.614.0",
|
|
20
20
|
"@aws-sdk/s3-request-presigner": "^3.614.0",
|
|
21
|
+
"@playwright/test": "^1.44.1",
|
|
21
22
|
"@types/sanitize-html": "^2.11.0",
|
|
22
23
|
"commander": "^12.1.0",
|
|
23
24
|
"detect-port": "^1.6.1",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"tsx": "^4.16.2",
|
|
41
42
|
"typescript": "^5.3.3",
|
|
42
43
|
"@empiricalrun/llm": "^0.3.0",
|
|
43
|
-
"@empiricalrun/reporter": "^0.12.
|
|
44
|
+
"@empiricalrun/reporter": "^0.12.2"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/detect-port": "^1.3.5",
|