@empiricalrun/playwright-utils 0.48.6 → 0.49.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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.49.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6fb8170: feat: playwright utils upgraded to use new core
8
+ - aa78c40: fix: narrower request payloads to avoid body attachments hogging request size
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [6fb8170]
13
+ - @empiricalrun/cua@0.4.0
14
+ - @empiricalrun/reporter@0.29.0
15
+ - @empiricalrun/dashboard-client@0.3.0
16
+ - @empiricalrun/llm@0.26.0
17
+
3
18
  ## 0.48.6
4
19
 
5
20
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAuBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,oBAAoB,CAG1B;IACF,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;;IAMrD,OAAO,CAAC,6BAA6B,CAqCnC;IAEF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IAwGtC,KAAK,CAAC,MAAM,EAAE,UAAU;IAmG9B,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAmChC;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"empirical-reporter.d.ts","sourceRoot":"","sources":["../../src/reporter/empirical-reporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,2BAA2B,CAAC;AAuBnC,cAAM,iBAAkB,YAAW,QAAQ;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,oBAAoB,CAG1B;IACF,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,YAAY,CAAgD;IACpE,OAAO,CAAC,iBAAiB,CAAyC;IAClE,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,kBAAkB,CAA2B;;IAMrD,OAAO,CAAC,6BAA6B,CAqCnC;IAEF,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU;IA+HtC,KAAK,CAAC,MAAM,EAAE,UAAU;IAmG9B,OAAO,CAAC,qBAAqB;YAkBf,gBAAgB;YAOhB,iBAAiB;CAmChC;AAED,eAAe,iBAAiB,CAAC"}
@@ -109,9 +109,32 @@ class EmpiricalReporter {
109
109
  ? parseInt(process.env.SHARD_INDEX, 10)
110
110
  : undefined;
111
111
  const params = {
112
- test,
112
+ test: {
113
+ id: test.id,
114
+ title: test.title,
115
+ location: test.location,
116
+ expectedStatus: test.expectedStatus,
117
+ retries: test.retries,
118
+ },
113
119
  suites,
114
- result,
120
+ result: {
121
+ retry: result.retry,
122
+ status: result.status,
123
+ duration: result.duration,
124
+ startTime: result.startTime,
125
+ error: result.error
126
+ ? {
127
+ message: result.error.message,
128
+ stack: result.error.stack,
129
+ location: result.error.location,
130
+ }
131
+ : undefined,
132
+ errors: result.errors?.map((e) => ({
133
+ message: e.message,
134
+ stack: e.stack,
135
+ location: e.location,
136
+ })),
137
+ },
115
138
  projectName,
116
139
  attachments: successfulAttachments,
117
140
  runId: process.env.TEST_RU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AAE,MAAM,CAAC;CACrB,CAAC,CAyCD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ;;;EAwBrD;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACnC,GAAG,CAIL;AAED,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,iBAuGjB;AAED;;;;;;;;;;GAUG;AACH;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,OAAe,GAC9B,iBAAiB,CAcnB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,6CA+BlB"}
@@ -16,11 +16,25 @@ exports.updateSummaryJsonAttachmentPaths = updateSummaryJsonAttachmentPaths;
16
16
  const zip_1 = require("@empiricalrun/r2-uploader/zip");
17
17
  const reporter_1 = require("@empiricalrun/reporter");
18
18
  const async_retry_1 = __importDefault(require("async-retry"));
19
+ const crypto_1 = __importDefault(require("crypto"));
19
20
  const fs_1 = __importDefault(require("fs"));
21
+ const mime_1 = __importDefault(require("mime"));
20
22
  const path_1 = __importDefault(require("path"));
21
- const utils_1 = require("playwright-core/lib/utils");
22
- const utilsBundle_1 = require("playwright-core/lib/utilsBundle");
23
23
  const logger_1 = require("../logger");
24
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/tools/cli-client/program.ts#L440
25
+ function calculateSha1(buffer) {
26
+ const hash = crypto_1.default.createHash("sha1");
27
+ hash.update(buffer);
28
+ return hash.digest("hex");
29
+ }
30
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/isomorphic/stringUtils.ts#L37
31
+ function isString(obj) {
32
+ return typeof obj === "string" || obj instanceof String;
33
+ }
34
+ // Mirrors https://github.com/microsoft/playwright/blob/main/packages/utils/fileUtils.ts#L77
35
+ function sanitizeForFilePath(s) {
36
+ return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, "-");
37
+ }
24
38
  const folderToPackageJsonPath = new Map();
25
39
  function getPackageJsonPath(folderPath) {
26
40
  const cached = folderToPackageJsonPath.get(folderPath);
@@ -55,15 +69,15 @@ async function normalizeAndSaveAttachment(outputPath, name, options = {}) {
55
69
  1)
56
70
  throw new Error(`Exactly one of "path" and "body" must be specified`);
57
71
  if (options.path !== undefined) {
58
- const hash = (0, utils_1.calculateSha1)(options.path);
59
- if (!(0, utils_1.isString)(name))
72
+ const hash = calculateSha1(options.path);
73
+ if (!isString(name))
60
74
  throw new Error('"name" should be string.');
61
- const sanitizedNamePrefix = (0, utils_1.sanitizeForFilePath)(name) + "-";
75
+ const sanitizedNamePrefix = sanitizeForFilePath(name) + "-";
62
76
  const dest = path_1.default.join(outputPath, "attachments", sanitizedNamePrefix + hash + path_1.default.extname(options.path));
63
77
  await fs_1.default.promises.mkdir(path_1.default.dirname(dest), { recursive: true });
64
78
  await fs_1.default.promises.copyFile(options.path, dest);
65
79
  const contentType = options.contentType ??
66
- (utilsBundle_1.mime.getType(path_1.default.basename(options.path)) || "application/octet-stream");
80
+ (mime_1.default.getType(path_1.default.basename(options.path)) || "application/octet-stream");
67
81
  return { name, contentType, path: dest };
68
82
  }
69
83
  else {
@@ -108,16 +122,10 @@ function suitesAndProjectForTest(test) {
108
122
  async function sendTestCaseUpdateToDashboard(params) {
109
123
  const DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
110
124
  try {
111
- const keyFilter = (key) => key === "parent";
112
- const payload = {
113
- ...params,
114
- test: safelySerialiseJSON(params.test, keyFilter),
115
- result: safelySerialiseJSON(params.result, keyFilter),
116
- };
117
125
  const requestBody = {
118
126
  name: "test_case_run_end",
119
127
  data: {
120
- ...payload,
128
+ ...params,
121
129
  },
122
130
  };
123
131
  if (!DOMAIN) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.48.6",
3
+ "version": "0.49.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "author": "Empirical Team <hey@empirical.run>",
24
24
  "devDependencies": {
25
- "@playwright/test": "1.58.2",
25
+ "@playwright/test": "1.60.0",
26
26
  "@types/async-retry": "^1.4.8",
27
27
  "@types/authenticator": "^1.1.4",
28
28
  "@types/babel__code-frame": "^7.0.6",
@@ -30,9 +30,10 @@
30
30
  "@types/node": "^20.14.9",
31
31
  "@types/serve-handler": "^6.1.4",
32
32
  "@types/pg": "^8.11.6",
33
- "playwright-core": "1.58.2",
33
+ "@types/mime": "3.0.0",
34
+ "playwright-core": "1.60.0",
34
35
  "serve-handler": "^6.1.6",
35
- "@empiricalrun/shared-types": "0.12.1"
36
+ "@empiricalrun/shared-types": "0.13.0"
36
37
  },
37
38
  "dependencies": {
38
39
  "@babel/code-frame": "^7.24.7",
@@ -43,11 +44,12 @@
43
44
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
44
45
  "rimraf": "^6.0.1",
45
46
  "ts-morph": "^23.0.0",
46
- "@empiricalrun/cua": "^0.3.0",
47
+ "mime": "3.0.0",
48
+ "@empiricalrun/cua": "^0.4.0",
47
49
  "@empiricalrun/dashboard-client": "^0.3.0",
48
50
  "@empiricalrun/llm": "^0.26.0",
49
51
  "@empiricalrun/r2-uploader": "^0.9.1",
50
- "@empiricalrun/reporter": "^0.28.1"
52
+ "@empiricalrun/reporter": "^0.29.0"
51
53
  },
52
54
  "scripts": {
53
55
  "dev": "tsc --build --watch",