@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 +13 -0
- package/dist/overlay-tests/visual.spec.js +5 -3
- package/dist/reporter/attachment-cleanup.js +8 -3
- package/dist/reporter/uploader.d.ts +1 -1
- package/dist/reporter/uploader.js +2 -2
- package/dist/test/expect/visual.d.ts.map +1 -1
- package/dist/test/expect/visual.js +13 -2
- package/package.json +1 -1
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.
|
|
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-
|
|
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.
|
|
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 =
|
|
161
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -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.
|
|
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
|
-
|
|
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;
|
|
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
|
-
|
|
33
|
-
|
|
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
|
}
|