@empiricalrun/test-gen 0.37.4 → 0.38.2
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 +24 -0
- package/browser-injected-scripts/annotate-elements.js +2 -1
- package/dist/agent/browsing/run.js +1 -1
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +3 -2
- package/dist/agent/codegen/utils.js +1 -1
- package/dist/agent/master/run.d.ts +2 -1
- package/dist/agent/master/run.d.ts.map +1 -1
- package/dist/agent/master/run.js +14 -14
- package/dist/agent/planner/run.d.ts +8 -0
- package/dist/agent/planner/run.d.ts.map +1 -0
- package/dist/agent/planner/run.js +75 -0
- package/dist/bin/index.js +14 -3
- package/dist/bin/utils/context.d.ts +1 -0
- package/dist/bin/utils/context.d.ts.map +1 -1
- package/dist/bin/utils/context.js +16 -1
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +10 -11
- package/dist/bin/utils/scenarios/index.d.ts.map +1 -1
- package/dist/bin/utils/scenarios/index.js +1 -0
- package/dist/browser-injected-scripts/annotate-elements.js +2 -1
- package/dist/evals/master-agent.evals.d.ts.map +1 -1
- package/dist/evals/master-agent.evals.js +2 -1
- package/dist/reporter/index.d.ts.map +1 -1
- package/dist/reporter/index.js +23 -18
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.38.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 132c2b4: fix: generation assets failure shouldnt stop test generation
|
|
8
|
+
- 213c357: fix: added available annotations in master agent prompt
|
|
9
|
+
|
|
10
|
+
## 0.38.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c2cf877: fix: get appropriate skill should return correct file path
|
|
15
|
+
|
|
16
|
+
## 0.38.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 2444057: feat: add support for planner agent
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 96bc299: fix: extract page vars is failing
|
|
25
|
+
- edce85d: fix: annotate elements where opacity is not set
|
|
26
|
+
|
|
3
27
|
## 0.37.4
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -135,7 +135,8 @@ window.annotateClickableElements = function annotateClickableElements(
|
|
|
135
135
|
if (
|
|
136
136
|
style.display === "none" ||
|
|
137
137
|
style.visibility === "hidden" ||
|
|
138
|
-
|
|
138
|
+
// This is done for cases where opacity is undefined
|
|
139
|
+
// parseFloat(style.opacity) === 0
|
|
139
140
|
style.pointerEvents === "none"
|
|
140
141
|
) {
|
|
141
142
|
return false;
|
|
@@ -35,7 +35,7 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
|
|
|
35
35
|
const playwrightConfig = await (0, utils_2.readPlaywrightConfig)();
|
|
36
36
|
// detect the playwright project name for the given test file and playwright config
|
|
37
37
|
const project = await (0, utils_2.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
|
|
38
|
-
const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(
|
|
38
|
+
const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(filePathToUpdate);
|
|
39
39
|
console.log(`Detected playwright project name: ${project}`);
|
|
40
40
|
// run playwright test which will internally run the master agent
|
|
41
41
|
const teardownFileRegex = /.*\.teardown\.ts/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAK3D,OAAO,EAAE,IAAI,EAAE,MAAM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EACT,eAAoB,EACpB,gBAAqB,EACrB,UAAyC,GAC1C,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,8EASA;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAuBb,SAAS;CAKjB"}
|
|
@@ -101,6 +101,7 @@ async function prepareFileForUpdateScenario(genConfig, trace) {
|
|
|
101
101
|
const updatedTestFileContent = newContentsWithTestOnly(testFileContent, testBlock, testBlock, parentDescribe?.getText() || "");
|
|
102
102
|
await fs_extra_1.default.writeFile(specPath, updatedTestFileContent);
|
|
103
103
|
}
|
|
104
|
+
return createTestFilePath;
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
107
|
* Function to prepare test file for master agent to run
|
|
@@ -147,8 +148,8 @@ async function prepareFileForMasterAgent(genConfig, trace) {
|
|
|
147
148
|
});
|
|
148
149
|
await fs_extra_1.default.writeFile(specPath, updatedContent, "utf-8");
|
|
149
150
|
}
|
|
150
|
-
await prepareFileForUpdateScenario(genConfig, prepareFileSpan);
|
|
151
|
-
return
|
|
151
|
+
const updatePath = await prepareFileForUpdateScenario(genConfig, prepareFileSpan);
|
|
152
|
+
return updatePath;
|
|
152
153
|
}
|
|
153
154
|
exports.prepareFileForMasterAgent = prepareFileForMasterAgent;
|
|
154
155
|
function newContentsWithTestOnly(existingContents, originalTestBlock, updatedTestBlock, parentDescribeBlock) {
|
|
@@ -69,7 +69,7 @@ function extractTestStepsSuggestions(input) {
|
|
|
69
69
|
const regex = /<subtask>(.*?)<\/subtask>[\s\S]*?<reason>([\s\S]*?)<\/reason>[\s\S]*?<file_import_path>([\s\S]*?)<\/file_import_path>[\s\S]*?<usage_example>([\s\S]*?)<\/usage_example>[\s\S]*?<method_name>([\s\S]*?)<\/method_name>/g;
|
|
70
70
|
let match;
|
|
71
71
|
while ((match = regex.exec(input)) !== null) {
|
|
72
|
-
const [, testStep, filePath, usageExample,
|
|
72
|
+
const [, testStep, reason, filePath, usageExample, methodName] = match;
|
|
73
73
|
result.push({
|
|
74
74
|
testStep: testStep?.trim() || "",
|
|
75
75
|
filePath: filePath?.trim() || "",
|
|
@@ -3,7 +3,7 @@ import { Page } from "playwright";
|
|
|
3
3
|
import { PlaywrightActions } from "../../actions";
|
|
4
4
|
import { ScopeVars, TestCase } from "../../types";
|
|
5
5
|
import { BrowsingAgentOptions } from "../browsing";
|
|
6
|
-
export declare function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, annotatedPageScreenshot, actions, disableSkills, useHints, }: {
|
|
6
|
+
export declare function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, annotatedPageScreenshot, actions, disableSkills, useHints, annotations, }: {
|
|
7
7
|
task: string;
|
|
8
8
|
executedActions: string[];
|
|
9
9
|
failedActions: any[];
|
|
@@ -16,6 +16,7 @@ export declare function getNextAction({ task, executedActions, failedActions, pa
|
|
|
16
16
|
actions: PlaywrightActions;
|
|
17
17
|
disableSkills: boolean;
|
|
18
18
|
useHints: boolean;
|
|
19
|
+
annotations?: string[];
|
|
19
20
|
}): Promise<import("openai/resources/index.mjs").ChatCompletionMessageToolCall | undefined>;
|
|
20
21
|
export declare function createTestUsingMasterAgent({ task, page, testCase, options, scopeVars, }: {
|
|
21
22
|
task: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EACH,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CA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AAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,2FA2FA;AAGD,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAuTA"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -16,7 +16,7 @@ const skills_retriever_1 = require("../codegen/skills-retriever");
|
|
|
16
16
|
const verification_1 = require("../verification");
|
|
17
17
|
const with_hints_1 = require("./with-hints");
|
|
18
18
|
const MAX_ERROR_COUNT = 2;
|
|
19
|
-
async function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, annotatedPageScreenshot, actions, disableSkills, useHints = false, }) {
|
|
19
|
+
async function getNextAction({ task, executedActions, failedActions, pageUrl, trace, llm, options, pageScreenshot, annotatedPageScreenshot, actions, disableSkills, useHints = false, annotations, }) {
|
|
20
20
|
const nextActionSpan = trace?.span({
|
|
21
21
|
name: "master-agent-next-action",
|
|
22
22
|
input: {
|
|
@@ -30,6 +30,7 @@ async function getNextAction({ task, executedActions, failedActions, pageUrl, tr
|
|
|
30
30
|
disableSkills,
|
|
31
31
|
useHints,
|
|
32
32
|
skills: skill_1.testCaseSkills.getAvailableSkills(),
|
|
33
|
+
annotations,
|
|
33
34
|
},
|
|
34
35
|
});
|
|
35
36
|
const promptSpan = nextActionSpan?.span({
|
|
@@ -40,7 +41,8 @@ async function getNextAction({ task, executedActions, failedActions, pageUrl, tr
|
|
|
40
41
|
failedActions: failedActions.map((a) => a).join("\n"),
|
|
41
42
|
executedActions: executedActions.map((a) => a).join("\n"),
|
|
42
43
|
pageUrl,
|
|
43
|
-
|
|
44
|
+
annotations,
|
|
45
|
+
}, 24);
|
|
44
46
|
// assuming there is only one user message in the prompt. if there is a change in langfuse prompt format, this will need to be updated
|
|
45
47
|
const userMessage = promptMessages.filter((m) => m.role === "user")[0];
|
|
46
48
|
const systemMessage = promptMessages.filter((m) => m.role === "system")[0];
|
|
@@ -171,16 +173,16 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
const buffer = await page.screenshot({
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
//This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
|
|
177
|
+
// fullPage: true,
|
|
178
|
+
// path: `screenshots/screenshot-${screenshotIndex++}.png`, // enable this and screenshotIndex var for local debugging
|
|
176
179
|
});
|
|
177
180
|
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
178
|
-
|
|
181
|
+
await testGenReporter.sendCurrentView(buffer);
|
|
179
182
|
const pageScreenshot = buffer.toString("base64");
|
|
180
183
|
let output;
|
|
181
184
|
let generatedCodeSteps = [];
|
|
182
185
|
let annotations;
|
|
183
|
-
let testGenAnnotatedSnapshotUpdatePromise;
|
|
184
186
|
let annotatedPageScreenshot;
|
|
185
187
|
if (useHints) {
|
|
186
188
|
await page.waitForTimeout(2000);
|
|
@@ -193,8 +195,9 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
193
195
|
annotations = annotationResult?.annotations || {};
|
|
194
196
|
await page.waitForTimeout(2000);
|
|
195
197
|
const annonationBuffer = await page.screenshot({
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
//This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
|
|
199
|
+
// fullPage: true,
|
|
200
|
+
// path: `screenshots/screenshot-${screenshotIndex++}.png`,
|
|
198
201
|
});
|
|
199
202
|
await page.evaluate(() => {
|
|
200
203
|
console.log({
|
|
@@ -207,13 +210,13 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
207
210
|
window?.annotationInstance?.destroy();
|
|
208
211
|
}
|
|
209
212
|
});
|
|
210
|
-
|
|
211
|
-
testGenReporter.sendCurrentView(annonationBuffer);
|
|
213
|
+
await testGenReporter.sendCurrentView(annonationBuffer);
|
|
212
214
|
annotatedPageScreenshot = annonationBuffer.toString("base64");
|
|
213
215
|
}
|
|
214
216
|
if (await (0, session_1.shouldStopSession)()) {
|
|
215
217
|
break;
|
|
216
218
|
}
|
|
219
|
+
const annotationKeys = annotations ? Object.keys(annotations) : [];
|
|
217
220
|
const toolCall = await getNextAction({
|
|
218
221
|
task,
|
|
219
222
|
executedActions: masterAgentActions,
|
|
@@ -227,6 +230,7 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
227
230
|
actions,
|
|
228
231
|
disableSkills,
|
|
229
232
|
useHints,
|
|
233
|
+
annotations: annotationKeys,
|
|
230
234
|
});
|
|
231
235
|
if (await (0, session_1.shouldStopSession)()) {
|
|
232
236
|
break;
|
|
@@ -345,10 +349,6 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
345
349
|
}
|
|
346
350
|
}
|
|
347
351
|
trace?.update({ input: { task }, output: { output } });
|
|
348
|
-
await testGenSnapshotUpdatePromise;
|
|
349
|
-
if (testGenAnnotatedSnapshotUpdatePromise) {
|
|
350
|
-
await testGenAnnotatedSnapshotUpdatePromise;
|
|
351
|
-
}
|
|
352
352
|
masterAgentSpan?.end({
|
|
353
353
|
output: {
|
|
354
354
|
action: output.action,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
+
import { TestCase } from "../../types";
|
|
3
|
+
export declare function planTask({ testCase, specPath, trace, }: {
|
|
4
|
+
testCase: TestCase;
|
|
5
|
+
specPath: string;
|
|
6
|
+
trace?: TraceClient;
|
|
7
|
+
}): Promise<string>;
|
|
8
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/planner/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsBvC,wBAAsB,QAAQ,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,mBA0DA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.planTask = void 0;
|
|
4
|
+
const llm_1 = require("@empiricalrun/llm");
|
|
5
|
+
const context_1 = require("../../bin/utils/context");
|
|
6
|
+
function extractTestPlan(input) {
|
|
7
|
+
const result = {
|
|
8
|
+
createSubTasks: "",
|
|
9
|
+
verfiedSubTasks: "",
|
|
10
|
+
enrichedSubTasks: "",
|
|
11
|
+
finalPlan: "",
|
|
12
|
+
};
|
|
13
|
+
const regex = /<create_sub_tasks>([\s\S]*?)<\/create_sub_tasks>[\s\S]*?<enriched_sub_tasks>([\s\S]*?)<\/enriched_sub_tasks>[\s\S]*?<final_plan>([\s\S]*?)<\/final_plan>/g;
|
|
14
|
+
let match;
|
|
15
|
+
while ((match = regex.exec(input)) !== null) {
|
|
16
|
+
const [, createSubTasks, enrichedSubTasks, finalPlan] = match;
|
|
17
|
+
result.createSubTasks = createSubTasks?.trim() || "";
|
|
18
|
+
result.enrichedSubTasks = enrichedSubTasks?.trim() || "";
|
|
19
|
+
result.finalPlan = finalPlan?.trim() || "";
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
async function planTask({ testCase, specPath, trace, }) {
|
|
24
|
+
const task = testCase.steps.join("\n");
|
|
25
|
+
// TODO: fix this
|
|
26
|
+
let fileContext = "";
|
|
27
|
+
try {
|
|
28
|
+
const { pomPrompt, testFileContent } = await (0, context_1.contextForGeneration)(specPath);
|
|
29
|
+
fileContext = `
|
|
30
|
+
${testFileContent}
|
|
31
|
+
${pomPrompt}
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.warn("Failed to generate file context for planner", e);
|
|
36
|
+
}
|
|
37
|
+
const plannerSpan = trace?.span({
|
|
38
|
+
name: "planner",
|
|
39
|
+
input: {
|
|
40
|
+
testCase,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const appKnowledge = await (0, context_1.fetchAppKnowledge)();
|
|
44
|
+
const promptSpan = plannerSpan?.span({
|
|
45
|
+
name: "planner-prompt",
|
|
46
|
+
input: {
|
|
47
|
+
appKnowledge,
|
|
48
|
+
fileContext,
|
|
49
|
+
testCase,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
const messages = await (0, llm_1.getPrompt)("planner", {
|
|
53
|
+
appKnowledge,
|
|
54
|
+
fileContext,
|
|
55
|
+
task,
|
|
56
|
+
}, 2);
|
|
57
|
+
promptSpan?.end({ output: { messages } });
|
|
58
|
+
const llm = new llm_1.LLM({
|
|
59
|
+
provider: "openai",
|
|
60
|
+
//TODO: change to o1
|
|
61
|
+
defaultModel: "gpt-4o",
|
|
62
|
+
});
|
|
63
|
+
const response = await llm.createChatCompletion({
|
|
64
|
+
trace: plannerSpan,
|
|
65
|
+
traceName: "planner-llm",
|
|
66
|
+
messages,
|
|
67
|
+
modelParameters: {
|
|
68
|
+
temperature: 0.5,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const plan = extractTestPlan(response?.content || "");
|
|
72
|
+
plannerSpan?.end({ output: plan?.finalPlan });
|
|
73
|
+
return plan?.finalPlan;
|
|
74
|
+
}
|
|
75
|
+
exports.planTask = planTask;
|
package/dist/bin/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const run_1 = require("../agent/browsing/run");
|
|
|
10
10
|
const utils_1 = require("../agent/browsing/utils");
|
|
11
11
|
const run_2 = require("../agent/codegen/run");
|
|
12
12
|
const infer_agent_1 = require("../agent/infer-agent");
|
|
13
|
+
const run_3 = require("../agent/planner/run");
|
|
13
14
|
const reporter_1 = require("../reporter");
|
|
14
15
|
const ci_1 = require("../reporter/ci");
|
|
15
16
|
const session_1 = require("../session");
|
|
@@ -77,9 +78,19 @@ async function runAgent(testGenConfig) {
|
|
|
77
78
|
});
|
|
78
79
|
testGenConfig.options.agent = agent;
|
|
79
80
|
}
|
|
81
|
+
logger.success(`Generating test using ${testGenConfig.options?.agent} agent. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`);
|
|
82
|
+
if (agent === "plan") {
|
|
83
|
+
const plan = await (0, run_3.planTask)({
|
|
84
|
+
testCase,
|
|
85
|
+
specPath,
|
|
86
|
+
trace,
|
|
87
|
+
});
|
|
88
|
+
new logger_1.CustomLogger({ useReporter: false }).log("Generated Plan:", plan);
|
|
89
|
+
await new reporter_1.TestGenUpdatesReporter().sendMessage(plan);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
80
92
|
if (agent !== "code") {
|
|
81
93
|
// this assumes we have only one scenario in test config
|
|
82
|
-
logger.success(`Generating test using ${testGenConfig.options?.agent} agent. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`);
|
|
83
94
|
const filePathToUpdate = await (0, utils_1.prepareFileForMasterAgent)(testGenConfig, trace);
|
|
84
95
|
await (0, run_1.generateTestsUsingMasterAgent)({
|
|
85
96
|
testFilePath: specPath,
|
|
@@ -88,7 +99,6 @@ async function runAgent(testGenConfig) {
|
|
|
88
99
|
});
|
|
89
100
|
}
|
|
90
101
|
else {
|
|
91
|
-
logger.success(`Generating test using coding agent. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`);
|
|
92
102
|
await (0, run_2.generateTest)(testCase, specPath, testGenConfig.options, trace);
|
|
93
103
|
}
|
|
94
104
|
}
|
|
@@ -123,7 +133,8 @@ async function runAgent(testGenConfig) {
|
|
|
123
133
|
testGenFailed = true;
|
|
124
134
|
new logger_1.CustomLogger().error(`Failed to generate test for the scenario. ${process.env.LOG_URL ? `[view log](${process.env.LOG_URL})` : ""}`, e?.message, e?.stack);
|
|
125
135
|
}
|
|
126
|
-
if (testGenConfig.options?.agent !== "code"
|
|
136
|
+
if (testGenConfig.options?.agent !== "code" &&
|
|
137
|
+
testGenConfig.options?.agent !== "plan") {
|
|
127
138
|
await new reporter_1.TestGenUpdatesReporter().reportGenAssets({
|
|
128
139
|
projectRepoName: testGenConfig.options.metadata.projectRepoName,
|
|
129
140
|
testName: testGenConfig.testCase.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/context.ts"],"names":[],"mappings":"AAKA,wBAAsB,yBAAyB,2CAS9C;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM;;;;GAOtD"}
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/context.ts"],"names":[],"mappings":"AAKA,wBAAsB,yBAAyB,2CAS9C;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,MAAM;;;;GAOtD;AAED,wBAAsB,iBAAiB,oBAYtC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.contextForGeneration = exports.createGitIgnoreFileFilter = void 0;
|
|
6
|
+
exports.fetchAppKnowledge = exports.contextForGeneration = exports.createGitIgnoreFileFilter = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const ignore_1 = __importDefault(require("ignore"));
|
|
9
9
|
const fs_1 = require("./fs");
|
|
@@ -27,3 +27,18 @@ async function contextForGeneration(file) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
exports.contextForGeneration = contextForGeneration;
|
|
30
|
+
async function fetchAppKnowledge() {
|
|
31
|
+
let fileExists = true;
|
|
32
|
+
const appKnowledgePath = "./app_knowledge.md";
|
|
33
|
+
try {
|
|
34
|
+
await fs_extra_1.default.access(appKnowledgePath);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
fileExists = false;
|
|
38
|
+
}
|
|
39
|
+
if (!fileExists) {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
return await fs_extra_1.default.readFile(appKnowledgePath, "utf-8");
|
|
43
|
+
}
|
|
44
|
+
exports.fetchAppKnowledge = fetchAppKnowledge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bin/utils/platform/web/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,IAAI,EAEJ,UAAU,EAEX,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,eAAO,MAAM,gCAAgC,eAC/B,UAAU,KACrB,MAgBF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,YAAY,EACZ,MAAM,EACN,OAAO,GACR,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG;IACF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB,CA2CA;AAwBD,wBAAsB,0CAA0C,CAC9D,QAAQ,EAAE,MAAM,oBA+BjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAs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BrB,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,EAC1C,YAAY,EACZ,QAAQ,EACR,MAAM,GACP,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,iBAsDA;AAED,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EAAE,iBA2BzB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB,WAYA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,UAOA"}
|
|
@@ -307,17 +307,16 @@ function replaceCreateTestWithNewCode(filePath, contents, generatedCode) {
|
|
|
307
307
|
});
|
|
308
308
|
const fixtureImportNode = sourceFile.getFirstDescendant((node) => !!(node.isKind(ts_morph_1.SyntaxKind.ImportDeclaration) &&
|
|
309
309
|
node.getText().includes("fixtures")));
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
updatedTestFile = updatedTestFile.replace(fixtureImportNode.getText(), expectedImports);
|
|
310
|
+
if (fixtureImportNode) {
|
|
311
|
+
const importClause = fixtureImportNode.getImportClause();
|
|
312
|
+
const namedImports = importClause
|
|
313
|
+
.getNamedImports()
|
|
314
|
+
.map((imp) => imp.getName());
|
|
315
|
+
const isComplete = namedImports.includes(testAlias) && namedImports.includes("expect");
|
|
316
|
+
if (!isComplete) {
|
|
317
|
+
const expectedImports = `import { test, expect } from "${getFixtureImportPath(filePath)}";`;
|
|
318
|
+
updatedTestFile = updatedTestFile.replace(fixtureImportNode.getText(), expectedImports);
|
|
319
|
+
}
|
|
321
320
|
}
|
|
322
321
|
return updatedTestFile;
|
|
323
322
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAEd,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bin/utils/scenarios/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAcxB,iBAAe,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAkB3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -135,7 +135,8 @@ window.annotateClickableElements = function annotateClickableElements(
|
|
|
135
135
|
if (
|
|
136
136
|
style.display === "none" ||
|
|
137
137
|
style.visibility === "hidden" ||
|
|
138
|
-
|
|
138
|
+
// This is done for cases where opacity is undefined
|
|
139
|
+
// parseFloat(style.opacity) === 0
|
|
139
140
|
style.pointerEvents === "none"
|
|
140
141
|
) {
|
|
141
142
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"master-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/master-agent.evals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,eAAO,MAAM,4BAA4B,EAAE,
|
|
1
|
+
{"version":3,"file":"master-agent.evals.d.ts","sourceRoot":"","sources":["../../src/evals/master-agent.evals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,eAAO,MAAM,4BAA4B,EAAE,UA4C1C,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
|
|
@@ -5,7 +5,7 @@ const actions_1 = require("../actions");
|
|
|
5
5
|
const skill_1 = require("../actions/skill");
|
|
6
6
|
const run_1 = require("../agent/master/run");
|
|
7
7
|
const masterGetNextActionEvaluator = async ({ item, trace, }) => {
|
|
8
|
-
const { task, executedActions, failedActions, pageUrl, options, pageScreenshot, annotatedPageScreenshot, disableSkills, useHints, skills = [], } = item.input;
|
|
8
|
+
const { task, executedActions, failedActions, pageUrl, options, pageScreenshot, annotatedPageScreenshot, disableSkills, useHints, skills = [], annotations, } = item.input;
|
|
9
9
|
const page = {};
|
|
10
10
|
skill_1.testCaseSkills.updateSkills(skills);
|
|
11
11
|
const actions = new actions_1.PlaywrightActions(page);
|
|
@@ -21,6 +21,7 @@ const masterGetNextActionEvaluator = async ({ item, trace, }) => {
|
|
|
21
21
|
actions,
|
|
22
22
|
disableSkills,
|
|
23
23
|
useHints,
|
|
24
|
+
annotations,
|
|
24
25
|
});
|
|
25
26
|
return {
|
|
26
27
|
scores: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAgDK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAa5E,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAUlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAGlE;AAED,qBAAa,sBAAsB;;IAE3B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,eAAe,CAAC,EACpB,eAAe,EACf,QAAQ,GACT,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAgDK,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2C9C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1C,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWxD"}
|
package/dist/reporter/index.js
CHANGED
|
@@ -95,25 +95,30 @@ class TestGenUpdatesReporter {
|
|
|
95
95
|
logger.log("Skipped uploading current view screenshot");
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
try {
|
|
99
|
+
// upload current screenshot to r2 and report it to reporter
|
|
100
|
+
if (!fs_extra_1.default.existsSync(path_1.default.join(process.cwd(), "gen-assets"))) {
|
|
101
|
+
await fs_extra_1.default.mkdir((process.cwd(), "gen-assets"));
|
|
102
|
+
}
|
|
103
|
+
await fs_extra_1.default.writeFile(path_1.default.join(process.cwd(), "gen-assets", `current-view-${Date.now()}.png`), buffer);
|
|
104
|
+
const uploadDir = (0, uploader_1.getUploadPathForRun)(reporterConfig?.projectRepoName);
|
|
105
|
+
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
106
|
+
sourceDir: path_1.default.join(process.cwd(), "gen-assets"),
|
|
107
|
+
destinationDir: uploadDir,
|
|
108
|
+
uploadBucket: uploader_1.UPLOAD_BUCKET,
|
|
109
|
+
});
|
|
110
|
+
const filePath = Object.keys(files)[0];
|
|
111
|
+
const relativeFilePath = filePath.replace(path_1.default.join(process.cwd(), "gen-assets"), "");
|
|
112
|
+
const url = `${uploader_1.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
113
|
+
await getReporter()?.report(new reporter_1.ProcessLogMessageBuilder({
|
|
114
|
+
type: "current-snapshot",
|
|
115
|
+
message: JSON.stringify({ type: "current-view", url }),
|
|
116
|
+
}));
|
|
117
|
+
await fs_extra_1.default.rmdir((process.cwd(), "gen-assets"), { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
console.warn("Failed to upload current view screenshot", e);
|
|
101
121
|
}
|
|
102
|
-
await fs_extra_1.default.writeFile(path_1.default.join(process.cwd(), "gen-assets", `current-view-${Date.now()}.png`), buffer);
|
|
103
|
-
const uploadDir = (0, uploader_1.getUploadPathForRun)(reporterConfig?.projectRepoName);
|
|
104
|
-
const files = await (0, r2_uploader_1.uploadDirectory)({
|
|
105
|
-
sourceDir: path_1.default.join(process.cwd(), "gen-assets"),
|
|
106
|
-
destinationDir: uploadDir,
|
|
107
|
-
uploadBucket: uploader_1.UPLOAD_BUCKET,
|
|
108
|
-
});
|
|
109
|
-
const filePath = Object.keys(files)[0];
|
|
110
|
-
const relativeFilePath = filePath.replace(path_1.default.join(process.cwd(), "gen-assets"), "");
|
|
111
|
-
const url = `${uploader_1.UPLOAD_DOMAIN}/${uploadDir}${relativeFilePath}`;
|
|
112
|
-
await getReporter()?.report(new reporter_1.ProcessLogMessageBuilder({
|
|
113
|
-
type: "current-snapshot",
|
|
114
|
-
message: JSON.stringify({ type: "current-view", url }),
|
|
115
|
-
}));
|
|
116
|
-
await fs_extra_1.default.rmdir((process.cwd(), "gen-assets"), { recursive: true });
|
|
117
122
|
}
|
|
118
123
|
async sendMessage(message) {
|
|
119
124
|
const reporter = getReporter();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type Environment = {
|
|
|
10
10
|
slug: string;
|
|
11
11
|
playwrightProjects: string[];
|
|
12
12
|
};
|
|
13
|
-
export type Agent = "code" | "master" | "auto";
|
|
13
|
+
export type Agent = "code" | "master" | "auto" | "plan";
|
|
14
14
|
export type TestGenConfigOptions = {
|
|
15
15
|
agent: Agent;
|
|
16
16
|
model: LLMModel;
|
|
@@ -42,6 +42,7 @@ export type TestCase = {
|
|
|
42
42
|
steps: string[];
|
|
43
43
|
filePath: string;
|
|
44
44
|
suites: string[];
|
|
45
|
+
ai_gist?: string;
|
|
45
46
|
};
|
|
46
47
|
export type PlaywrightActionGenerator = (page: Page, options: {
|
|
47
48
|
stateVariables: Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,eAAe,EACf,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,MAAM,MAAM,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