@empiricalrun/test-gen 0.46.4 → 0.46.6
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 +13 -0
- package/dist/agent/codegen/update-flow.js +1 -1
- package/dist/agent/diagnosis-agent/index.js +1 -1
- package/dist/agent/enrich-prompt/index.js +1 -1
- package/dist/agent/master/browser-tests/index.spec.js +1 -1
- package/dist/agent/master/icon-descriptor/index.d.ts +1 -1
- package/dist/agent/master/icon-descriptor/index.d.ts.map +1 -1
- package/dist/agent/master/icon-descriptor/index.js +48 -9
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.46.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8065639: fix: check for svg in descendants of provided html element and not direct children
|
|
8
|
+
- f5f12f5: feat: Move icons knowledge to .empiricalrun directory
|
|
9
|
+
|
|
10
|
+
## 0.46.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- cce1c90: fix: nesting for llm tracing
|
|
15
|
+
|
|
3
16
|
## 0.46.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -42,7 +42,7 @@ async function getUpdateTestCodeCompletion({ testCase, testFileContent, testFile
|
|
|
42
42
|
currentScenarioCodeBlock,
|
|
43
43
|
});
|
|
44
44
|
const llm = new llm_1.LLM({
|
|
45
|
-
trace,
|
|
45
|
+
trace: promptSpan,
|
|
46
46
|
provider: "anthropic",
|
|
47
47
|
defaultModel: "claude-3-5-sonnet-20240620",
|
|
48
48
|
providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
|
|
@@ -64,7 +64,7 @@ async function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logg
|
|
|
64
64
|
const llm = new llm_1.LLM({
|
|
65
65
|
provider: "openai",
|
|
66
66
|
defaultModel: "o1",
|
|
67
|
-
trace,
|
|
67
|
+
trace: failureDiagnosisSpan,
|
|
68
68
|
});
|
|
69
69
|
// TODO: make this dynamic in nature. the prompts should be made receipe
|
|
70
70
|
// which will help to get rid of if else logic
|
|
@@ -52,7 +52,7 @@ const enrichPromptWithFailingLine = async ({ trace, testBlock, testFilePath, sug
|
|
|
52
52
|
userMessage: suggestionForFix,
|
|
53
53
|
});
|
|
54
54
|
const llm = new llm_1.LLM({
|
|
55
|
-
trace,
|
|
55
|
+
trace: enrichedPromptSpan,
|
|
56
56
|
providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
|
|
57
57
|
provider: "anthropic",
|
|
58
58
|
defaultModel: "claude-3-5-sonnet-latest",
|
|
@@ -71,7 +71,7 @@ test("agent can click icons accurately", async ({ page, server }) => {
|
|
|
71
71
|
(0, test_1.expect)(response.code).toContain("page.locator");
|
|
72
72
|
(0, test_1.expect)(response.code).toContain("click()");
|
|
73
73
|
// Validate icons registry
|
|
74
|
-
const iconsRegistryFile = path_1.default.join(process.cwd(), "icons.json");
|
|
74
|
+
const iconsRegistryFile = path_1.default.join(process.cwd(), ".empiricalrun", "icons.json");
|
|
75
75
|
const icons = JSON.parse(fs_1.default.readFileSync(iconsRegistryFile, "utf-8"));
|
|
76
76
|
(0, test_1.expect)(icons.length).toBeGreaterThan(0);
|
|
77
77
|
// Commenting out this check since with parallel test executions,
|
|
@@ -11,7 +11,7 @@ export declare function generateKey(htmlString: string): string;
|
|
|
11
11
|
export declare function reverseKey(hash: string): string;
|
|
12
12
|
export declare function createNodeFromHTML(htmlString: string): {
|
|
13
13
|
node: Element | null;
|
|
14
|
-
|
|
14
|
+
descendant: Element[];
|
|
15
15
|
};
|
|
16
16
|
export declare function getIconDescription({ htmlString, pageHtml, trace, }: {
|
|
17
17
|
htmlString: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/icon-descriptor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/icon-descriptor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,KAAK,aAAa,GAAG;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,KAAK,CAAC,aAAa,CAAC,CAoDzD;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM;;;EAUpD;AAqKD,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,QAAQ,EACR,KAAK,GACN,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkC9B"}
|
|
@@ -10,18 +10,49 @@ const jsdom_1 = require("jsdom");
|
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const constants_1 = require("../../../constants");
|
|
12
12
|
const normalize_svg_1 = require("./normalize-svg");
|
|
13
|
-
const
|
|
13
|
+
const OLD_ICONS_KNOWLEDGE_PATH = path_1.default.join(process.cwd(), "icons.json");
|
|
14
|
+
const EMPIRICAL_RUN_DIR = path_1.default.join(process.cwd(), ".empiricalrun");
|
|
15
|
+
const ICONS_KNOWLEDGE_PATH = path_1.default.join(EMPIRICAL_RUN_DIR, "icons.json");
|
|
14
16
|
function loadIconsKnowledge() {
|
|
15
|
-
if
|
|
17
|
+
// Check if file exists in the new location
|
|
18
|
+
if (fs_1.default.existsSync(ICONS_KNOWLEDGE_PATH)) {
|
|
19
|
+
const raw = fs_1.default.readFileSync(ICONS_KNOWLEDGE_PATH, "utf-8");
|
|
20
|
+
if (raw) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
console.log("error parsing iconsKnowledge json");
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
return [];
|
|
17
30
|
}
|
|
18
|
-
|
|
19
|
-
if (
|
|
31
|
+
// Check if file exists in the old location and move it if it does
|
|
32
|
+
if (fs_1.default.existsSync(OLD_ICONS_KNOWLEDGE_PATH)) {
|
|
20
33
|
try {
|
|
21
|
-
|
|
34
|
+
const raw = fs_1.default.readFileSync(OLD_ICONS_KNOWLEDGE_PATH, "utf-8");
|
|
35
|
+
let iconData = [];
|
|
36
|
+
if (raw) {
|
|
37
|
+
try {
|
|
38
|
+
iconData = JSON.parse(raw);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.log("error parsing iconsKnowledge json from old location");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Create the directory and move the file
|
|
45
|
+
if (!fs_1.default.existsSync(EMPIRICAL_RUN_DIR)) {
|
|
46
|
+
fs_1.default.mkdirSync(EMPIRICAL_RUN_DIR, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
// Save to new location
|
|
49
|
+
fs_1.default.writeFileSync(ICONS_KNOWLEDGE_PATH, JSON.stringify(iconData, null, 2), "utf-8");
|
|
50
|
+
// Remove the old file
|
|
51
|
+
fs_1.default.unlinkSync(OLD_ICONS_KNOWLEDGE_PATH);
|
|
52
|
+
return iconData;
|
|
22
53
|
}
|
|
23
54
|
catch (err) {
|
|
24
|
-
console.log("
|
|
55
|
+
console.log("Error moving icons knowledge file:", err);
|
|
25
56
|
return [];
|
|
26
57
|
}
|
|
27
58
|
}
|
|
@@ -29,8 +60,16 @@ function loadIconsKnowledge() {
|
|
|
29
60
|
}
|
|
30
61
|
exports.loadIconsKnowledge = loadIconsKnowledge;
|
|
31
62
|
async function saveIconsKnowledge(iconsData) {
|
|
63
|
+
// Ensure the directory exists
|
|
64
|
+
if (!fs_1.default.existsSync(EMPIRICAL_RUN_DIR)) {
|
|
65
|
+
fs_1.default.mkdirSync(EMPIRICAL_RUN_DIR, { recursive: true });
|
|
66
|
+
}
|
|
32
67
|
const content = JSON.stringify(iconsData, null, 2);
|
|
33
68
|
fs_1.default.writeFileSync(ICONS_KNOWLEDGE_PATH, content, "utf-8");
|
|
69
|
+
// If old file exists, remove it
|
|
70
|
+
if (fs_1.default.existsSync(OLD_ICONS_KNOWLEDGE_PATH)) {
|
|
71
|
+
fs_1.default.unlinkSync(OLD_ICONS_KNOWLEDGE_PATH);
|
|
72
|
+
}
|
|
34
73
|
}
|
|
35
74
|
exports.saveIconsKnowledge = saveIconsKnowledge;
|
|
36
75
|
function generateKey(htmlString) {
|
|
@@ -51,7 +90,7 @@ function createNodeFromHTML(htmlString) {
|
|
|
51
90
|
const node = document.body.firstElementChild;
|
|
52
91
|
return {
|
|
53
92
|
node, // Return the first node
|
|
54
|
-
|
|
93
|
+
descendant: node ? Array.from(node.querySelectorAll("*")) : [], // Convert HTMLCollection to array
|
|
55
94
|
};
|
|
56
95
|
}
|
|
57
96
|
exports.createNodeFromHTML = createNodeFromHTML;
|
|
@@ -95,7 +134,7 @@ function processSvgWithUseElements(svgElement, document) {
|
|
|
95
134
|
function getHtmlForDescription(elementHtml, pageHtml) {
|
|
96
135
|
const dom = new jsdom_1.JSDOM(pageHtml);
|
|
97
136
|
const page = dom.window.document;
|
|
98
|
-
const { node,
|
|
137
|
+
const { node, descendant } = createNodeFromHTML(elementHtml);
|
|
99
138
|
if (!node) {
|
|
100
139
|
return undefined;
|
|
101
140
|
}
|
|
@@ -103,7 +142,7 @@ function getHtmlForDescription(elementHtml, pageHtml) {
|
|
|
103
142
|
processSvgWithUseElements(node, page);
|
|
104
143
|
return node.outerHTML;
|
|
105
144
|
}
|
|
106
|
-
const svgChildren =
|
|
145
|
+
const svgChildren = descendant?.filter((child) => child?.tagName?.toLowerCase() === "svg");
|
|
107
146
|
if (svgChildren && svgChildren.length > 0) {
|
|
108
147
|
for (const svgChild of svgChildren) {
|
|
109
148
|
processSvgWithUseElements(svgChild, page);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.6",
|
|
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/reporter": "^0.23.1",
|
|
77
77
|
"@empiricalrun/r2-uploader": "^0.3.8",
|
|
78
|
-
"@empiricalrun/
|
|
78
|
+
"@empiricalrun/llm": "^0.9.35"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@playwright/test": "1.47.1",
|