@empiricalrun/test-gen 0.37.4 → 0.38.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 +17 -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.map +1 -1
- package/dist/agent/master/run.js +6 -4
- 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/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,22 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.38.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c2cf877: fix: get appropriate skill should return correct file path
|
|
8
|
+
|
|
9
|
+
## 0.38.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 2444057: feat: add support for planner agent
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 96bc299: fix: extract page vars is failing
|
|
18
|
+
- edce85d: fix: annotate elements where opacity is not set
|
|
19
|
+
|
|
3
20
|
## 0.37.4
|
|
4
21
|
|
|
5
22
|
### 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,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,OAAO,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAMzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../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,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() || "",
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"}
|
package/dist/agent/master/run.js
CHANGED
|
@@ -171,8 +171,9 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
const buffer = await page.screenshot({
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
//This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
|
|
175
|
+
// fullPage: true,
|
|
176
|
+
// path: `screenshots/screenshot-${screenshotIndex++}.png`, // enable this and screenshotIndex var for local debugging
|
|
176
177
|
});
|
|
177
178
|
const testGenReporter = new reporter_1.TestGenUpdatesReporter();
|
|
178
179
|
const testGenSnapshotUpdatePromise = testGenReporter.sendCurrentView(buffer);
|
|
@@ -193,8 +194,9 @@ async function createTestUsingMasterAgent({ task, page, testCase, options, scope
|
|
|
193
194
|
annotations = annotationResult?.annotations || {};
|
|
194
195
|
await page.waitForTimeout(2000);
|
|
195
196
|
const annonationBuffer = await page.screenshot({
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
//This is done to improve element annotation accuracy, anyways it doesn't annotate elements which are out of viewport
|
|
198
|
+
// fullPage: true,
|
|
199
|
+
// path: `screenshots/screenshot-${screenshotIndex++}.png`,
|
|
198
200
|
});
|
|
199
201
|
await page.evaluate(() => {
|
|
200
202
|
console.log({
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GAAG,SAAS,GACrB,IAAI,GAAG,SAAS,CA4BlB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,M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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;
|
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,Q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