@empiricalrun/playwright-utils 0.26.15 → 0.26.17

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,37 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.26.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [387f475]
8
+ - Updated dependencies [39f1aa8]
9
+ - Updated dependencies [09a1126]
10
+ - Updated dependencies [1f74b60]
11
+ - Updated dependencies [e5f8110]
12
+ - Updated dependencies [b39d75c]
13
+ - Updated dependencies [587532f]
14
+ - Updated dependencies [99d8490]
15
+ - Updated dependencies [226c361]
16
+ - Updated dependencies [41fc766]
17
+ - Updated dependencies [d00c867]
18
+ - Updated dependencies [d018e6b]
19
+ - Updated dependencies [b908890]
20
+ - @empiricalrun/test-gen@0.64.1
21
+ - @empiricalrun/llm@0.17.3
22
+
23
+ ## 0.26.16
24
+
25
+ ### Patch Changes
26
+
27
+ - 43dc453: fix: record locators before execution for more reliable codegen
28
+ - Updated dependencies [e5b9f7e]
29
+ - Updated dependencies [43dc453]
30
+ - Updated dependencies [1a5ec8d]
31
+ - Updated dependencies [24d9415]
32
+ - @empiricalrun/test-gen@0.64.0
33
+ - @empiricalrun/llm@0.17.2
34
+
3
35
  ## 0.26.15
4
36
 
5
37
  ### Patch Changes
@@ -20,15 +20,13 @@ const useCache = (data) => {
20
20
  }
21
21
  fs_1.default.writeFileSync(cache_1.CACHE_FILE, JSON.stringify(cacheValue, null, 2), "utf8");
22
22
  };
23
- const deleteCache = () => {
24
- if (fs_1.default.existsSync(cache_1.CACHE_FILE))
25
- fs_1.default.unlinkSync(cache_1.CACHE_FILE);
26
- };
27
23
  fixtures_1.test.beforeEach(async ({ page }) => {
28
24
  (0, test_1.injectLocatorHighlightScripts)(page, fixtures_1.test);
29
25
  });
30
26
  fixtures_1.test.afterEach(() => {
31
- deleteCache();
27
+ // Delete overlay cache
28
+ if (fs_1.default.existsSync(cache_1.CACHE_FILE))
29
+ fs_1.default.unlinkSync(cache_1.CACHE_FILE);
32
30
  });
