@empiricalrun/test-gen 0.23.3 → 0.23.5

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.23.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d954fd: feat: use custom playwright reporter
8
+ - Updated dependencies [6d954fd]
9
+ - @empiricalrun/reporter@0.17.7
10
+
11
+ ## 0.23.4
12
+
13
+ ### Patch Changes
14
+
15
+ - d1068e6: fix: multiple session details call and missing generation id in requests
16
+ - Updated dependencies [d1068e6]
17
+ - @empiricalrun/reporter@0.17.6
18
+
3
19
  ## 0.23.3
4
20
 
5
21
  ### Patch Changes
@@ -19,6 +19,7 @@ async function generateTestsUsingBrowsingAgent(testFilePath) {
19
19
  const fileService = new server_1.FileService({ port });
20
20
  await fileService.startFileService();
21
21
  fileService.setFilePath(testFilePath);
22
+ // read playwright config from ./playwright.config.ts of source repo
22
23
  const playwrightConfig = await (0, utils_2.readPlaywrightConfig)();
23
24
  const project = await (0, utils_2.detectProjectName)(testFilePath, playwrightConfig);
24
25
  logger.log(`Detected playwright project name: ${project}`);
@@ -39,7 +40,6 @@ async function generateTestsUsingBrowsingAgent(testFilePath) {
39
40
  catch (e) {
40
41
  logger.error(e);
41
42
  await new reporter_1.TestGenUpdatesReporter().sendMessage(e);
42
- process.exit(1);
43
43
  }
44
44
  await (0, web_1.removeTestOnly)(testFilePath);
45
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAMpE;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,CAoDD;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uploader/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAUpE;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,CAmED;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,UAM1D;AAED,wBAAgB,2BAA2B,uBAQ1C"}
@@ -8,12 +8,20 @@ const reporter_1 = require("@empiricalrun/reporter");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const r2_1 = require("./r2");
10
10
  // json summary of test results
11
- const TEST_RESULTS_DIR = "test-results";
11
+ // originally we used to upload test results directory for this
12
+ // but now we have our test results (per testcase artifacts) inside playwright-report/data
13
+ // but we also have summary.json in playwright-report/
14
+ // we can avoid html report upload here if we don't want
15
+ const PLAYWRIGHT_REPORT_DATA = "playwright-report/data";
12
16
  exports.UPLOAD_BUCKET = "test-report";
13
17
  exports.UPLOAD_DOMAIN = "https://reports.empirical.run"; // domain based on bucket mentioned above
14
18
  const uploadId = crypto.randomUUID();
15
19
  function getFullUploadPath(filePath, uploadDir) {
16
- const relativeFilePath = filePath.replace(path_1.default.join(process.cwd(), TEST_RESULTS_DIR), "");
20
+ // remove the source dir from the file path - only keep the relative path
21
+ // old path for data: ~/source-repo/test-results/testName/
22
+ // new path for data: ~/source-repo/playwright-report/data/testName
23
+ const relativeFilePath = filePath.replace(path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA), "");
24
+ // new relativeFilePath will look like
17
25
  return `${exports.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
18
26
  }
19
27
  exports.getFullUploadPath = getFullUploadPath;
@@ -29,14 +37,27 @@ exports.getFullUploadPath = getFullUploadPath;
29
37
  */
30
38
  async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
31
39
  // project repo name is the github repo name
40
+ // test-generation/<project-name>/<random-uuid>
32
41
  const uploadDir = getUploadPathForRun(projectRepoName);
42
+ // upload test assets
33
43
  const files = await (0, r2_1.uploadDirectory)({
34
- sourceDir: path_1.default.join(process.cwd(), TEST_RESULTS_DIR),
44
+ // ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
45
+ sourceDir: path_1.default.join(process.cwd(), PLAYWRIGHT_REPORT_DATA), // upload data dir
46
+ destinationDir: uploadDir,
47
+ uploadBucket: exports.UPLOAD_BUCKET,
48
+ });
49
+ // upload summary.json
50
+ await (0, r2_1.uploadDirectory)({
51
+ // ~/source-repo/playwright-report -> has index.html, data, trace(they are assets for index.html, not sure why they are called trace), and summary.json
52
+ sourceDir: path_1.default.join(process.cwd(), "playwright-report"), // upload data dir
53
+ fileList: [path_1.default.join(process.cwd(), "playwright-report", "summary.json")],
35
54
  destinationDir: uploadDir,
36
55
  uploadBucket: exports.UPLOAD_BUCKET,
37
56
  });
38
57
  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");
58
+ // old default location: ..../source-repo/test-results/summary.json
59
+ // new default location: ..../source-repo/playwright-report/summary.json
60
+ const defaultLocation = path_1.default.join(process.cwd(), "playwright-report", "summary.json");
40
61
  const results = (0, reporter_1.parseJsonReport)(defaultLocation);
41
62
  const flatTestsList = (0, reporter_1.getFlattenedTestList)(results.suites);
42
63
  const testAttachmentPaths = [];
@@ -61,7 +82,9 @@ async function uploadTestResultsUsingPrjRepo({ projectRepoName, testName, }) {
61
82
  const traceFiles = fileNames.filter((fileName) => fileName.endsWith(".zip") && testAttachmentPaths.includes(fileName));
62
83
  return {
63
84
  videoUrls: videoFiles.map((fileName) => getFullUploadPath(fileName, uploadDir)),
64
- summaryUrl: getFullUploadPath("/test-results/summary.json", uploadDir),
85
+ // uploaded separately
86
+ summaryUrl: `${exports.UPLOAD_DOMAIN}/${uploadDir}/summary.json`,
87
+ // summaryUrl: getFullUploadPath("/test-results/summary.json", uploadDir),
65
88
  traceFiles: traceFiles.map((fileName) => getFullUploadPath(fileName, uploadDir)),
66
89
  };
67
90
  }
@@ -1,8 +1,9 @@
1
1
  interface FileMap {
2
2
  [file: string]: string;
3
3
  }
4
- export declare function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }: {
4
+ export declare function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }: {
5
5
  sourceDir: string;
6
+ fileList?: string[];
6
7
  destinationDir: string;
7
8
  uploadBucket: string;
8
9
  }): Promise<FileMap>;
@@ -1 +1 @@
1
- {"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/uploader/r2.ts"],"names":[],"mappings":"AAqBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAsGD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnB"}
1
+ {"version":3,"file":"r2.d.ts","sourceRoot":"","sources":["../../src/uploader/r2.ts"],"names":[],"mappings":"AAsBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA2GD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
@@ -60,7 +60,14 @@ const run = async (config) => {
60
60
  secretAccessKey: config.secretAccessKey,
61
61
  },
62
62
  });
63
- const files = getFileList(config.sourceDir);
63
+ let files;
64
+ if (config.fileList) {
65
+ console.log("uploading single file: ", config.fileList[0]);
66
+ files = config.fileList;
67
+ }
68
+ else {
69
+ files = getFileList(config.sourceDir);
70
+ }
64
71
  await Promise.all(files.map(async (file) => {
65
72
  console.log(file);
66
73
  const fileStream = fs.readFileSync(file);
@@ -115,7 +122,7 @@ const run = async (config) => {
115
122
  }));
116
123
  return urls;
117
124
  };
118
- async function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }) {
125
+ async function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }) {
119
126
  let config = {
120
127
  accountId: process.env.R2_ACCOUNT_ID,
121
128
  accessKeyId: process.env.R2_ACCESS_KEY_ID,
@@ -123,6 +130,7 @@ async function uploadDirectory({ sourceDir, destinationDir, uploadBucket, }) {
123
130
  bucket: uploadBucket,
124
131
  sourceDir,
125
132
  destinationDir,
133
+ fileList,
126
134
  };
127
135
  const uploadedFiles = await run(config);
128
136
  return uploadedFiles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.23.3",
3
+ "version": "0.23.5",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -42,7 +42,7 @@
42
42
  "tsx": "^4.16.2",
43
43
  "typescript": "^5.3.3",
44
44
  "@empiricalrun/llm": "^0.7.3",
45
- "@empiricalrun/reporter": "^0.17.5"
45
+ "@empiricalrun/reporter": "^0.17.7"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/detect-port": "^1.3.5",