@empiricalrun/test-gen 0.46.0 → 0.46.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
|
@@ -7,6 +7,8 @@ const test_1 = require("@playwright/test");
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const http_server_1 = __importDefault(require("http-server"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const utils_1 = require("../../browsing/utils");
|
|
11
|
+
const element_annotation_1 = require("../element-annotation");
|
|
10
12
|
const run_1 = require("../run");
|
|
11
13
|
let server;
|
|
12
14
|
let PORT = 2345;
|
|
@@ -70,3 +72,23 @@ test_1.test.afterAll(() => {
|
|
|
70
72
|
(0, test_1.expect)(icons.length).toBe(4); // 1 for each unique icon
|
|
71
73
|
fs_1.default.unlinkSync(iconsRegistryFile);
|
|
72
74
|
});
|
|
75
|
+
(0, test_1.test)("annotate and enrich annotations correctly", async ({ page }) => {
|
|
76
|
+
await (0, utils_1.injectPwLocatorGenerator)(page);
|
|
77
|
+
await page.goto(`http://localhost:${PORT}/iframe-elements.html`);
|
|
78
|
+
const { annotationKeys: keys } = await (0, element_annotation_1.getAnnotationKeys)({
|
|
79
|
+
page,
|
|
80
|
+
preference: {
|
|
81
|
+
actionType: "all",
|
|
82
|
+
},
|
|
83
|
+
options: {},
|
|
84
|
+
});
|
|
85
|
+
console.log(keys);
|
|
86
|
+
(0, test_1.expect)(keys.length).toBe(6);
|
|
87
|
+
// 2 icons: 1 in main frame, 1 in iframe
|
|
88
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("icon") && k.text.includes("close"))
|
|
89
|
+
.length).toBe(2);
|
|
90
|
+
// 2 text inputs: 1 in main frame, 1 in iframe
|
|
91
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("Enter your name")).length).toBe(2);
|
|
92
|
+
// 2 clickable divs: 1 in main frame, 1 in iframe
|
|
93
|
+
(0, test_1.expect)(keys.filter((k) => k.text.includes("Lorem Ipsum")).length).toBe(2);
|
|
94
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2DjD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,EACP,UAAU,GACX,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,oBAAoB,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA8C9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EACN,KAAK,GACL,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,WAAW,GACtB,UAAU,CAAC,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAgBF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,EACP,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC,
|
|
1
|
+
{"version":3,"file":"element-annotation.d.ts","sourceRoot":"","sources":["../../../src/agent/master/element-annotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAQlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2DjD,wBAAsB,oBAAoB,CAAC,EACzC,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,KAAK,EACL,GAAG,EACH,OAAO,EACP,UAAU,GACX,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,oBAAoB,CAAC;CAClC,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA8C9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EACN,KAAK,GACL,UAAU,CAAC,IAAI,GACf,UAAU,CAAC,WAAW,GACtB,UAAU,CAAC,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC;AAgBF,wBAAsB,iBAAiB,CAAC,EACtC,IAAI,EACJ,UAAU,EACV,OAAO,EACP,KAAK,GACN,EAAE;IACD,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,oBAAoB,CAAC;IACjC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC,CAoFD"}
|
|
@@ -111,15 +111,30 @@ async function getAnnotationKeys({ page, preference, options, trace, }) {
|
|
|
111
111
|
const annotations = Object.entries(
|
|
112
112
|
// @ts-ignore
|
|
113
113
|
window.annotationInstance.annotations).map(([key, value]) => {
|
|
114
|
+
// Helper function to safely get text content
|
|
115
|
+
const getTextContent = (node) => {
|
|
116
|
+
try {
|
|
117
|
+
return node?.innerText?.trim() || null;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Helper function to safely get placeholder
|
|
124
|
+
const getPlaceholder = (node) => {
|
|
125
|
+
try {
|
|
126
|
+
return node?.placeholder?.trim() || null;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
114
132
|
return {
|
|
115
133
|
elementID: key,
|
|
116
|
-
innerText: value.node
|
|
134
|
+
innerText: getTextContent(value.node),
|
|
117
135
|
innerHTML: value.node.innerHTML,
|
|
118
136
|
outerHTML: value.node.outerHTML,
|
|
119
|
-
placeholder: value.node
|
|
120
|
-
value.node instanceof HTMLTextAreaElement
|
|
121
|
-
? value.node.placeholder
|
|
122
|
-
: null,
|
|
137
|
+
placeholder: getPlaceholder(value.node),
|
|
123
138
|
};
|
|
124
139
|
});
|
|
125
140
|
const fullPageHTML = document.documentElement.outerHTML;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"ts-morph": "^23.0.0",
|
|
75
75
|
"tsx": "^4.16.2",
|
|
76
76
|
"typescript": "^5.3.3",
|
|
77
|
-
"@empiricalrun/
|
|
77
|
+
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
78
78
|
"@empiricalrun/reporter": "^0.23.1",
|
|
79
|
-
"@empiricalrun/
|
|
79
|
+
"@empiricalrun/llm": "^0.9.35"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@playwright/test": "1.47.1",
|