@empiricalrun/test-gen 0.27.1 → 0.27.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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAyFD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAwCD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAiBxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QA6BjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAyFD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAwCD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAiBxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QA6BjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,CAAC,CA8CjB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,YAAiB,EACjB,IAAS,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"}
|
|
@@ -187,6 +187,15 @@ async function readPlaywrightConfig() {
|
|
|
187
187
|
return playwrightConfig;
|
|
188
188
|
}
|
|
189
189
|
exports.readPlaywrightConfig = readPlaywrightConfig;
|
|
190
|
+
function matchAgainstPattern(pattern, filePathToTest) {
|
|
191
|
+
if (isRegExp(pattern)) {
|
|
192
|
+
const regExp = pattern;
|
|
193
|
+
return regExp.test(filePathToTest);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return (0, minimatch_1.minimatch)(filePathToTest, pattern);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
190
199
|
/**
|
|
191
200
|
* detect the project name for the given file in playwright test repo
|
|
192
201
|
* if project and test file path for running test don't match, then playwright throws error
|
|
@@ -195,51 +204,45 @@ exports.readPlaywrightConfig = readPlaywrightConfig;
|
|
|
195
204
|
*/
|
|
196
205
|
async function detectProjectName(testFilePath, playwrightConfig) {
|
|
197
206
|
const filePath = testFilePath.replace("./tests/", "");
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
ignoreFile = regExp.test(filePath);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
ignoreFile = (0, minimatch_1.minimatch)(filePath, testIgnore);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// if test file path is in ignore list then skip it
|
|
216
|
-
// TODO: support for array based glob match
|
|
217
|
-
if (ignoreFile) {
|
|
218
|
-
return "";
|
|
219
|
-
}
|
|
220
|
-
if (typeof testMatch === "string" || isRegExp(testMatch)) {
|
|
221
|
-
let isMatch = false;
|
|
222
|
-
if (isRegExp(testMatch)) {
|
|
223
|
-
isMatch = testMatch.test(filePath);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
isMatch = (0, minimatch_1.minimatch)(filePath, testMatch);
|
|
227
|
-
}
|
|
228
|
-
if (isMatch && p.use?.defaultBrowserType === "chromium") {
|
|
229
|
-
return p.name;
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
return "";
|
|
233
|
-
}
|
|
207
|
+
if (!playwrightConfig.projects || playwrightConfig.projects.length === 0) {
|
|
208
|
+
throw new Error(`No projects found in playwright config.`);
|
|
209
|
+
}
|
|
210
|
+
const filteredProjectNames = playwrightConfig.projects
|
|
211
|
+
.map((p) => {
|
|
212
|
+
const testIgnore = p.testIgnore;
|
|
213
|
+
const testMatch = p.testMatch || "**";
|
|
214
|
+
let ignoreFile = false;
|
|
215
|
+
if (testIgnore) {
|
|
216
|
+
if (typeof testIgnore === "string" || isRegExp(testIgnore)) {
|
|
217
|
+
ignoreFile = matchAgainstPattern(testIgnore, filePath);
|
|
234
218
|
}
|
|
235
|
-
else {
|
|
236
|
-
|
|
219
|
+
else if (typeof testIgnore === "object") {
|
|
220
|
+
ignoreFile = testIgnore.some((ignore) => matchAgainstPattern(ignore, filePath));
|
|
237
221
|
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
222
|
+
}
|
|
223
|
+
// if test file path is in ignore list then skip it
|
|
224
|
+
if (ignoreFile) {
|
|
225
|
+
return "";
|
|
226
|
+
}
|
|
227
|
+
let isMatch = false;
|
|
228
|
+
if (typeof testMatch === "string" || isRegExp(testMatch)) {
|
|
229
|
+
isMatch = matchAgainstPattern(testMatch, filePath);
|
|
230
|
+
}
|
|
231
|
+
else if (typeof testMatch === "object") {
|
|
232
|
+
isMatch = testMatch.some((match) => matchAgainstPattern(match, filePath));
|
|
233
|
+
}
|
|
234
|
+
if (isMatch && p.use?.defaultBrowserType === "chromium") {
|
|
235
|
+
return p.name || "";
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
.filter((p) => !!p);
|
|
242
|
+
if (filteredProjectNames.length === 0) {
|
|
243
|
+
throw new Error(`No project found for the test file: ${testFilePath} in playwright config.`);
|
|
241
244
|
}
|
|
242
|
-
return
|
|
245
|
+
return filteredProjectNames[0];
|
|
243
246
|
}
|
|
244
247
|
exports.detectProjectName = detectProjectName;
|
|
245
248
|
async function getPromptForNextAction({ pageSnapshot = "", task = "", previousActions = [], lastActionErrors = [], promptType = "browsing-agent-next-action", }) {
|