@empiricalrun/test-gen 0.42.24 → 0.42.26

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,5 +1,18 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.42.26
4
+
5
+ ### Patch Changes
6
+
7
+ - 070c16a: feat: config for master agent sanity test suite
8
+
9
+ ## 0.42.25
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [2babfe0]
14
+ - @empiricalrun/llm@0.9.34
15
+
3
16
  ## 0.42.24
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AA8FD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,EACxB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CA0DjB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAuHxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QAIjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAA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BAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAuBb,SAAS;CAKjB"}
@@ -164,7 +164,11 @@ function newContentsWithTestOnly(existingContents, originalTestBlock, updatedTes
164
164
  }
165
165
  }
166
166
  async function injectPwLocatorGenerator(page) {
167
- const pathToInstalledTestGen = require.resolve(".").split("dist")[0];
167
+ let pathToInstalledTestGen = require.resolve(".").split("dist")[0];
168
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
169
+ if (process.env.RUNNING_BROWSER_TESTS_FOR_TEST_GEN) {
170
+ pathToInstalledTestGen = process.cwd();
171
+ }
168
172
  const annotateElementPath = path_1.default.join(pathToInstalledTestGen, "dist", "browser-injected-scripts", "annotate-elements.js");
169
173
  if (!fs_extra_1.default.existsSync(annotateElementPath)) {
170
174
  throw new Error(`annotate-elements.js not found at path: ${annotateElementPath}`);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/browser-tests/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const test_1 = require("@playwright/test");
7
+ const http_server_1 = __importDefault(require("http-server"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const run_1 = require("../run");
10
+ let server;
11
+ let PORT = 2345;
12
+ test_1.test.beforeAll(async () => {
13
+ server = http_server_1.default.createServer({
14
+ root: path_1.default.join(process.cwd(), "test-data"),
15
+ });
16
+ // Start the server
17
+ await new Promise((resolve) => {
18
+ server.listen(PORT, () => {
19
+ console.log(`Server running at http://localhost:${PORT}`);
20
+ resolve(true);
21
+ });
22
+ });
23
+ });
24
+ test_1.test.afterAll(() => {
25
+ if (server) {
26
+ server.close();
27
+ }
28
+ });
29
+ (0, test_1.test)("able to scroll and interact with elements", async ({ page }) => {
30
+ await page.goto(`http://localhost:${PORT}/blog-page.html`);
31
+ const response = await (0, run_1.createTestUsingMasterAgent)({
32
+ task: `fill test@test.com into the email field and click the submit`,
33
+ page,
34
+ options: {},
35
+ });
36
+ console.log(response);
37
+ (0, test_1.expect)(response.importPaths.length).toBe(0);
38
+ (0, test_1.expect)(response.code).toContain("await page.getByPlaceholder('Enter your email').fill(\"test@test.com\")");
39
+ (0, test_1.expect)(response.code).toContain("await page.getByRole('button', { name: 'Subscribe' }).click()");
40
+ });
41
+ test_1.test.skip("scroll when element does not exist", async ({ page }) => {
42
+ await page.goto(`http://localhost:${PORT}/blog-page.html`);
43
+ const response = await (0, run_1.createTestUsingMasterAgent)({
44
+ task: `click search button`,
45
+ page,
46
+ options: {},
47
+ });
48
+ console.log(response);
49
+ (0, test_1.expect)(response.importPaths.length).toBe(0);
50
+ (0, test_1.expect)(response.code.length).toBe(0);
51
+ });
52
+ (0, test_1.test)("agent can click icons accurately", async ({ page }) => {
53
+ await page.goto(`http://localhost:${PORT}/icons-navbar.html`);
54
+ await (0, test_1.expect)(page.getByText("select an icon")).toBeVisible();
55
+ const response = await (0, run_1.createTestUsingMasterAgent)({
56
+ task: `click on the gear icon`,
57
+ page,
58
+ options: {},
59
+ });
60
+ await (0, test_1.expect)(page.getByText("you clicked Gear")).toBeVisible();
61
+ console.log(response);
62
+ (0, test_1.expect)(response.importPaths.length).toBe(0);
63
+ (0, test_1.expect)(response.code).toContain("page.getByRole");
64
+ (0, test_1.expect)(response.code).toContain("click()");
65
+ });
@@ -180,7 +180,6 @@ const action_tool_calls_1 = require("../agent/master/action-tool-calls");
180
180
  href: config.node.href,
181
181
  }));
182
182
  }, preference);
183
- console.log("Annotations:", annotations);
184
183
  test_1.test.expect(annotations.length).toBe(1);
185
184
  test_1.test.expect(annotations[0]?.tagName).toBe("DIV");
186
185
  });
@@ -296,8 +296,6 @@ test("should only annotate given text on quizziz page", async ({ page }) => {
296
296
  href: config.node.href,
297
297
  }));
298
298
  }, preference);
299
-
300
- console.log("Annotations:", annotations);
301
299
  test.expect(annotations.length).toBe(1);
302
300
  test.expect(annotations[0]?.tagName).toBe("DIV");
303
301
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.42.24",
3
+ "version": "0.42.26",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -71,7 +71,7 @@
71
71
  "ts-morph": "^23.0.0",
72
72
  "tsx": "^4.16.2",
73
73
  "typescript": "^5.3.3",
74
- "@empiricalrun/llm": "^0.9.33",
74
+ "@empiricalrun/llm": "^0.9.34",
75
75
  "@empiricalrun/r2-uploader": "^0.3.8",
76
76
  "@empiricalrun/reporter": "^0.23.1"
77
77
  },
@@ -80,9 +80,11 @@
80
80
  "@types/detect-port": "^1.3.5",
81
81
  "@types/express": "^4.17.21",
82
82
  "@types/fs-extra": "^11.0.4",
83
+ "@types/http-server": "^0.12.4",
83
84
  "@types/js-levenshtein": "^1.1.3",
84
85
  "@types/lodash.isequal": "^4.5.8",
85
86
  "@types/md5": "^2.3.5",
87
+ "http-server": "^14.1.1",
86
88
  "js-levenshtein": "^1.1.6",
87
89
  "playwright": "1.47.1",
88
90
  "ts-patch": "^3.3.0",
@@ -94,7 +96,7 @@
94
96
  "clean": "tspc --build --clean",
95
97
  "lint": "eslint .",
96
98
  "test": "vitest run",
97
- "test-browser": "npx playwright test",
99
+ "test-browser": "pnpm build && RUNNING_BROWSER_TESTS_FOR_TEST_GEN=1 npx playwright test",
98
100
  "test:watch": "vitest",
99
101
  "test:watch-files": "vitest $0 --watch"
100
102
  }
@@ -1,5 +1,12 @@
1
1
  import { defineConfig } from "@playwright/test";
2
2
 
3
+ // To run master agent sanity tests, we want our typescript
4
+ // transformer to be used while compiling the tests.
5
+ // Hence, we bypass Playwright's default TS compiler, and have
6
+ // it run compiled test files from /dist/
3
7
  export default defineConfig({
4
- testDir: "./src/browser-injected-scripts",
8
+ testDir: "./dist/.",
9
+ testMatch: "**/*.spec.js",
10
+ // Setting large timeout as master agent takes time to run.
11
+ timeout: 120_000,
5
12
  });