@empiricalrun/playwright-utils 0.25.27 → 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 +23 -0
- package/dist/reporter/util.d.ts.map +1 -1
- package/dist/reporter/util.js +5 -2
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/index.d.ts +3 -2
- 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 +4 -4
- 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 +16 -12
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/utils.d.ts +2 -2
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/utils.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/dismiss-overlays/utils.js +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/click.js +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/hover.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.26.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 9c64161: fix: rm -rf magic token, now using API key auth
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- @empiricalrun/test-gen@0.54.1
|
|
25
|
+
|
|
3
26
|
## 0.25.27
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/reporter/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;;AAEH,OAAO,EAAS,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/reporter/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;;AAEH,OAAO,EAAS,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAI9C,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAmB7D;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAAG,SAAS,UAMhC;AAED,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAyCD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ;;;EAwBrD;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAyDf;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GACnC,GAAG,CAIL"}
|
package/dist/reporter/util.js
CHANGED
|
@@ -28,7 +28,6 @@ const utils_1 = require("playwright-core/lib/utils");
|
|
|
28
28
|
const utilsBundle_1 = require("playwright-core/lib/utilsBundle");
|
|
29
29
|
const logger_1 = require("../logger");
|
|
30
30
|
const folderToPackageJsonPath = new Map();
|
|
31
|
-
const API_TOKEN = "weQPMWKT";
|
|
32
31
|
function getPackageJsonPath(folderPath) {
|
|
33
32
|
const cached = folderToPackageJsonPath.get(folderPath);
|
|
34
33
|
if (cached !== undefined)
|
|
@@ -135,12 +134,16 @@ async function sendTestCaseUpdateToDashboard(params) {
|
|
|
135
134
|
console.warn("No dashboard domain found. Skipping send message to dashboard.");
|
|
136
135
|
return;
|
|
137
136
|
}
|
|
137
|
+
if (!process.env.EMPIRICALRUN_API_KEY) {
|
|
138
|
+
console.error("No API token found. Skipping send message to dashboard.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
138
141
|
await (0, async_retry_1.default)(async () => {
|
|
139
142
|
const response = await fetch(`${DOMAIN}/api/test-runs/events`, {
|
|
140
143
|
method: "PUT",
|
|
141
144
|
headers: {
|
|
142
145
|
"Content-Type": "application/json",
|
|
143
|
-
Authorization:
|
|
146
|
+
Authorization: `Bearer ${process.env.EMPIRICALRUN_API_KEY}`,
|
|
144
147
|
},
|
|
145
148
|
body: JSON.stringify(requestBody),
|
|
146
149
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Page } from "@playwright/test";
|
|
2
|
-
import {
|
|
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;
|
|
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,
|
|
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
|
-
|
|
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
|
-
:
|
|
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;
|
|
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.
|
|
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.
|
|
41
|
+
"@empiricalrun/llm": "^0.15.0",
|
|
42
42
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
43
|
-
"@empiricalrun/test-gen": "^0.
|
|
43
|
+
"@empiricalrun/test-gen": "^0.55.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"dev": "tsc --build --watch",
|