@empiricalrun/playwright-utils 0.48.3 → 0.48.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 +13 -0
- package/dist/overlay-tests/visual.spec.js +5 -3
- package/dist/test/expect/visual.d.ts.map +1 -1
- package/dist/test/expect/visual.js +13 -2
- package/dist/webhook.d.ts.map +1 -1
- package/dist/webhook.js +19 -44
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.48.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e00de0e: fix: visual assertions attachments should be path-based
|
|
8
|
+
- 448e699: chore: simplify webhook assertions
|
|
9
|
+
|
|
10
|
+
## 0.48.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 18aa8e1: chore: simplify webhook assertions
|
|
15
|
+
|
|
3
16
|
## 0.48.3
|
|
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
|
});
|
|
@@ -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
|
}
|
package/dist/webhook.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../src/webhook.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,eAAe,GAAG,OAAO,GAAG,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../src/webhook.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,eAAe,GAAG,OAAO,GAAG,cAAc,CAAC;AAyQhD,wBAAsB,aAAa,CACjC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,eAAe,CAAA;CAAO,GACnE,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CAO3B"}
|
package/dist/webhook.js
CHANGED
|
@@ -141,26 +141,15 @@ function inboxRowToWebhookRequest(row) {
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
async function inboxGetUrl() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const result = await apiClient.request("/api/inbox/proxy", {
|
|
149
|
-
method: "POST",
|
|
150
|
-
body: { method: "POST", path: "/api/hooks/token" },
|
|
151
|
-
});
|
|
152
|
-
const tokenData = result.data;
|
|
153
|
-
return `${INBOX_WORKER_URL}/hooks/${tokenData.uuid}`;
|
|
154
|
-
}
|
|
155
|
-
const response = await fetch(`${INBOX_WORKER_URL}/api/hooks/token`, {
|
|
144
|
+
const apiClient = new dashboard_client_1.DashboardAPIClient({
|
|
145
|
+
authType: "project-api-key",
|
|
146
|
+
});
|
|
147
|
+
const result = await apiClient.request("/api/inbox/proxy", {
|
|
156
148
|
method: "POST",
|
|
149
|
+
body: { method: "POST", path: "/api/hooks/token" },
|
|
157
150
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
throw new Error(`inbox webhook error [${response.status} ${response.statusText}]: ${body}`);
|
|
161
|
-
}
|
|
162
|
-
const { uuid } = await response.json();
|
|
163
|
-
return `${INBOX_WORKER_URL}/hooks/${uuid}`;
|
|
151
|
+
const tokenData = result.data;
|
|
152
|
+
return `${INBOX_WORKER_URL}/hooks/${tokenData.uuid}`;
|
|
164
153
|
}
|
|
165
154
|
async function inboxQuery(token, content) {
|
|
166
155
|
const terms = Array.isArray(content) ? content : [content];
|
|
@@ -172,35 +161,21 @@ async function inboxQuery(token, content) {
|
|
|
172
161
|
for (const t of terms) {
|
|
173
162
|
params.append("content", t);
|
|
174
163
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
authType: "project-api-key",
|
|
178
|
-
});
|
|
179
|
-
const result = await apiClient.request("/api/inbox/proxy", {
|
|
180
|
-
method: "POST",
|
|
181
|
-
body: {
|
|
182
|
-
method: "GET",
|
|
183
|
-
path: `/api/hooks?${params.toString()}`,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
const response = result.data;
|
|
187
|
-
if (!response || !Array.isArray(response.data)) {
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
return response.data.map(inboxRowToWebhookRequest);
|
|
191
|
-
}
|
|
192
|
-
const rawResponse = await fetch(`${INBOX_WORKER_URL}/api/hooks?${params.toString()}`);
|
|
193
|
-
if (!rawResponse.ok) {
|
|
194
|
-
const body = await rawResponse.text().catch(() => "");
|
|
195
|
-
throw new Error(`inbox webhook error [${rawResponse.status} ${rawResponse.statusText}]: ${body}`);
|
|
196
|
-
}
|
|
197
|
-
const json = await rawResponse.json().catch((e) => {
|
|
198
|
-
throw new Error(`inbox webhook returned invalid JSON: ${String(e)}`);
|
|
164
|
+
const apiClient = new dashboard_client_1.DashboardAPIClient({
|
|
165
|
+
authType: "project-api-key",
|
|
199
166
|
});
|
|
200
|
-
|
|
167
|
+
const result = await apiClient.request("/api/inbox/proxy", {
|
|
168
|
+
method: "POST",
|
|
169
|
+
body: {
|
|
170
|
+
method: "GET",
|
|
171
|
+
path: `/api/hooks?${params.toString()}`,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
const response = result.data;
|
|
175
|
+
if (!response || !Array.isArray(response.data)) {
|
|
201
176
|
return [];
|
|
202
177
|
}
|
|
203
|
-
return
|
|
178
|
+
return response.data.map(inboxRowToWebhookRequest);
|
|
204
179
|
}
|
|
205
180
|
// ── public API ──
|
|
206
181
|
function extractToken(webhookUrl) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
44
44
|
"rimraf": "^6.0.1",
|
|
45
45
|
"ts-morph": "^23.0.0",
|
|
46
|
+
"@empiricalrun/cua": "^0.3.0",
|
|
46
47
|
"@empiricalrun/dashboard-client": "^0.3.0",
|
|
47
|
-
"@empiricalrun/r2-uploader": "^0.9.1",
|
|
48
48
|
"@empiricalrun/llm": "^0.26.0",
|
|
49
|
-
"@empiricalrun/
|
|
50
|
-
"@empiricalrun/
|
|
49
|
+
"@empiricalrun/r2-uploader": "^0.9.1",
|
|
50
|
+
"@empiricalrun/reporter": "^0.28.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"dev": "tsc --build --watch",
|