@empiricalrun/playwright-utils 0.26.0 → 0.26.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.26.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b5a81a1: feat: add test case name to overlay dismissal traces
8
+ - 78e3aa4: fix: overlay prompt should always have general instructions
9
+ - Updated dependencies [99e4e6e]
10
+ - Updated dependencies [cc4cb5e]
11
+ - Updated dependencies [508565d]
12
+ - Updated dependencies [8da022c]
13
+ - @empiricalrun/test-gen@0.55.0
14
+ - @empiricalrun/llm@0.15.0
15
+
3
16
  ## 0.26.0
4
17
 
5
18
  ### Minor Changes
@@ -1,12 +1,13 @@
1
1
  import { Page } from "@playwright/test";
2
- import { OverlayElement } from "./types";
2
+ import type { TestFn } from "../../types";
3
+ import type { OverlayElement } from "./types";
3
4
  export declare function isErrorSupported(errorMessage: string | undefined): boolean;
4
5
  export declare class OverlayDismissAgent {
5
6
  private readonly page;
6
7
  private cachingCandidates;
7
8
  constructor(page: Page);
8
9
  saveToCache(): Promise<void>;
9
- run(originalError: any, reporter: (description: string) => void): Promise<void>;
10
+ run(originalError: any, reporter: (description: string) => void, testFn: TestFn): Promise<void>;
10
11
  private runAgent;
11
12
  }
12
13
  export declare function extractInterceptingElement(errorMessage: string): OverlayElement | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAOzC,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,WAKhE;AAED,qBAAa,mBAAmB;IAOlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IANjC,OAAO,CAAC,iBAAiB,CAIhB;gBAEoB,IAAI,EAAE,IAAI;IAEjC,WAAW;IAMX,GAAG,CACP,aAAa,EAAE,GAAG,EAClB,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,GACtC,OAAO,CAAC,IAAI,CAAC;YA4BF,QAAQ;CAgCvB;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAiC5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO9C,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,WAKhE;AAED,qBAAa,mBAAmB;IAOlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IANjC,OAAO,CAAC,iBAAiB,CAIhB;gBAEoB,IAAI,EAAE,IAAI;IAEjC,WAAW;IAMX,GAAG,CACP,aAAa,EAAE,GAAG,EAClB,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,EACvC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;YA4BF,QAAQ;CAiCvB;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAiC5B"}
@@ -25,7 +25,7 @@ class OverlayDismissAgent {
25
25
  await (0, cache_1.setCodeToCache)(candidate);
26
26
  }
27
27
  }
