@empiricalrun/playwright-utils 0.5.0 → 0.6.0

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,11 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 59206d0: feat: add highlighter support for textContent
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAU7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAS9C"}
1
+ {"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAU9C"}
@@ -8,6 +8,7 @@ const input_value_1 = require("./pw-locator-patch/input-value");
8
8
  const is_checked_1 = require("./pw-locator-patch/is-checked");
9
9
  const is_disabled_1 = require("./pw-locator-patch/is-disabled");
10
10
  const is_editable_1 = require("./pw-locator-patch/is-editable");
11
+ const text_content_1 = require("./pw-locator-patch/text-content");
11
12
  function addLocatorHighlights(page) {
12
13
  const LocatorClass = page.locator("").constructor;
13
14
  (0, expect_1.patchExpect)(LocatorClass);
@@ -17,5 +18,6 @@ function addLocatorHighlights(page) {
17
18
  (0, is_disabled_1.patchIsDisabled)(LocatorClass);
18
19
  (0, hover_1.patchHover)(LocatorClass);
19
20
  (0, inner_text_1.patchInnerText)(LocatorClass);
21
+ (0, text_content_1.patchTextContent)(LocatorClass);
20
22
  }
21
23
  exports.addLocatorHighlights = addLocatorHighlights;
@@ -1 +1 @@
1
- {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAyB/D"}
1
+ {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QA2B/D"}
@@ -14,7 +14,9 @@ function patchExpect(LocatorClass) {
14
14
  await this.evaluate((node) => {
15
15
  node.classList.add("empirical-element-grab-highlight");
16
16
  setTimeout(() => {
17
- node.classList.remove("empirical-element-grab-highlight");
17
+ if (node.isConnected) {
18
+ node.classList.remove("empirical-element-grab-highlight");
19
+ }
18
20
  }, 2000);
19
21
  });
20
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAiB9D"}
1
+ {"version":3,"file":"hover.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/hover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,UAAU,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAmB9D"}
@@ -11,7 +11,9 @@ function patchHover(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAkBlE"}
1
+ {"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBlE"}
@@ -11,7 +11,9 @@ function patchInnerText(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAkBnE"}
1
+ {"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
@@ -11,7 +11,9 @@ function patchInputValue(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAkBlE"}
1
+ {"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,cAAc,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBlE"}
@@ -11,7 +11,9 @@ function patchIsChecked(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAkBnE"}
1
+ {"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
@@ -11,7 +11,9 @@ function patchIsDisabled(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAkBnE"}
1
+ {"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBnE"}
@@ -11,7 +11,9 @@ function patchIsEditable(LocatorClass) {
11
11
  await this.evaluate((node) => {
12
12
  node.classList.add("empirical-element-grab-highlight");
13
13
  setTimeout(() => {
14
- node.classList.remove("empirical-element-grab-highlight");
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
15
17
  }, 2000);
16
18
  });
17
19
  }
@@ -0,0 +1,5 @@
1
+ import type { Locator } from "@playwright/test";
2
+ export declare function patchTextContent(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=text-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../../../src/test/scripts/pw-locator-patch/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,QAoBpE"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchTextContent = void 0;
4
+ function patchTextContent(LocatorClass) {
5
+ const originalTextContent = LocatorClass.prototype.textContent;
6
+ //ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
7
+ LocatorClass.prototype.textContent = async function (options) {
8
+ const result = await originalTextContent.apply(this, [options]);
9
+ try {
10
+ await this.scrollIntoViewIfNeeded();
11
+ await this.evaluate((node) => {
12
+ node.classList.add("empirical-element-grab-highlight");
13
+ setTimeout(() => {
14
+ if (node.isConnected) {
15
+ node.classList.remove("empirical-element-grab-highlight");
16
+ }
17
+ }, 2000);
18
+ });
19
+ }
20
+ catch (e) {
21
+ console.log("Failed to add highlight for locator method: textContent", e);
22
+ }
23
+ return result;
24
+ };
25
+ }
26
+ exports.patchTextContent = patchTextContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"