@empiricalrun/playwright-utils 0.48.4 → 0.48.6

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,18 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.48.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 05df554: fix: turn down verbose logs
8
+
9
+ ## 0.48.5
10
+
11
+ ### Patch Changes
12
+
13
+ - e00de0e: fix: visual assertions attachments should be path-based
14
+ - 448e699: chore: simplify webhook assertions
15
+
3
16
  ## 0.48.4
4
17
 
5
18
  ### Patch Changes
@@ -10,7 +10,8 @@ const expect = (0, test_1.extendExpect)(fixtures_1.expect);
10
10
  expect(pageAttachment).toBeDefined();
11
11
  expect(pageAttachment.name).toBe("toLookRight-L11-a-welcome-page-with-a-heading-and-a-paragraph-of-text");
12
12
  expect(pageAttachment.contentType).toBe("image/png");
13
- expect(pageAttachment.body.length).toBeGreaterThan(0);
13
+ expect(pageAttachment.path).toBeDefined();
14
+ expect(pageAttachment.path).toMatch(/\.png$/);
14
15
  });
15
16
  (0, fixtures_1.test)("toLookRight on locator attaches screenshot", async ({ page, server, }, testInfo) => {
16
17
  await page.goto(`${server.baseURL}/visual-test.html`);
@@ -18,7 +19,8 @@ const expect = (0, test_1.extendExpect)(fixtures_1.expect);
18
19
  await expect(heading).toLookRight("A heading that says Welcome to the App");
19
20
  const locatorAttachment = testInfo.attachments.find((a) => a.name.startsWith("toLookRight-"));
20
21
  expect(locatorAttachment).toBeDefined();
21
- expect(locatorAttachment.name).toBe("toLookRight-L31-a-heading-that-says-welcome-to-the-app");
22
+ expect(locatorAttachment.name).toBe("toLookRight-L32-a-heading-that-says-welcome-to-the-app");
22
23
  expect(locatorAttachment.contentType).toBe("image/png");
23
- expect(locatorAttachment.body.length).toBeGreaterThan(0);
24
+ expect(locatorAttachment.path).toBeDefined();
25
+ expect(locatorAttachment.path).toMatch(/\.png$/);
24
26
  });
@@ -157,15 +157,20 @@ class AttachmentCleanup {
157
157
  }
158
158
  _logDiskStatus() {
159
159
  this._diskLogTick++;
160
- const artifactsSuffix = this._diskLogTick % 15 === 0 ? `, breakdown=${getDiskBreakdown()}` : "";
161
- logger_1.logger.info(`[AttachmentCleanup] Periodic: registered=${this._registeredCount}, pending=${this._pending.size}, uploaded=${this._uploadedCount}, evicted=${this._evictedCount} (${formatBytes(this._evictedBytes)}), totalSize=${formatBytes(this._totalSize)}, limit=${formatBytes(this._limitBytes)}, disk=${getDiskUsage()}${artifactsSuffix}`);
160
+ // const artifactsSuffix =
161
+ // this._diskLogTick % 15 === 0 ? `, breakdown=${getDiskBreakdown()}` : "";
162
+ // logger.info(
163
+ // `[AttachmentCleanup] Periodic: registered=${this._registeredCount}, pending=${this._pending.size}, uploaded=${this._uploadedCount}, evicted=${this._evictedCount} (${formatBytes(this._evictedBytes)}), totalSize=${formatBytes(this._totalSize)}, limit=${formatBytes(this._limitBytes)}, disk=${getDiskUsage()}${artifactsSuffix}`,
164
+ // );
162
165
  }
