@empiricalrun/playwright-utils 0.70.3 → 0.71.1
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 +21 -0
- package/dist/api-worker-client.d.ts +5 -1
- package/dist/api-worker-client.d.ts.map +1 -1
- package/dist/api-worker-client.js +15 -0
- package/dist/generated/api-worker-openapi.d.ts +609 -383
- package/dist/generated/api-worker-openapi.d.ts.map +1 -1
- package/dist/overlay-test-expectations.d.ts +10 -0
- package/dist/overlay-test-expectations.d.ts.map +1 -0
- package/dist/overlay-test-expectations.js +51 -0
- package/dist/overlay-tests/click.spec.js +26 -94
- package/dist/overlay-tests/dropdown.spec.js +10 -9
- package/dist/overlay-tests/fixtures.d.ts +1 -0
- package/dist/overlay-tests/fixtures.d.ts.map +1 -1
- package/dist/overlay-tests/fixtures.js +24 -0
- package/dist/overlay-tests/visual.spec.js +1 -11
- package/dist/test/cross-shard-locks.d.ts +1 -1
- package/dist/test/cross-shard-locks.d.ts.map +1 -1
- package/dist/test/cross-shard-locks.js +71 -25
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +10 -0
- package/dist/test/locator-handler-log.spec.d.ts +2 -0
- package/dist/test/locator-handler-log.spec.d.ts.map +1 -0
- package/dist/test/locator-handler-log.spec.js +44 -0
- package/dist/test/scripts/locator-handler-log.d.ts +23 -0
- package/dist/test/scripts/locator-handler-log.d.ts.map +1 -0
- package/dist/test/scripts/locator-handler-log.js +105 -0
- package/dist/test/scripts/pw-locator-patch/actions/click.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/actions/click.js +17 -34
- package/dist/test/scripts/pw-locator-patch/actions/hover.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/actions/hover.js +11 -25
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.d.ts +21 -4
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.js +113 -18
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.d.ts +2 -3
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.js +6 -52
- package/dist/webhook.d.ts +1 -6
- package/dist/webhook.d.ts.map +1 -1
- package/dist/webhook.js +12 -124
- package/package.json +3 -3
- package/playwright.config.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/overlay-tests/typesafe-hit-check.spec.d.ts +0 -2
- package/dist/overlay-tests/typesafe-hit-check.spec.d.ts.map +0 -1
- package/dist/overlay-tests/typesafe-hit-check.spec.js +0 -57
- package/dist/overlay-tests/typesafe.spec.d.ts +0 -2
- package/dist/overlay-tests/typesafe.spec.d.ts.map +0 -1
- package/dist/overlay-tests/typesafe.spec.js +0 -88
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/typesafe.d.ts +0 -38
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/typesafe.d.ts.map +0 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/typesafe.js +0 -159
package/dist/webhook.js
CHANGED
|
@@ -3,101 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getWebhookUrl = getWebhookUrl;
|
|
4
4
|
exports.queryWebhookRequests = queryWebhookRequests;
|
|
5
5
|
const api_worker_client_1 = require("./api-worker-client");
|
|
6
|
-
const WEBHOOK_SITE_BASE_URL = "https://webhook.site";
|
|
7
|
-
const DEFAULT_TOKEN_EXPIRY = 604800;
|
|
8
|
-
function escapeQueryTerm(term) {
|
|
9
|
-
return term.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
10
|
-
}
|
|
11
|
-
function buildContentQuery(content) {
|
|
12
|
-
const terms = Array.isArray(content) ? content : [content];
|
|
13
|
-
if (terms.length === 0 || terms.some((t) => t.length === 0)) {
|
|
14
|
-
throw new Error("content must be a non-empty string or string[]");
|
|
15
|
-
}
|
|
16
|
-
return terms.map((t) => `content:"${escapeQueryTerm(t)}"`).join(" AND ");
|
|
17
|
-
}
|
|
18
|
-
async function webhookSiteGetUrl(options) {
|
|
19
|
-
const expiry = options.expiry === undefined ? DEFAULT_TOKEN_EXPIRY : options.expiry;
|
|
20
|
-
if (process.env.EMPIRICALRUN_API_KEY) {
|
|
21
|
-
const apiClient = new api_worker_client_1.ApiWorkerClient();
|
|
22
|
-
const result = await apiClient.postProviderProxy("/api/webhook-site/proxy", {
|
|
23
|
-
method: "POST",
|
|
24
|
-
path: "/token",
|
|
25
|
-
body: { expiry },
|
|
26
|
-
});
|
|
27
|
-
const tokenData = result.data;
|
|
28
|
-
return `${WEBHOOK_SITE_BASE_URL}/${tokenData.uuid}`;
|
|
29
|
-
}
|
|
30
|
-
const apiKey = process.env.WEBHOOK_SITE_API_KEY;
|
|
31
|
-
if (!apiKey) {
|
|
32
|
-
throw new Error("Either EMPIRICALRUN_API_KEY or WEBHOOK_SITE_API_KEY must be set");
|
|
33
|
-
}
|
|
34
|
-
const response = await fetch(`${WEBHOOK_SITE_BASE_URL}/token`, {
|
|
35
|
-
method: "POST",
|
|
36
|
-
headers: {
|
|
37
|
-
"Api-Key": apiKey,
|
|
38
|
-
"Content-Type": "application/json",
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify({ expiry }),
|
|
41
|
-
});
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
const body = await response.text().catch(() => "");
|
|
44
|
-
throw new Error(`webhook.site error [${response.status} ${response.statusText}]: ${body}`);
|
|
45
|
-
}
|
|
46
|
-
const { uuid } = await response.json();
|
|
47
|
-
return `${WEBHOOK_SITE_BASE_URL}/${uuid}`;
|
|
48
|
-
}
|
|
49
|
-
async function webhookSiteQueryViaProxy(token, content) {
|
|
50
|
-
const apiClient = new api_worker_client_1.ApiWorkerClient();
|
|
51
|
-
const params = new URLSearchParams({
|
|
52
|
-
query: buildContentQuery(content),
|
|
53
|
-
sorting: "newest",
|
|
54
|
-
per_page: "20",
|
|
55
|
-
});
|
|
56
|
-
const result = await apiClient.postProviderProxy("/api/webhook-site/proxy", {
|
|
57
|
-
method: "GET",
|
|
58
|
-
path: `/token/${token}/requests?${params.toString()}`,
|
|
59
|
-
});
|
|
60
|
-
const webhookResponse = result.data;
|
|
61
|
-
if (!webhookResponse ||
|
|
62
|
-
!webhookResponse.data ||
|
|
63
|
-
!Array.isArray(webhookResponse.data)) {
|
|
64
|
-
throw new Error("webhook.site proxy response missing 'data' array");
|
|
65
|
-
}
|
|
66
|
-
return webhookResponse.data;
|
|
67
|
-
}
|
|
68
|
-
async function webhookSiteQueryDirect(token, content) {
|
|
69
|
-
const apiKey = process.env.WEBHOOK_SITE_API_KEY;
|
|
70
|
-
if (!apiKey) {
|
|
71
|
-
throw new Error("Either EMPIRICALRUN_API_KEY or WEBHOOK_SITE_API_KEY must be set");
|
|
72
|
-
}
|
|
73
|
-
const params = new URLSearchParams({
|
|
74
|
-
query: buildContentQuery(content),
|
|
75
|
-
sorting: "newest",
|
|
76
|
-
per_page: "20",
|
|
77
|
-
});
|
|
78
|
-
const rawResponse = await fetch(`https://webhook.site/token/${token}/requests?${params.toString()}`, {
|
|
79
|
-
headers: {
|
|
80
|
-
"Api-Key": apiKey,
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
if (!rawResponse.ok) {
|
|
84
|
-
const body = await rawResponse.text().catch(() => "");
|
|
85
|
-
throw new Error(`webhook.site error [${rawResponse.status} ${rawResponse.statusText}]: ${body}`);
|
|
86
|
-
}
|
|
87
|
-
const json = await rawResponse.json().catch((e) => {
|
|
88
|
-
throw new Error(`webhook.site returned invalid JSON: ${String(e)}`);
|
|
89
|
-
});
|
|
90
|
-
if (!json || !Array.isArray(json.data)) {
|
|
91
|
-
throw new Error("webhook.site response missing 'data' array");
|
|
92
|
-
}
|
|
93
|
-
return json.data;
|
|
94
|
-
}
|
|
95
|
-
async function webhookSiteQuery(token, content) {
|
|
96
|
-
if (process.env.EMPIRICALRUN_API_KEY) {
|
|
97
|
-
return webhookSiteQueryViaProxy(token, content);
|
|
98
|
-
}
|
|
99
|
-
return webhookSiteQueryDirect(token, content);
|
|
100
|
-
}
|
|
101
6
|
function captureToWebhookRequest(capture) {
|
|
102
7
|
const headers = Object.fromEntries(Object.entries(capture.headers).map(([key, value]) => [key, [value]]));
|
|
103
8
|
return {
|
|
@@ -118,18 +23,6 @@ function captureToWebhookRequest(capture) {
|
|
|
118
23
|
updated_at: capture.received_at,
|
|
119
24
|
};
|
|
120
25
|
}
|
|
121
|
-
async function inboxGetUrl() {
|
|
122
|
-
const { url } = await new api_worker_client_1.ApiWorkerClient().createWebhookCapture();
|
|
123
|
-
return url;
|
|
124
|
-
}
|
|
125
|
-
async function inboxQuery(token, content) {
|
|
126
|
-
const captures = await new api_worker_client_1.ApiWorkerClient().listWebhookCaptures(token, {
|
|
127
|
-
content: Array.isArray(content) ? content : [content],
|
|
128
|
-
order: "newest",
|
|
129
|
-
limit: 20,
|
|
130
|
-
});
|
|
131
|
-
return captures.map(captureToWebhookRequest);
|
|
132
|
-
}
|
|
133
26
|
function extractToken(webhookUrl) {
|
|
134
27
|
let url;
|
|
135
28
|
try {
|
|
@@ -138,6 +31,9 @@ function extractToken(webhookUrl) {
|
|
|
138
31
|
catch {
|
|
139
32
|
throw new Error(`Invalid webhook URL: ${webhookUrl}`);
|
|
140
33
|
}
|
|
34
|
+
if (url.hostname === "webhook.site") {
|
|
35
|
+
throw new Error(`webhook.site URLs are no longer supported: use getWebhookUrl() for an Empirical inbox URL (${webhookUrl})`);
|
|
36
|
+
}
|
|
141
37
|
const parts = url.pathname.split("/").filter(Boolean);
|
|
142
38
|
const token = parts[parts.length - 1];
|
|
143
39
|
if (!token) {
|
|
@@ -145,24 +41,16 @@ function extractToken(webhookUrl) {
|
|
|
145
41
|
}
|
|
146
42
|
return token;
|
|
147
43
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
return "inbox";
|
|
153
|
-
}
|
|
154
|
-
async function getWebhookUrl(options = {}) {
|
|
155
|
-
const provider = options.provider || "webhook-site";
|
|
156
|
-
if (provider === "webhook-site") {
|
|
157
|
-
return webhookSiteGetUrl(options);
|
|
158
|
-
}
|
|
159
|
-
return inboxGetUrl();
|
|
44
|
+
async function getWebhookUrl() {
|
|
45
|
+
const { url } = await new api_worker_client_1.ApiWorkerClient().createWebhookCapture();
|
|
46
|
+
return url;
|
|
160
47
|
}
|
|
161
48
|
async function queryWebhookRequests(webhookUrl, content) {
|
|
162
49
|
const token = extractToken(webhookUrl);
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
50
|
+
const captures = await new api_worker_client_1.ApiWorkerClient().listWebhookCaptures(token, {
|
|
51
|
+
content: Array.isArray(content) ? content : [content],
|
|
52
|
+
order: "newest",
|
|
53
|
+
limit: 20,
|
|
54
|
+
});
|
|
55
|
+
return captures.map(captureToWebhookRequest);
|
|
168
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22"
|
|
6
6
|
},
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"openapi-fetch": "0.14.1",
|
|
63
63
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
64
64
|
"ts-morph": "^28.0.0",
|
|
65
|
-
"@empiricalrun/cua": "^0.
|
|
66
|
-
"@empiricalrun/r2-uploader": "^0.
|
|
65
|
+
"@empiricalrun/cua": "^0.7.0",
|
|
66
|
+
"@empiricalrun/r2-uploader": "^0.12.0",
|
|
67
67
|
"@empiricalrun/reporter": "^0.30.6"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
package/playwright.config.ts
CHANGED