@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/api-worker-client.d.ts +5 -1
  3. package/dist/api-worker-client.d.ts.map +1 -1
  4. package/dist/api-worker-client.js +15 -0
  5. package/dist/generated/api-worker-openapi.d.ts +609 -383
  6. package/dist/generated/api-worker-openapi.d.ts.map +1 -1
  7. package/dist/overlay-test-expectations.d.ts +10 -0
  8. package/dist/overlay-test-expectations.d.ts.map +1 -0
  9. package/dist/overlay-test-expectations.js +51 -0
  10. package/dist/overlay-tests/click.spec.js +26 -94
  11. package/dist/overlay-tests/dropdown.spec.js +10 -9
  12. package/dist/overlay-tests/fixtures.d.ts +1 -0
  13. package/dist/overlay-tests/fixtures.d.ts.map +1 -1
  14. package/dist/overlay-tests/fixtures.js +24 -0
  15. package/dist/overlay-tests/visual.spec.js +1 -11
  16. package/dist/test/cross-shard-locks.d.ts +1 -1
  17. package/dist/test/cross-shard-locks.d.ts.map +1 -1
  18. package/dist/test/cross-shard-locks.js +71 -25
  19. package/dist/test/index.d.ts +1 -0
  20. package/dist/test/index.d.ts.map +1 -1
  21. package/dist/test/index.js +10 -0
  22. package/dist/test/locator-handler-log.spec.d.ts +2 -0
  23. package/dist/test/locator-handler-log.spec.d.ts.map +1 -0
  24. package/dist/test/locator-handler-log.spec.js +44 -0
  25. package/dist/test/scripts/locator-handler-log.d.ts +23 -0
  26. package/dist/test/scripts/locator-handler-log.d.ts.map +1 -0
  27. package/dist/test/scripts/locator-handler-log.js +105 -0
  28. package/dist/test/scripts/pw-locator-patch/actions/click.d.ts.map +1 -1
  29. package/dist/test/scripts/pw-locator-patch/actions/click.js +17 -34
  30. package/dist/test/scripts/pw-locator-patch/actions/hover.d.ts.map +1 -1
  31. package/dist/test/scripts/pw-locator-patch/actions/hover.js +11 -25
  32. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.d.ts +21 -4
  33. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.d.ts.map +1 -1
  34. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.js +113 -18
  35. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.d.ts +2 -3
  36. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.d.ts.map +1 -1
  37. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.js +6 -52
  38. package/dist/webhook.d.ts +1 -6
  39. package/dist/webhook.d.ts.map +1 -1
  40. package/dist/webhook.js +12 -124
  41. package/package.json +3 -3
  42. package/playwright.config.ts +1 -1
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/dist/overlay-tests/typesafe-hit-check.spec.d.ts +0 -2
  45. package/dist/overlay-tests/typesafe-hit-check.spec.d.ts.map +0 -1
  46. package/dist/overlay-tests/typesafe-hit-check.spec.js +0 -57
  47. package/dist/overlay-tests/typesafe.spec.d.ts +0 -2
  48. package/dist/overlay-tests/typesafe.spec.d.ts.map +0 -1
  49. package/dist/overlay-tests/typesafe.spec.js +0 -88
  50. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/typesafe.d.ts +0 -38
  51. package/dist/test/scripts/pw-locator-patch/dismiss-overlays/typesafe.d.ts.map +0 -1
  52. 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 detectProvider(webhookUrl) {
149
- if (webhookUrl.includes("webhook.site")) {
150
- return "webhook-site";
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 provider = detectProvider(webhookUrl);
164
- if (provider === "webhook-site") {
165
- return webhookSiteQuery(token, content);
166
- }
167
- return inboxQuery(token, content);
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.70.3",
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.6.0",
66
- "@empiricalrun/r2-uploader": "^0.11.9",
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": {
@@ -20,7 +20,7 @@ export default defineConfig({
20
20
  {
21
21
  name: "scoped-http-headers",
22
22
  testDir: "./src/test",
23
- testMatch: /scoped-http-headers\.spec\.ts/,
23
+ testMatch: /(scoped-http-headers|locator-handler-log)\.spec\.ts/,
24
24
  },
25
25
  {
26
26
  name: "regex-test",