@empiricalrun/test-gen 0.46.6 → 0.46.7
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 +6 -0
- package/dist/agent/master/browser-tests/index.spec.js +2 -3
- package/dist/browser-injected-scripts/annotate-elements.js +2 -5
- package/dist/browser-injected-scripts/annotate-elements.spec.js +1 -1
- package/dist/browser-injected-scripts/annotate-elements.spec.ts +25 -26
- package/package.json +3 -3
- package/playwright.config.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -103,7 +103,7 @@ test("fill action with multiple pages", async ({ context }) => {
|
|
|
103
103
|
const page1 = await context.newPage();
|
|
104
104
|
const page2 = await context.newPage();
|
|
105
105
|
const response = await (0, run_1.createTestUsingMasterAgent)({
|
|
106
|
-
task: `goto empirical.run on page1 and goto
|
|
106
|
+
task: `goto empirical.run on page1 and goto github.com/search in page2. Enter text empirical on page2 and click on search.`,
|
|
107
107
|
page: page2,
|
|
108
108
|
options: {},
|
|
109
109
|
scopeVars: {
|
|
@@ -116,7 +116,6 @@ test("fill action with multiple pages", async ({ context }) => {
|
|
|
116
116
|
console.log(response.code);
|
|
117
117
|
const lines = response.code.split("\n");
|
|
118
118
|
(0, test_1.expect)(lines.find((l) => l.match(/^await page1\.goto(.+)empirical\.run/))).toBeTruthy();
|
|
119
|
-
(0, test_1.expect)(lines.find((l) => l.match(/^await page2\.goto(.+)
|
|
119
|
+
(0, test_1.expect)(lines.find((l) => l.match(/^await page2\.goto(.+)github\.com\/search/))).toBeTruthy();
|
|
120
120
|
(0, test_1.expect)(lines.find((l) => l.match(/^await page2(.+)fill(.+)empirical/))).toBeTruthy();
|
|
121
|
-
(0, test_1.expect)(lines.find((l) => l.match(/^await page2(.+)click/))).toBeTruthy();
|
|
122
121
|
});
|
|
@@ -262,12 +262,9 @@ function annotateElementsWithPreference({
|
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
//
|
|
265
|
+
// Some special handling for Tailwind CSS and Vue
|
|
266
266
|
if (!isClickable) {
|
|
267
|
-
|
|
268
|
-
if (className && className.toLowerCase().includes("button")) {
|
|
269
|
-
isClickable = true;
|
|
270
|
-
} else if (element.classList.contains("cursor-pointer")) {
|
|
267
|
+
if (element.classList.contains("cursor-pointer")) {
|
|
271
268
|
isClickable = true;
|
|
272
269
|
} else if (element.classList.contains("v-list-item--link")) {
|
|
273
270
|
// vue specific click handling
|
|
@@ -183,7 +183,7 @@ const action_tool_calls_1 = require("../agent/master/action-tool-calls");
|
|
|
183
183
|
test_1.test.expect(annotations.length).toBe(1);
|
|
184
184
|
test_1.test.expect(annotations[0]?.tagName).toBe("DIV");
|
|
185
185
|
});
|
|
186
|
-
test_1.test
|
|
186
|
+
(0, test_1.test)("should not annotate children that don't have onClick handler", async ({ page, }) => {
|
|
187
187
|
await page.setContent(`<div class="button-outer" onclick="alert('clicked')">
|
|
188
188
|
<div class="button-inner">Click me</div>
|
|
189
189
|
</div>`);
|
|
@@ -300,34 +300,33 @@ test("should only annotate given text on quizziz page", async ({ page }) => {
|
|
|
300
300
|
test.expect(annotations[0]?.tagName).toBe("DIV");
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
test
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
test("should not annotate children that don't have onClick handler", async ({
|
|
304
|
+
page,
|
|
305
|
+
}) => {
|
|
306
|
+
await page.setContent(
|
|
307
|
+
`<div class="button-outer" onclick="alert('clicked')">
|
|
308
308
|
<div class="button-inner">Click me</div>
|
|
309
309
|
</div>`,
|
|
310
|
-
|
|
310
|
+
);
|
|
311
311
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
await page.addScriptTag({
|
|
313
|
+
path: path.resolve(__dirname, "./annotate-elements.js"),
|
|
314
|
+
});
|
|
315
315
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return Object.entries(annotations).map(([hint, config]) => ({
|
|
321
|
-
hint,
|
|
322
|
-
innerText: config.node.innerText?.toLowerCase().trim(),
|
|
323
|
-
tagName: config.node.tagName,
|
|
324
|
-
testId: config.node.getAttribute("data-testid"),
|
|
325
|
-
className: config.node.className,
|
|
326
|
-
}));
|
|
327
|
-
});
|
|
316
|
+
const annotations = await page.evaluate(() => {
|
|
317
|
+
// eslint-disable-next-line no-undef
|
|
318
|
+
const { annotations } = annotateElementsWithPreference();
|
|
328
319
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
)
|
|
320
|
+
return Object.entries(annotations).map(([hint, config]) => ({
|
|
321
|
+
hint,
|
|
322
|
+
innerText: config.node.innerText?.toLowerCase().trim(),
|
|
323
|
+
tagName: config.node.tagName,
|
|
324
|
+
testId: config.node.getAttribute("data-testid"),
|
|
325
|
+
className: config.node.className,
|
|
326
|
+
}));
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
console.log(annotations);
|
|
330
|
+
test.expect(annotations.length).toBe(1);
|
|
331
|
+
test.expect(annotations[0].className).toBe("button-outer");
|
|
332
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"ts-morph": "^23.0.0",
|
|
74
74
|
"tsx": "^4.16.2",
|
|
75
75
|
"typescript": "^5.3.3",
|
|
76
|
-
"@empiricalrun/
|
|
76
|
+
"@empiricalrun/llm": "^0.9.35",
|
|
77
77
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
78
|
-
"@empiricalrun/
|
|
78
|
+
"@empiricalrun/reporter": "^0.23.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@playwright/test": "1.47.1",
|
package/playwright.config.ts
CHANGED
|
@@ -11,4 +11,14 @@ export default defineConfig({
|
|
|
11
11
|
timeout: 240_000,
|
|
12
12
|
fullyParallel: true,
|
|
13
13
|
workers: "50%",
|
|
14
|
+
use: {
|
|
15
|
+
launchOptions: {
|
|
16
|
+
args: [
|
|
17
|
+
"--disable-web-security",
|
|
18
|
+
"--disable-site-isolation-trials",
|
|
19
|
+
"--disable-features=IsolateOrigins,site-per-process",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
bypassCSP: true,
|
|
23
|
+
},
|
|
14
24
|
});
|