@empiricalrun/playwright-utils 0.18.18 → 0.18.20

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,19 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.18.20
4
+
5
+ ### Patch Changes
6
+
7
+ - b99ba96: fix: removed logger import from r2-uploader
8
+
9
+ ## 0.18.19
10
+
11
+ ### Patch Changes
12
+
13
+ - 96f7acc: fix: replaced unsigned asset urls with public url
14
+ - Updated dependencies [e85633b]
15
+ - @empiricalrun/test-gen@0.38.44
16
+
3
17
  ## 0.18.18
4
18
 
5
19
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/reporter/custom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAMV,KAAK,EACL,QAAQ,IAAI,cAAc,EAC1B,SAAS,EACT,UAAU,IAAI,gBAAgB,EAE/B,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAML,UAAU,EAMX,MAAM,2BAA2B,CAAC;AAkBnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAsC/C,QAAA,MAAM,iBAAiB,UAAoC,CAAC;AAC5D,KAAK,oBAAoB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAM/D,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,aAAa,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,CAAC,mBAAmB,CAAqB;IAEhD,OAAO,CAAC,YAAY,CAEN;IACd,OAAO,CAAC,eAAe,CAAmB;gBAE9B,OAAO,EAAE,mBAAmB;IAIxC,aAAa;IAIb,QAAQ;IAER,QAAQ;IAER,WAAW;IAEX,SAAS;IAET,WAAW,CAAC,IAAI,EAAE,cAAc;IAIhC,OAAO,IAAI,IAAI;IAIf,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB;YA4D1C,qBAAqB;IA+BnC,WAAW,CAAC,MAAM,EAAE,UAAU;IAI9B,OAAO,CAAC,KAAK,EAAE,KAAK;IAYpB,eAAe,IAAI;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,oBAAoB,CAAC;QAC3B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1B;IAsBD,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IASxD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAIzB,KAAK,CAAC,MAAM,EAAE,UAAU;IA8FxB,MAAM;CA8Bb;AAwED,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,GAAE,MAAoB,EAC1B,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,iBAqBhB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAsBhE;AAsiBD,eAAe,YAAY,CAAC"}
@@ -22,7 +22,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.startHtmlReportServer = exports.showHTMLReport = void 0;
24
24
  const code_frame_1 = require("@babel/code-frame");
25
- const r2_uploader_1 = require("@empiricalrun/r2-uploader");
26
25
  const crypto_1 = require("crypto");
27
26
  const fs_1 = __importDefault(require("fs"));
28
27
  const path_1 = __importDefault(require("path"));
@@ -35,6 +34,7 @@ const stream_1 = require("stream");
35
34
  const logger_1 = require("../logger");
36
35
  const base_1 = require("./base");
37
36
  const queue_1 = require("./queue");
37
+ const uploader_1 = require("./uploader");
38
38
  const util_1 = require("./util");
39
39
  const htmlReportOptions = ["always", "never", "on-failure"];
40
40
  const isHtmlReportOption = (type) => {
@@ -63,7 +63,6 @@ function listFilesRecursively(dir) {
63
63
  }
64
64
  return files;
65
65
  }