33
31
  (0, fixtures_1.test)("overlay dismiss should not trigger recursively when executing from cache", async ({ page, server, }) => {
34
32
  // Set up cache with a bad value: click on "Target" to dimiss the glass pane
@@ -1,10 +1,36 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
3
7
  const test_1 = require("../test");
8
+ const cache_1 = require("../test/scripts/pw-locator-patch/dismiss-overlays/cache");
4
9
  const fixtures_1 = require("./fixtures");
5
10
  fixtures_1.test.beforeEach(async ({ page }) => {
6
11
  (0, test_1.injectLocatorHighlightScripts)(page, fixtures_1.test);
7
12
  });
13
+ fixtures_1.test.afterAll(async () => {
14
+ // Delete overlay cache
15
+ if (fs_1.default.existsSync(cache_1.CACHE_FILE))
16
+ fs_1.default.unlinkSync(cache_1.CACHE_FILE);
17
+ });
18
+ function getCacheDataWithDom({ dom }) {
19
+ const cacheData = JSON.parse(fs_1.default.readFileSync(cache_1.CACHE_FILE, "utf8"));
20
+ return cacheData.data.find(({ element }) => {
21
+ if (dom)
22
+ return element.dom.includes(dom);
23
+ return false;
24
+ });
25
+ }
26
+ function getCacheDataWithTextContent({ textContent }) {
27
+ const cacheData = JSON.parse(fs_1.default.readFileSync(cache_1.CACHE_FILE, "utf8"));
28
+ return cacheData.data.find(({ element }) => {
29
+ if (textContent)
30
+ return element.textContent.includes(textContent);
31
+ return false;
32
+ });
33
+ }
8
34
  (0, fixtures_1.test)("should dismiss survicate for hover", async ({ page, server }) => {
9
35
  await page.goto(`${server.baseURL}/survey.html`);
10
36
  // Assert that Survicate and button loads
@@ -27,6 +53,38 @@ fixtures_1.test.beforeEach(async ({ page }) => {
27
53
  // Do the click, which should pass
28
54
  await page.getByRole("button", { name: "Target" }).click();
29
55
  await (0, fixtures_1.expect)(page.getByRole("heading", { name: "Terms of Service" })).not.toBeVisible();
56
+ // Assert cache is correct
57
+ const withDom = getCacheDataWithDom({
58
+ dom: '<div class="terms-text">',
59
+ });
60
+ (0, fixtures_1.expect)(withDom).toBeTruthy();
61
+ const withText = getCacheDataWithTextContent({
62
+ textContent: "By accepting these terms, you agree to our Terms of Service",
63
+ });
64
+ (0, fixtures_1.expect)(withDom).toEqual(withText);
65
+ const code = withDom?.code;
66
+ (0, fixtures_1.expect)(code).toBeDefined();
67
+ (0, fixtures_1.expect)(code).toMatch(/await page\.getBy(Text|Label)\('I have read and agree to the'\)\.click\(\);/);
68
+ (0, fixtures_1.expect)(code).toContain("await page.getByRole('button', { name: 'Accept' }).click()");
69
+ });
70
+ (0, fixtures_1.test)("should be able to fill form and dismiss overlay", async ({ page, server, }) => {
71
+ await page.goto(`${server.baseURL}/overlay-form.html`);
72
+ await page.getByRole("button", { name: "Target" }).click();
73
+ await (0, fixtures_1.expect)(page.getByText("Target was clicked")).toBeVisible();
74
+ // Assert cache is correct
75
+ const withDom = getCacheDataWithDom({
76
+ dom: 'id="hearAboutUs"',
77
+ });
78
+ (0, fixtures_1.expect)(withDom).toBeTruthy();
79
+ const withText = getCacheDataWithTextContent({
80
+ textContent: "How did you hear about us",
81
+ });
82
+ (0, fixtures_1.expect)(withText).toBeTruthy();
83
+ (0, fixtures_1.expect)(withDom).toEqual(withText);
84
+ const code = withDom?.code;
85
+ (0, fixtures_1.expect)(code).toBeDefined();
86
+ (0, fixtures_1.expect)(code).toContain("await page.getByPlaceholder('Please enter at least 4').fill");
87
+ (0, fixtures_1.expect)(code).toContain("await page.getByRole('button', { name: 'Submit' }).click()");
30
88
  });
31
89
  (0, fixtures_1.test)("should choose and dismiss the correct overlay", async ({ page, server, }) => {
32
90
  await page.goto(`${server.baseURL}/choose-an-overlay.html`);
@@ -39,6 +97,19 @@ fixtures_1.test.beforeEach(async ({ page }) => {
39
97
  // Assert correct overlay was dismissed
40
98
  await (0, fixtures_1.expect)(page.getByText("This is a toast message")).not.toBeVisible();
41
99
  await (0, fixtures_1.expect)(page.getByRole("button", { name: "Close" })).toBeVisible();
100
+ // Assert cache is correct
101
+ const withDom = getCacheDataWithDom({
102
+ dom: '<div id="toast" class="z-[100]">',
103
+ });
104
+ (0, fixtures_1.expect)(withDom).toBeTruthy();
105
+ const withText = getCacheDataWithTextContent({
106
+ textContent: "This is a toast message",
107
+ });
108
+ (0, fixtures_1.expect)(withText).toBeTruthy();
109
+ (0, fixtures_1.expect)(withDom).toEqual(withText);
110
+ const code = withDom?.code;
111
+ (0, fixtures_1.expect)(code).toBeDefined();
112
+ (0, fixtures_1.expect)(code).toContain("await page.getByRole('button', { name: '×' }).click()");
42
113
  });
43
114
  // Test is flaky - skipping it
44
115
  fixtures_1.test.skip("should fallback when the overlay cannot be dismissed", async ({ page, server, }) => {
@@ -62,11 +133,6 @@ fixtures_1.test.skip("should fallback when the overlay cannot be dismissed", asy
62
133
  await page.locator("#sidebar-menu").getByText("Customise UI").click();
63
134
  await (0, fixtures_1.expect)(page.getByText("This is the Customise UI page")).toBeVisible();
64
135
  });
65
- (0, fixtures_1.test)("should be able to fill form and dismiss overlay", async ({ page, server, }) => {
66
- await page.goto(`${server.baseURL}/overlay-form.html`);
67
- await page.getByRole("button", { name: "Target" }).click();
68
- await (0, fixtures_1.expect)(page.getByText("Target was clicked")).toBeVisible();
69
- });
70
136
  fixtures_1.test.skip("should be able to dismiss multiple overlays", async ({ page, server, }) => {
71
137
  await page.goto(`${server.baseURL}/loop-to-dismiss.html`);
72
138
  await page.getByRole("button", { name: "Target" }).click();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.26.15",
3
+ "version": "0.26.17",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -38,9 +38,9 @@
38
38
  "mailosaur": "^8.6.1",
39
39
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
40
40
  "rimraf": "^6.0.1",
41
- "@empiricalrun/llm": "^0.17.1",
41
+ "@empiricalrun/llm": "^0.17.3",
42
42
  "@empiricalrun/r2-uploader": "^0.3.9",
43
- "@empiricalrun/test-gen": "^0.63.0"
43
+ "@empiricalrun/test-gen": "^0.64.1"
44
44
  },
45
45
  "scripts": {
46
46
  "dev": "tsc --build --watch",