163
166
  logSummary() {
164
167
  if (this._diskLogTimer) {
165
168
  clearInterval(this._diskLogTimer);
166
169
  this._diskLogTimer = null;
167
170
  }
168
- logger_1.logger.info(`[AttachmentCleanup] Summary: registered=${this._registeredCount}, pending=${this._pending.size}, uploaded=${this._uploadedCount}, evicted=${this._evictedCount} (${formatBytes(this._evictedBytes)}), totalSize=${formatBytes(this._totalSize)}, disk=${getDiskUsage()}, breakdown=${getDiskBreakdown()}`);
171
+ // logger.info(
172
+ // `[AttachmentCleanup] Summary: registered=${this._registeredCount}, pending=${this._pending.size}, uploaded=${this._uploadedCount}, evicted=${this._evictedCount} (${formatBytes(this._evictedBytes)}), totalSize=${formatBytes(this._totalSize)}, disk=${getDiskUsage()}, breakdown=${getDiskBreakdown()}`,
173
+ // );
169
174
  }
170
175
  set onEvict(callback) {
171
176
  this._onEvict = callback;
@@ -1,6 +1,6 @@
1
1
  import { StorageCredentials } from "@empiricalrun/r2-uploader";
2
2
  export interface UploaderConfig {
3
- projectName: string;
3
+ projectSlug: string;
4
4
  runId: string;
5
5
  baseUrl: string;
6
6
  uploadBucket: string;
@@ -16,7 +16,7 @@ class Uploader {
16
16
  constructor(config) {
17
17
  this._baseUrl = config.baseUrl;
18
18
  this._uploadBucket = config.uploadBucket;
19
- this._destinationDir = `${config.projectName}/${config.runId}`;
19
+ this._destinationDir = `${config.projectSlug}/${config.runId}`;
20
20
  this._credentials = config.credentials;
21
21
  logger_1.logger.debug(`[Uploader] Initialized with destination: ${this._destinationDir}, provider: ${this._credentials.provider}`);
22
22
  }
@@ -146,7 +146,7 @@ function createUploader() {
146
146
  uploadBucket = bucket;
147
147
  }
148
148
  return new Uploader({
149
- projectName: process.env.PROJECT_NAME,
149
+ projectSlug: process.env.PROJECT_NAME,
150
150
  runId: process.env.TEST_RUN_GITHUB_ACTION_ID,
151
151
  baseUrl,
152
152
  uploadBucket,
@@ -1 +1 @@
1
- {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAOhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA8D7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CA2FxB"}
1
+ {"version":3,"file":"visual.d.ts","sourceRoot":"","sources":["../../../src/test/expect/visual.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAC;AAUhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAsE7C,wBAAsB,WAAW,CAC/B,MAAM,EAAE,IAAI,GAAG,OAAO,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC,CA2FxB"}
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.toLookRight = toLookRight;
4
7
  const llm_1 = require("@empiricalrun/llm");
5
8
  const vision_1 = require("@empiricalrun/llm/vision");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const os_1 = __importDefault(require("os"));
11
+ const path_1 = __importDefault(require("path"));
6
12
  const telemetry_1 = require("../../telemetry");
7
13
  const mouse_pointer_1 = require("../scripts/mouse-pointer");
8
14
  function getCallerLine() {
@@ -29,8 +35,13 @@ function attachScreenshot(screenshot, pageDescription) {
29
35
  .replace(/[^a-z0-9]+/g, "-")
30
36
  .replace(/(^-|-$)/g, "");
31
37
  const line = getCallerLine();
32
- testInfo.attach(`toLookRight-L${line}-${slug}`, {
33
- body: screenshot,
38
+ const attachmentName = `toLookRight-L${line}-${slug}`;
39
+ // Write to a temp file so the attachment has a path (required by empirical reporter).
40
+ // Playwright copies it into test-results/<test>/attachments/ on attach.
41
+ const tmpFile = path_1.default.join(os_1.default.tmpdir(), `${attachmentName}-${Date.now()}.png`);
42
+ fs_1.default.writeFileSync(tmpFile, screenshot);
43
+ testInfo.attach(attachmentName, {
44
+ path: tmpFile,
34
45
  contentType: "image/png",
35
46
  });
36
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.48.4",
3
+ "version": "0.48.6",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"