66
- const R2_BUCKET_NAME = "test-report";
67
66
  class HtmlReporter {
68
67
  config;
69
68
  suite;
@@ -162,24 +161,11 @@ class HtmlReporter {
162
161
  return;
163
162
  }
164
163
  try {
165
- const uploadTask = async () => {
166
- const uploadedFiles = await (0, r2_uploader_1.uploadDirectory)({
167
- fileList: [attachment.path],
168
- sourceDir: this._outputFolder + "/data/" + folderName,
169
- destinationDir: process.env.PROJECT_NAME +
170
- "/" +
171
- process.env.TEST_RUN_GITHUB_ACTION_ID +
172
- "/data/" +
173
- folderName,
174
- uploadBucket: R2_BUCKET_NAME,
175
- })
176
- .then((fileMap) => {
177
- logger_1.logger.debug("Finished uploading test attachment", fileMap);
178
- return fileMap;
179
- })
180
- .catch((e) => logger_1.logger.error("Error uploading test attachment", e));
181
- return uploadedFiles;
182
- };
164
+ const uploadTask = (0, uploader_1.createUploadTask)({
165
+ fileList: [attachment.path],
166
+ outputFolder: this._outputFolder,
167
+ relativePath: path_1.default.join("data", folderName || ""),
168
+ });
183
169
  return (0, queue_1.sendTaskToQueue)(uploadTask);
184
170
  }
185
171
  catch (e) {
@@ -254,53 +240,20 @@ class HtmlReporter {
254
240
  const tracePath = this._outputFolder + "/trace";
255
241
  const traceExists = fs_1.default.existsSync(tracePath);
256
242
  logger_1.logger.debug("trace exists:", traceExists);
257
- const uploadTraceTask = async () => {
258
- logger_1.logger.debug("Uploading playwright trace");
259
- return (0, r2_uploader_1.uploadDirectory)({
260
- sourceDir: this._outputFolder + "/trace",
261
- destinationDir: process.env.PROJECT_NAME +
262
- "/" +
263
- process.env.TEST_RUN_GITHUB_ACTION_ID +
264
- "/trace",
265
- uploadBucket: R2_BUCKET_NAME,
266
- })
267
- .then((fileMap) => {
268
- logger_1.logger.debug("Finished uploading playwright trace", fileMap);
269
- })
270
- .catch((e) => logger_1.logger.error("Error uploading playwright trace", e));
271
- };
243
+ const uploadTraceTask = (0, uploader_1.createUploadTask)({
244
+ outputFolder: this._outputFolder,
245
+ relativePath: "trace",
246
+ });
272
247
  // upload index.html
273
- const uploadIndexTask = async () => {
274
- logger_1.logger.debug("Uploading html report");
275
- return (0, r2_uploader_1.uploadDirectory)({
276
- sourceDir: this._outputFolder,
277
- fileList: [path_1.default.join(this._outputFolder, "index.html")],
278
- destinationDir: process.env.PROJECT_NAME +
279
- "/" +
280
- process.env.TEST_RUN_GITHUB_ACTION_ID,
281
- uploadBucket: R2_BUCKET_NAME,
282
- })
283
- .then((fileMap) => {
284
- logger_1.logger.debug("Finished uploading html report", fileMap);
285
- })
286
- .catch((e) => logger_1.logger.error("Error uploading html report", e));
287
- };
248
+ const uploadIndexTask = (0, uploader_1.createUploadTask)({
249
+ outputFolder: this._outputFolder,
250
+ fileList: [path_1.default.join(this._outputFolder, "index.html")],
251
+ });
288
252
  // upload summary.json
289
- const uploadSummaryTask = async () => {
290
- logger_1.logger.debug("Uploading json report");
291
- return (0, r2_uploader_1.uploadDirectory)({
292
- sourceDir: this._outputFolder,
293
- fileList: [path_1.default.join(this._outputFolder, "summary.json")],
294
- destinationDir: process.env.PROJECT_NAME +
295
- "/" +
296
- process.env.TEST_RUN_GITHUB_ACTION_ID,
297
- uploadBucket: R2_BUCKET_NAME,
298
- })
299
- .then((fileMap) => {
300
- logger_1.logger.debug("Finished uploading json report", fileMap);
301
- })
302
- .catch((e) => logger_1.logger.error("Error uploading json report", e));
303
- };
253
+ const uploadSummaryTask = (0, uploader_1.createUploadTask)({
254
+ outputFolder: this._outputFolder,
255
+ fileList: [path_1.default.join(this._outputFolder, "summary.json")],
256
+ });
304
257
  if (traceExists) {
305
258
  void (0, queue_1.sendTaskToQueue)(uploadTraceTask);
306
259
  }
@@ -1,5 +1,5 @@
1
1
  import { FileMap } from "@empiricalrun/r2-uploader";
2
- type AsyncTask = () => Promise<FileMap | void>;
2
+ export type AsyncTask = () => Promise<FileMap | void>;
3
3
  type AsyncTaskReturnType = FileMap | void;
4
4
  type AsyncTaskResult = Promise<AsyncTaskReturnType>;
5
5
  export declare function sendTaskToQueue(task: AsyncTask): AsyncTaskResult;
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/reporter/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIpD,KAAK,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAC/C,KAAK,mBAAmB,GAAG,OAAO,GAAG,IAAI,CAAC;AAC1C,KAAK,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAoGpD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CAQhE;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOxD"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/reporter/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIpD,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AACtD,KAAK,mBAAmB,GAAG,OAAO,GAAG,IAAI,CAAC;AAC1C,KAAK,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAoGpD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,CAQhE;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAOxD"}
@@ -0,0 +1,13 @@
1
+ import { FileMap } from "@empiricalrun/r2-uploader/src/types";
2
+ import { AsyncTask } from "./queue";
3
+ export declare function uploadFiles({ fileList, outputFolder, relativePath, }: {
4
+ outputFolder: string;
5
+ fileList?: string[];
6
+ relativePath: string;
7
+ }): Promise<FileMap | void>;
8
+ export declare function createUploadTask({ fileList, outputFolder, relativePath, }: {
9
+ outputFolder: string;
10
+ fileList?: string[];
11
+ relativePath?: string;
12
+ }): AsyncTask;
13
+ //# sourceMappingURL=uploader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAK9D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpC,wBAAsB,WAAW,CAAC,EAChC,QAAQ,EACR,YAAY,EACZ,YAAY,GACb,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAwB1B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,YAAY,EACZ,YAAiB,GAClB,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,SAAS,CAaZ"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createUploadTask = exports.uploadFiles = void 0;
7
+ const upload_1 = require("@empiricalrun/r2-uploader/src/upload");
8
+ const path_1 = __importDefault(require("path"));
9
+ const logger_1 = require("../logger");
10
+ const R2_BUCKET_NAME = "test-report";
11
+ const R2_BASE_URL = "https://reports.empirical.run";
12
+ async function uploadFiles({ fileList, outputFolder, relativePath, }) {
13
+ if (!process.env.PROJECT_NAME || !process.env.TEST_RUN_GITHUB_ACTION_ID) {
14
+ return;
15
+ }
16
+ const urls = {};
17
+ const sourceDir = path_1.default.join(outputFolder, relativePath);
18
+ const destinationDir = path_1.default.join(process.env.PROJECT_NAME, process.env.TEST_RUN_GITHUB_ACTION_ID, relativePath);
19
+ const uploadedfiles = await (0, upload_1.uploadDirectory)({
20
+ sourceDir,
21
+ fileList,
22
+ destinationDir,
23
+ uploadBucket: R2_BUCKET_NAME,
24
+ });
25
+ Object.entries(uploadedfiles).forEach(([filePath]) => {
26
+ const fileName = filePath.split("/").pop() || "";
27
+ const fileUrl = new URL(path_1.default.join(destinationDir, fileName), R2_BASE_URL);
28
+ urls[fileName] = fileUrl.toString();
29
+ });
30
+ logger_1.logger.debug("Finished uploading files:", urls);
31
+ return urls;
32
+ }
33
+ exports.uploadFiles = uploadFiles;
34
+ function createUploadTask({ fileList, outputFolder, relativePath = "", }) {
35
+ return async () => {
36
+ return uploadFiles({
37
+ fileList,
38
+ outputFolder,
39
+ relativePath,
40
+ })
41
+ .then((fileMap) => {
42
+ logger_1.logger.debug("Finished uploading files", fileMap);
43
+ return fileMap;
44
+ })
45
+ .catch((e) => logger_1.logger.error("Error uploading files", e));
46
+ };
47
+ }
48
+ exports.createUploadTask = createUploadTask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.18.18",
3
+ "version": "0.18.20",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -43,8 +43,8 @@
43
43
  "playwright-extra": "^4.3.6",
44
44
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
45
45
  "rimraf": "^6.0.1",
46
+ "@empiricalrun/test-gen": "^0.38.44",
46
47
  "@empiricalrun/r2-uploader": "^0.3.7",
47
- "@empiricalrun/test-gen": "^0.38.43",
48
48
  "@empiricalrun/llm": "^0.9.28"
49
49
  },
50
50
  "scripts": {