28
- async run(originalError, reporter) {
28
+ async run(originalError, reporter, testFn) {
29
29
  let element;
30
30
  try {
31
31
  element = extractInterceptingElement(originalError.message);
@@ -45,15 +45,16 @@ class OverlayDismissAgent {
45
45
  if (success) {
46
46
  return;
47
47
  }
48
- await this.runAgent(element, text);
48
+ await this.runAgent(element, text, testFn);
49
49
  }
50
50
  catch (agentError) {
51
51
  reporter(`Error during overlay dismissal agent execution: ${agentError.toString()}`);
52
52
  throw originalError;
53
53
  }
54
54
  }
55
- async runAgent(element, text) {
55
+ async runAgent(element, text, testFn) {
56
56
  const task = await (0, prompt_1.getTask)(this.page, element, text);
57
+ const trace = (0, utils_1.traceThis)(task, testFn);
57
58
  if (PREFERRED_AGENT === "inhouse-master") {
58
59
  const result = await (0, run_1.createTestUsingMasterAgent)({
59
60
  task,
@@ -69,7 +70,6 @@ class OverlayDismissAgent {
69
70
  });
70
71
  }
71
72
  else if (PREFERRED_AGENT === "openai-cua") {
72
- const trace = (0, utils_1.traceThis)(task);
73
73
  const result = await (0, run_1.createTestUsingComputerUseAgent)({
74
74
  page: this.page,
75
75
  task,
@@ -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,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"}
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,mBAyCzB"}
@@ -3,15 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTask = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  async function getTask(page, element, text) {
6
- if ((0, utils_1.isProductFruitsOverlay)(element)) {
7
- // TODO: Remove this special handling with app knowledge
8
- return promptForPFScenario(text);
9
- }
10
- else if (await isLeapChadsScenario(page)) {
11
- // TODO: Remove this special handling with app knowledge
12
- return promptForLeapChadsScenario();
13
- }
14
- const promptAddition = text
6
+ let promptAddition = text
15
7
  ? `
16
8
  In this case, the popup can be identified with its text content:
17
9
 
@@ -19,8 +11,18 @@ In this case, the popup can be identified with its text content:
19
11
  ${text}
20
12
  </popup_text_content>
21
13
  `
22
- : ``;
14
+ : "";
15
+ if ((0, utils_1.isProductFruitsOverlay)(element)) {
16
+ // TODO: Remove this special handling with app knowledge
17
+ promptAddition = promptForPFScenario(text);
18
+ }
19
+ else if (await isLeapChadsScenario(page)) {
20
+ // TODO: Remove this special handling with app knowledge
21
+ promptAddition = promptForLeapChadsScenario();
22
+ }
23
23
  let task = `
24
+ # General instructions for your task
25
+
24
26
  Find a way to dismiss the popup. If the popup is non dismissible or there is no popup then return immediately.
25
27
  Do all actions required to dismiss the popup - don't ask for user confirmation.
26
28
 
@@ -34,6 +36,8 @@ Examples of typical popups:
34
36
  4. Forms that capture traffic sources or persona information. Make up content for the input fields, if that's required to dismiss the popup.
35
37
  5. Anything else that can be dismissed by taking a few user actions.
36
38
 
39
+ # Instructions for this specific scenario
40
+
37
41
  ${promptAddition}`;
38
42
  return task;
39
43
  }
@@ -45,12 +49,12 @@ function promptForPFScenario(text) {
45
49
  <overlapper_element_text_content>
46
50
  ${text}
47
51
  </overlapper_element_text_content>`
48
- : undefined;
52
+ : "";
49
53
  return `
50
54
  We are attempting to do a click action on Target element.
51
55
 
52
56
  This action is failing because our Target element is covered with another element (called Overlapper).
53
- ${promptAddition || ""}
57
+ ${promptAddition}
54
58
 
55
59
  The only way to work around this is to Click on some other sidebar link element.
56
60
 
@@ -1,9 +1,9 @@
1
1
  import type { Page } from "@playwright/test";
2
2
  import type { TestFn } from "../../types";
3
- import { OverlayElement } from "./types";
3
+ import type { OverlayElement } from "./types";
4
4
  export declare function overlayDescription(element: OverlayElement | undefined): string | undefined;
5
5
  export declare function isProductFruitsOverlay(element: OverlayElement | undefined): boolean | undefined;
6
6
  export declare function textContent(pageRef: Page, element: OverlayElement | undefined): Promise<string | undefined>;
7
7
  export declare function annotateForReport(testFn: TestFn, description: string): void;
8
- export declare function traceThis(task: string): import("@empiricalrun/llm").TraceClient | undefined;
8
+ export declare function traceThis(task: string, testFn: TestFn): import("@empiricalrun/llm").TraceClient | undefined;
9
9
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,sBASrE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,uBAKzE;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,cAAc,GAAG,SAAS,+BAiDpC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAMpE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,uDAgBrC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/dismiss-overlays/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,sBASrE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,uBAKzE;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,cAAc,GAAG,SAAS,+BAiDpC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAMpE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uDAiBrD"}
@@ -76,10 +76,11 @@ function annotateForReport(testFn, description) {
76
76
  });
77
77
  }
78
78
  exports.annotateForReport = annotateForReport;
79
- function traceThis(task) {
79
+ function traceThis(task, testFn) {
80
80
  const metadata = {
81
81
  projectName: process.env.PROJECT_NAME ?? "",
82
82
  testRunId: process.env.TEST_RUN_GITHUB_ACTION_ID ?? "",
83
+ testCase: testFn.info().title,
83
84
  };
84
85
  const trace = (0, llm_1.createLangfuseTrace)({
85
86
  name: "overlay_dismiss",
@@ -39,7 +39,7 @@ function patchClick(LocatorClass, testFn) {
39
39
  // This will cause our overlay dismissal to not run.
40
40
  throw originalError;
41
41
  }
42
- await overlayDismiss.run(originalError, reporter);
42
+ await overlayDismiss.run(originalError, reporter, testFn);
43
43
  // Dismissal attempt finished (implicitly successful if no error thrown)
44
44
  reporter(`Overlay dismissal attempted, retrying original action.`);
45
45
  }
@@ -34,7 +34,7 @@ function patchHover(LocatorClass, testFn) {
34
34
  if (!(0, dismiss_overlays_1.isErrorSupported)(originalError.message)) {
35
35
  throw originalError;
36
36
  }
37
- await overlayDismiss.run(originalError, reporter);
37
+ await overlayDismiss.run(originalError, reporter, testFn);
38
38
  reporter(`Overlay dismissal attempted, retrying original action.`);
39
39
  }
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
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.8",
41
+ "@empiricalrun/llm": "^0.15.0",
42
42
  "@empiricalrun/r2-uploader": "^0.3.8",
43
- "@empiricalrun/test-gen": "^0.54.1"
43
+ "@empiricalrun/test-gen": "^0.55.0"
44
44
  },
45
45
  "scripts": {
46
46
  "dev": "tsc --build --watch",