@empiricalrun/playwright-utils 0.25.11 → 0.25.13

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,22 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.25.13
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0aeca9d]
8
+ - @empiricalrun/llm@0.14.2
9
+ - @empiricalrun/test-gen@0.53.2
10
+
11
+ ## 0.25.12
12
+
13
+ ### Patch Changes
14
+
15
+ - d37b0b7: fix: override prompt for LeapChads overlay
16
+ - Updated dependencies [40fcbc2]
17
+ - @empiricalrun/llm@0.14.1
18
+ - @empiricalrun/test-gen@0.53.1
19
+
3
20
  ## 0.25.11
4
21
 
5
22
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAsB7C,wBAAsB,cAAc,CAAC,EACnC,GAAG,EACH,IAAI,EACJ,IAAI,GACL,EAAE;IACD,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,iBAiCA;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,GAAG,EACH,IAAI,GACL,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAkChC"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAiB7C,wBAAsB,cAAc,CAAC,EACnC,GAAG,EACH,IAAI,EACJ,IAAI,GACL,EAAE;IACD,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd,iBAkCA;AAED,wBAAsB,gBAAgB,CAAC,EACrC,IAAI,EACJ,GAAG,EACH,IAAI,GACL,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAkChC"}
@@ -7,10 +7,6 @@ exports.executeFromCache = exports.setCodeToCache = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const CACHE_FILE = path_1.default.join(process.cwd(), ".empiricalrun", `overlay-cache.json`);
10
- function isCacheSupported(code) {
11
- // Current release only supports caching for code that contains 1 `click` only
12
- return code.includes("click") && code.trim().split("\n").length <= 1;
13
- }
14
10
  function normalizeString(str) {
15
11
  // Replace all whitespace sequences with a single space
16
12
  return str.replace(/\s+/g, " ").trim();
@@ -20,7 +16,8 @@ async function setCodeToCache({ dom, text, code, }) {
20
16
  // At least one of the two is required
21
17
  return;
22
18
  }
23
- if (!isCacheSupported(code)) {
19
+ if (process.env.TEST_GEN_TOKEN) {
20
+ // No caching for test gen sessions (we don't want steps to get committed)
24
21
  return;
25
22
  }
26
23
  const obj = {
@@ -16,7 +16,7 @@ function isErrorSupported(errorMessage) {
16
16
  exports.isErrorSupported = isErrorSupported;
17
17
  async function runAgentOnOverlay(pageRef, element) {
18
18
  const text = await (0, utils_1.textContent)(pageRef, element);
19
- const task = (0, prompt_1.getTask)(element, text);
19
+ const task = await (0, prompt_1.getTask)(pageRef, element, text);
20
20
  const { success } = await (0, cache_1.executeFromCache)({
21
21
  page: pageRef,
22
22
  dom: element?.interceptor,
@@ -1,3 +1,4 @@
1
+ import type { Page } from "playwright-core";
1
2
  import { OverlayElement } from "./types";
2
- export declare function getTask(element: OverlayElement | undefined, text: string | undefined): string;
3
+ export declare function getTask(page: Page, element: OverlayElement | undefined, text: string | undefined): Promise<string>;
3
4
  //# sourceMappingURL=prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,wBAAgB,OAAO,CACrB,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,GAAG,SAAS,UAkCzB"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,IAAI,EAAE,MAAM,GAAG,SAAS,mBAqCzB"}
@@ -2,11 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTask = void 0;
4
4
  const utils_1 = require("./utils");
5
- function getTask(element, text) {
5
+ async function getTask(page, element, text) {
6
6
  if ((0, utils_1.isProductFruitsOverlay)(element)) {
7
7
  // TODO: Remove this special handling with app knowledge
8
8
  return promptForPFScenario(text);
9
9
  }
10
+ else if (await isLeapChadsScenario(page)) {
11
+ // TODO: Remove this special handling with app knowledge
12
+ return promptForLeapChadsScenario();
13
+ }
10
14
  const promptAddition = text
11
15
  ? `
12
16
  In this case, the popup can be identified with its text content:
@@ -53,3 +57,18 @@ The only way to work around this is to Click on some other sidebar link element.
53
57
  Don't reattempt the click on Target element, your job is done after the first click.
54
58
  `;
55
59
  }
60
+ async function isLeapChadsScenario(page) {
61
+ const button = page.getByRole("button", { name: "Join the Chads" });
62
+ const isVisible = await button.isVisible();
63
+ return isVisible;
64
+ }
65
+ function promptForLeapChadsScenario() {
66
+ return `We are attempting to do a click action on an element on this screen, but that action is obstructed
67
+ by a popup element. To dismiss this popup, we need your help to
68
+
69
+ 1. Click on the "Join the Chads" button, which will dismiss the popup.
70
+ 2. Click on "Home" in the bottom navigation bar.
71
+
72
+ Do these actions, and nothing else.
73
+ `;
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.25.11",
3
+ "version": "0.25.13",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -38,9 +38,9 @@
38
38
  "mailosaur": "^8.6.1",
39
39
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
40
40
  "rimraf": "^6.0.1",
41
- "@empiricalrun/llm": "^0.14.0",
41
+ "@empiricalrun/llm": "^0.14.2",
42
42
  "@empiricalrun/r2-uploader": "^0.3.8",
43
- "@empiricalrun/test-gen": "^0.53.0"
43
+ "@empiricalrun/test-gen": "^0.53.2"
44
44
  },
45
45
  "scripts": {
46
46
  "dev": "tsc --build --watch",