@empiricalrun/test-gen 0.35.6 → 0.35.9

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,23 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.35.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 04ca7f3: feat: add locator.press action
8
+
9
+ ## 0.35.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 461f3dd: fix: add logs for generation stopped due to stop session requested
14
+
15
+ ## 0.35.7
16
+
17
+ ### Patch Changes
18
+
19
+ - 2145207: fix: vitest config to exclude browser tests
20
+
3
21
  ## 0.35.6
4
22
 
5
23
  ### Patch Changes
@@ -157,7 +157,7 @@ test("should annotate all important items on quizizz page", async ({
157
157
  (item) =>
158
158
  item.innerText.includes("accommodations") &&
159
159
  item.href ===
160
- "https://quizizz.com/admin/differentiation/accommodations",
160
+ "https://quizizz.com/admin/differentiation/accommodations",
161
161
  ),
162
162
  )
163
163
  .toBeTruthy();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,OAAO,EAAE,YAAY,EAA6B,MAAM,UAAU,CAAC;AAWnE,qBAAa,iBAAiB;IAShB,OAAO,CAAC,IAAI;IARxB,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,eAAe,CAInB;IACJ,OAAO,CAAC,cAAc,CAA2B;gBAE7B,IAAI,EAAE,IAAI;IAexB,aAAa,CACjB,IAAI,oBAAa,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,CAAC,EAAE,WAAW;IAgDrB,wBAAwB,IAAI,YAAY,EAAE;IAkB1C,sBAAsB,IAAI,YAAY,EAAE;IAUxC,YAAY,IAAI;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAO9B;;;;;;OAMG;IACH,aAAa,IAAI,OAAO;IAQxB,UAAU;CAUX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,OAAO,EAAE,YAAY,EAA6B,MAAM,UAAU,CAAC;AAYnE,qBAAa,iBAAiB;IAShB,OAAO,CAAC,IAAI;IARxB,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,eAAe,CAInB;IACJ,OAAO,CAAC,cAAc,CAA2B;gBAE7B,IAAI,EAAE,IAAI;IAgBxB,aAAa,CACjB,IAAI,oBAAa,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,KAAK,CAAC,EAAE,WAAW;IAgDrB,wBAAwB,IAAI,YAAY,EAAE;IAmB1C,sBAAsB,IAAI,YAAY,EAAE;IAUxC,YAAY,IAAI;QACd,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;KACvB;IAUD,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAO9B;;;;;;OAMG;IACH,aAAa,IAAI,OAAO;IAQxB,UAAU;CAUX"}
@@ -9,6 +9,7 @@ const done_1 = require("./done");
9
9
  const fill_1 = require("./fill");
10
10
  const goto_1 = require("./goto");
11
11
  const hover_1 = require("./hover");
12
+ const press_1 = require("./press");
12
13
  const reload_page_1 = require("./reload-page");
13
14
  const skill_1 = require("./skill");
14
15
  const text_content_1 = require("./text-content");
@@ -24,6 +25,7 @@ class PlaywrightActions {
24
25
  goto_1.gotoActionGenerator,
25
26
  click_1.clickActionGenerator,
26
27
  hover_1.hoverActionGenerator,
28
+ press_1.pressActionGenerator,
27
29
  done_1.doneActionGenerator,
28
30
  assert_1.assertTextVisibilityActionGenerator,
29
31
  reload_page_1.reloadActionGenerator,
@@ -84,6 +86,7 @@ class PlaywrightActions {
84
86
  fill_1.fillActionGenerator,
85
87
  goto_1.gotoActionGenerator,
86
88
  click_1.clickActionGenerator,
89
+ press_1.pressActionGenerator,
87
90
  done_1.doneActionGenerator,
88
91
  assert_1.assertTextVisibilityActionGenerator,
89
92
  reload_page_1.reloadActionGenerator,
@@ -0,0 +1,4 @@
1
+ import { PlaywrightActionGenerator } from "../types";
2
+ export declare const PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element";
3
+ export declare const pressActionGenerator: PlaywrightActionGenerator;
4
+ //# sourceMappingURL=press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/actions/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AAExE,eAAO,MAAM,oBAAoB,EAAE,yBA4DlC,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pressActionGenerator = exports.PLAYWRIGHT_PRESS_ACTION_NAME = void 0;
4
+ const constants_1 = require("./constants");
5
+ const utils_1 = require("./utils");
6
+ exports.PLAYWRIGHT_PRESS_ACTION_NAME = "keyboard_press_on_element";
7
+ const pressActionGenerator = (page) => {
8
+ return {
9
+ execute: async ({ args }) => {
10
+ const css = args.css_selector;
11
+ const locator = await (0, utils_1.getPlaywrightLocatorUsingCssSelector)(css, args.xpath, page, args?.elementAnnotation);
12
+ const exec = new Function("page", `return page.${locator}.press("${args.key}", { timeout: 3000 })`);
13
+ await exec(page);
14
+ return {
15
+ locator,
16
+ };
17
+ },
18
+ // TODO: args transformer to be kept at a single place
19
+ template: (args, options) => {
20
+ return {
21
+ code: `await ${(0, utils_1.getPageVarName)()}.${options.locator}.press("${args.key}");`,
22
+ };
23
+ },
24
+ name: exports.PLAYWRIGHT_PRESS_ACTION_NAME,
25
+ schema: {
26
+ type: "function",
27
+ function: {
28
+ name: exports.PLAYWRIGHT_PRESS_ACTION_NAME,
29
+ description: "Focuses the matching element and presses a combination of the keys",
30
+ parameters: {
31
+ type: "object",
32
+ properties: {
33
+ reason: {
34
+ type: "string",
35
+ description: constants_1.DEFAULT_ACTION_REASON_PROMPT,
36
+ },
37
+ key: {
38
+ type: "string",
39
+ description: "The key to press on the keyboard after focusing the element. Example: F1 - F12, Digit0- Digit9, KeyA- KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp, etc.",
40
+ },
41
+ xpath: {
42
+ type: "string",
43
+ description: "XPath selector to identify the element uniquely and click it. When creating XPATH selector, ensure they are unique and specific enough to select only one element, even if there are multiple elements of the same type (like multiple h1 elements)",
44
+ },
45
+ css_selector: {
46
+ type: "string",
47
+ description: "CSS selector to identify the element uniquely.When creating CSS selectors, ensure they are unique to the page and specific enough to select only one element.",
48
+ },
49
+ },
50
+ required: ["reason", "key", "xpath", "css_selector"],
51
+ },
52
+ },
53
+ },
54
+ };
55
+ };
56
+ exports.pressActionGenerator = pressActionGenerator;
@@ -157,7 +157,7 @@ test("should annotate all important items on quizizz page", async ({
157
157
  (item) =>
158
158
  item.innerText.includes("accommodations") &&
159
159
  item.href ===
160
- "https://quizizz.com/admin/differentiation/accommodations",
160
+ "https://quizizz.com/admin/differentiation/accommodations",
161
161
  ),
162
162
  )
163
163
  .toBeTruthy();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAkBA,iBAAS,iBAAiB;;;;;EAOzB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,YAAY,EACZ,UAAU,EACV,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB,QAIA;AAED,wBAAsB,iBAAiB,qBAGtC;AAED,wBAAsB,eAAe,0DAqBpC;AAED,wBAAsB,UAAU,kBAqB/B;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAmBA,iBAAS,iBAAiB;;;;;EAOzB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,YAAY,EACZ,UAAU,EACV,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB,QAIA;AAED,wBAAsB,iBAAiB,qBAStC;AAED,wBAAsB,eAAe,0DAqBpC;AAED,wBAAsB,UAAU,kBAqB/B;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSessionDetails = exports.endSession = exports.getSessionState = exports.shouldStopSession = exports.setSessionDetails = void 0;
7
7
  const package_json_1 = __importDefault(require("../../package.json"));
8
+ const logger_1 = require("../bin/logger");
8
9
  const sessionDetails = {
9
10
  sessionId: undefined,
10
11
  version: package_json_1.default.version,
@@ -30,7 +31,11 @@ function setSessionDetails({ sessionId, generationId, testCaseId, projectRepoNam
30
31
  exports.setSessionDetails = setSessionDetails;
31
32
  async function shouldStopSession() {
32
33
  const sessionState = await getSessionState();
33
- return sessionState !== "started";
34
+ const shouldStopSession = sessionState !== "started";
35
+ if (shouldStopSession) {
36
+ new logger_1.CustomLogger().warn(`Generation to be stopped due to session state marked as ${sessionState}`);
37
+ }
38
+ return shouldStopSession;
34
39
  }
35
40
  exports.shouldStopSession = shouldStopSession;
36
41
  async function getSessionState() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/test-gen",
3
- "version": "0.35.6",
3
+ "version": "0.35.9",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -63,7 +63,7 @@
63
63
  "clean": "tsc --build --clean",
64
64
  "lint": "eslint .",
65
65
  "test": "vitest run",
66
- "e2e-test": "npx playwright test",
66
+ "test-browser": "npx playwright test",
67
67
  "test:watch": "vitest",
68
68
  "test:watch-files": "vitest $0 --watch"
69
69
  }
package/vitest.config.ts CHANGED
@@ -6,5 +6,6 @@ dotenvConfig({ path: [".env.local", ".env"] });
6
6
  export default defineConfig({
7
7
  test: {
8
8
  setupFiles: ["dotenv/config"],
9
+ include: ["src/**/*.test.ts"],
9
10
  },
10
11
  });