@empiricalrun/playwright-utils 0.25.10 → 0.25.12
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 +19 -0
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/cache.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/cache.js +2 -5
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.js +1 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/prompt.d.ts +2 -1
- 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 +20 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @empiricalrun/playwright-utils
|
|
2
2
|
|
|
3
|
+
## 0.25.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d37b0b7: fix: override prompt for LeapChads overlay
|
|
8
|
+
- Updated dependencies [40fcbc2]
|
|
9
|
+
- @empiricalrun/llm@0.14.1
|
|
10
|
+
- @empiricalrun/test-gen@0.53.1
|
|
11
|
+
|
|
12
|
+
## 0.25.11
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [d1d682d]
|
|
17
|
+
- Updated dependencies [8533602]
|
|
18
|
+
- Updated dependencies [e8035d6]
|
|
19
|
+
- @empiricalrun/test-gen@0.53.0
|
|
20
|
+
- @empiricalrun/llm@0.14.0
|
|
21
|
+
|
|
3
22
|
## 0.25.10
|
|
4
23
|
|
|
5
24
|
### 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;
|
|
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 (
|
|
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,
|
|
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.
|
|
3
|
+
"version": "0.25.12",
|
|
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.
|
|
41
|
+
"@empiricalrun/llm": "^0.14.1",
|
|
42
42
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
43
|
-
"@empiricalrun/test-gen": "^0.
|
|
43
|
+
"@empiricalrun/test-gen": "^0.53.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"dev": "tsc --build --watch",
|