@empiricalrun/playwright-utils 0.4.0 → 0.4.1

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/test/index.d.ts +5 -0
  3. package/dist/test/index.d.ts.map +1 -0
  4. package/dist/test/index.js +13 -0
  5. package/dist/test/scripts/index.d.ts +3 -0
  6. package/dist/test/scripts/index.d.ts.map +1 -0
  7. package/dist/test/scripts/index.js +17 -0
  8. package/dist/test/scripts/locator-highlights.d.ts +3 -0
  9. package/dist/test/scripts/locator-highlights.d.ts.map +1 -0
  10. package/dist/test/scripts/locator-highlights.js +21 -0
  11. package/dist/test/scripts/mouse-pointer.d.ts +3 -0
  12. package/dist/test/scripts/mouse-pointer.d.ts.map +1 -0
  13. package/dist/test/scripts/mouse-pointer.js +80 -0
  14. package/dist/test/scripts/pw-locator-patch/expect.d.ts +5 -0
  15. package/dist/test/scripts/pw-locator-patch/expect.d.ts.map +1 -0
  16. package/dist/test/scripts/pw-locator-patch/expect.js +28 -0
  17. package/dist/test/scripts/pw-locator-patch/hover.d.ts +5 -0
  18. package/dist/test/scripts/pw-locator-patch/hover.d.ts.map +1 -0
  19. package/dist/test/scripts/pw-locator-patch/hover.js +23 -0
  20. package/dist/test/scripts/pw-locator-patch/inner-text.d.ts +5 -0
  21. package/dist/test/scripts/pw-locator-patch/inner-text.d.ts.map +1 -0
  22. package/dist/test/scripts/pw-locator-patch/inner-text.js +24 -0
  23. package/dist/test/scripts/pw-locator-patch/input-value.d.ts +5 -0
  24. package/dist/test/scripts/pw-locator-patch/input-value.d.ts.map +1 -0
  25. package/dist/test/scripts/pw-locator-patch/input-value.js +24 -0
  26. package/dist/test/scripts/pw-locator-patch/is-checked.d.ts +5 -0
  27. package/dist/test/scripts/pw-locator-patch/is-checked.d.ts.map +1 -0
  28. package/dist/test/scripts/pw-locator-patch/is-checked.js +24 -0
  29. package/dist/test/scripts/pw-locator-patch/is-disabled.d.ts +5 -0
  30. package/dist/test/scripts/pw-locator-patch/is-disabled.d.ts.map +1 -0
  31. package/dist/test/scripts/pw-locator-patch/is-disabled.js +24 -0
  32. package/dist/test/scripts/pw-locator-patch/is-editable.d.ts +5 -0
  33. package/dist/test/scripts/pw-locator-patch/is-editable.d.ts.map +1 -0
  34. package/dist/test/scripts/pw-locator-patch/is-editable.js +24 -0
  35. package/package.json +11 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e7f8f63: feat: add highlights to video recording
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,5 @@
1
+ import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
2
+ export declare const baseTestFixture: (testFn: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>) => TestType<PlaywrightTestArgs & PlaywrightTestOptions & {
3
+ [key: string]: any;
4
+ }, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAI1B,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C;;kDAQF,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.baseTestFixture = void 0;
4
+ const scripts_1 = require("./scripts");
5
+ const baseTestFixture = function (testFn) {
6
+ return testFn.extend({
7
+ page: async ({ page }, use) => {
8
+ (0, scripts_1.addCustomScripts)(page);
9
+ await use(page);
10
+ },
11
+ });
12
+ };
13
+ exports.baseTestFixture = baseTestFixture;
@@ -0,0 +1,3 @@
1
+ import type { Page } from "@playwright/test";
2
+ export declare function addCustomScripts(page: Page): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAK7C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,QAS1C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addCustomScripts = void 0;
4
+ const locator_highlights_1 = require("./locator-highlights");
5
+ const mouse_pointer_1 = require("./mouse-pointer");
6
+ function addCustomScripts(page) {
7
+ try {
8
+ // pointer highlighter and focus highlighter
9
+ (0, mouse_pointer_1.addMousePointerHighlighter)(page);
10
+ // playwright locator highlighter
11
+ (0, locator_highlights_1.addLocatorHighlights)(page);
12
+ }
13
+ catch (e) {
14
+ console.error("Failed to add mouse pointer highlighter", e);
15
+ }
16
+ }
17
+ exports.addCustomScripts = addCustomScripts;
@@ -0,0 +1,3 @@
1
+ import type { Page } from "@playwright/test";
2
+ export declare function addLocatorHighlights(page: Page): void;
3
+ //# sourceMappingURL=locator-highlights.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addLocatorHighlights = void 0;
4
+ const expect_1 = require("./pw-locator-patch/expect");
5
+ const hover_1 = require("./pw-locator-patch/hover");
6
+ const inner_text_1 = require("./pw-locator-patch/inner-text");
7
+ const input_value_1 = require("./pw-locator-patch/input-value");
8
+ const is_checked_1 = require("./pw-locator-patch/is-checked");
9
+ const is_disabled_1 = require("./pw-locator-patch/is-disabled");
10
+ const is_editable_1 = require("./pw-locator-patch/is-editable");
11
+ function addLocatorHighlights(page) {
12
+ const LocatorClass = page.locator("").constructor;
13
+ (0, expect_1.patchExpect)(LocatorClass);
14
+ (0, input_value_1.patchInputValue)(LocatorClass);
15
+ (0, is_checked_1.patchIsChecked)(LocatorClass);
16
+ (0, is_editable_1.patchIsEditable)(LocatorClass);
17
+ (0, is_disabled_1.patchIsDisabled)(LocatorClass);
18
+ (0, hover_1.patchHover)(LocatorClass);
19
+ (0, inner_text_1.patchInnerText)(LocatorClass);
20
+ }
21
+ exports.addLocatorHighlights = addLocatorHighlights;
@@ -0,0 +1,3 @@
1
+ import type { Page } from "@playwright/test";
2
+ export declare function addMousePointerHighlighter(page: Page): void;
3
+ //# sourceMappingURL=mouse-pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mouse-pointer.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/mouse-pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,QAgGpD"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMousePointerHighlighter = void 0;
4
+ function addMousePointerHighlighter(page) {
5
+ page.on("load", async () => {
6
+ await page?.evaluate(() => {
7
+ const box = document.createElement("div");
8
+ box.classList.add("empirical-mouse-pointer");
9
+ const styleElement = document.createElement("style");
10
+ styleElement.textContent = `
11
+ .empirical-mouse-pointer {
12
+ pointer-events: none;
13
+ position: absolute;
14
+ top: 0;
15
+ z-index: 10000;
16
+ left: 0;
17
+ width: 20px;
18
+ height: 20px;
19
+ background: rgba(0,0,0,.4);
20
+ border: 1px dashed #FF000D;
21
+ border-radius: 10px;
22
+ margin: -10px 0 0 -10px;
23
+ padding: 0;
24
+ transition: background .2s, border-radius .2s, border-color .2s;
25
+ }
26
+ .empirical-mouse-pointer.button-1 {
27
+ transition: none;
28
+ background: rgba(0,0,0,0.9);
29
+ }
30
+ .empirical-mouse-pointer.button-2 {
31
+ transition: none;
32
+ border-color: rgba(0,0,255,0.9);
33
+ }
34
+ .empirical-mouse-pointer.button-3 {
35
+ transition: none;
36
+ border-radius: 4px;
37
+ }
38
+ .empirical-mouse-pointer.button-4 {
39
+ transition: none;
40
+ border-color: rgba(255,0,0,0.9);
41
+ }
42
+ .empirical-mouse-pointer.button-5 {
43
+ transition: none;
44
+ border-color: rgba(0,255,0,0.9);
45
+ }
46
+ .empirical-element-grab-highlight {
47
+ outline: 2px dashed cyan !important;
48
+ }
49
+ *:focus {
50
+ outline: 2px dashed #FF000D !important;
51
+ }
52
+ *:focus-visible {
53
+ outline: 2px dashed #FF000D !important;
54
+ }
55
+ `;
56
+ document.head.appendChild(styleElement);
57
+ document.body.appendChild(box);
58
+ document.addEventListener("mousemove", (event) => {
59
+ box.style.left = `${event.pageX}px`;
60
+ box.style.top = `${event.pageY}px`;
61
+ updateButtons(event.buttons);
62
+ }, true);
63
+ document.addEventListener("mousedown", (event) => {
64
+ updateButtons(event.buttons);
65
+ box.classList.add(`button-${event.button + 1}`);
66
+ }, true);
67
+ document.addEventListener("mouseup", (event) => {
68
+ updateButtons(event.buttons);
69
+ box.classList.remove(`button-${event.button + 1}`);
70
+ }, true);
71
+ // @ts-ignore
72
+ function updateButtons(buttons) {
73
+ for (let i = 0; i < 5; i++) {
74
+ box.classList.toggle(`button-${i + 1}`, (buttons / Math.pow(2, i)) % 2 >= 1);
75
+ }
76
+ }
77
+ });
78
+ });
79
+ }
80
+ exports.addMousePointerHighlighter = addMousePointerHighlighter;
@@ -0,0 +1,5 @@
1
+ import type { Locator } from "@playwright/test";
2
+ export declare function patchExpect(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=expect.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchExpect = void 0;
4
+ function patchExpect(LocatorClass) {
5
+ //@ts-ignore _expect returnsPromise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }>
6
+ const originalExpect = LocatorClass.prototype._expect;
7
+ // @ts-ignore _expect is a private method in playwright
8
+ // https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L352
9
+ LocatorClass.prototype._expect = async function (expression, options) {
10
+ const result = await originalExpect.apply(this, [expression, options]);
11
+ if (result.matches) {
12
+ try {
13
+ await this.scrollIntoViewIfNeeded();
14
+ await this.evaluate((node) => {
15
+ node.classList.add("empirical-element-grab-highlight");
16
+ setTimeout(() => {
17
+ node.classList.remove("empirical-element-grab-highlight");
18
+ }, 2000);
19
+ });
20
+ }
21
+ catch (e) {
22
+ console.error("Failed to add highlight for locator method: _expect", e);
23
+ }
24
+ }
25
+ return result;
26
+ };
27
+ }
28
+ exports.patchExpect = patchExpect;
@@ -0,0 +1,5 @@
1
+ import { Locator } from "@playwright/test";
2
+ export declare function patchHover(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=hover.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchHover = void 0;
4
+ function patchHover(LocatorClass) {
5
+ const originalHover = LocatorClass.prototype.hover;
6
+ LocatorClass.prototype.hover = async function (options) {
7
+ // ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L243
8
+ await originalHover.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: hover", e);
20
+ }
21
+ };
22
+ }
23
+ exports.patchHover = patchHover;
@@ -0,0 +1,5 @@
1
+ import type { Locator } from "@playwright/test";
2
+ export declare function patchInnerText(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=inner-text.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchInnerText = void 0;
4
+ function patchInnerText(LocatorClass) {
5
+ const originalInputValue = LocatorClass.prototype.innerText;
6
+ //ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L251
7
+ LocatorClass.prototype.innerText = async function (options) {
8
+ const result = await originalInputValue.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: innerText", e);
20
+ }
21
+ return result;
22
+ };
23
+ }
24
+ exports.patchInnerText = patchInnerText;
@@ -0,0 +1,5 @@
1
+ import type { Locator } from "@playwright/test";
2
+ export declare function patchInputValue(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=input-value.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchInputValue = void 0;
4
+ function patchInputValue(LocatorClass) {
5
+ const originalInputValue = LocatorClass.prototype.inputValue;
6
+ //ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
7
+ LocatorClass.prototype.inputValue = async function (options) {
8
+ const result = await originalInputValue.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: inputValue", e);
20
+ }
21
+ return result;
22
+ };
23
+ }
24
+ exports.patchInputValue = patchInputValue;
@@ -0,0 +1,5 @@
1
+ import { Locator } from "@playwright/test";
2
+ export declare function patchIsChecked(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=is-checked.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchIsChecked = void 0;
4
+ function patchIsChecked(LocatorClass) {
5
+ const originalIsChecked = LocatorClass.prototype.isChecked;
6
+ LocatorClass.prototype.isChecked = async function (options) {
7
+ // ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L259
8
+ const result = await originalIsChecked.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: isChecked", e);
20
+ }
21
+ return result;
22
+ };
23
+ }
24
+ exports.patchIsChecked = patchIsChecked;
@@ -0,0 +1,5 @@
1
+ import { Locator } from "@playwright/test";
2
+ export declare function patchIsDisabled(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=is-disabled.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchIsDisabled = void 0;
4
+ function patchIsDisabled(LocatorClass) {
5
+ const originalIsDisabled = LocatorClass.prototype.isDisabled;
6
+ LocatorClass.prototype.isDisabled = async function (options) {
7
+ // ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L263
8
+ const result = await originalIsDisabled.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: isDisabled", e);
20
+ }
21
+ return result;
22
+ };
23
+ }
24
+ exports.patchIsDisabled = patchIsDisabled;
@@ -0,0 +1,5 @@
1
+ import { Locator } from "@playwright/test";
2
+ export declare function patchIsEditable(LocatorClass: {
3
+ prototype: Locator;
4
+ }): void;
5
+ //# sourceMappingURL=is-editable.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchIsEditable = void 0;
4
+ function patchIsEditable(LocatorClass) {
5
+ const originalIsEditable = LocatorClass.prototype.isEditable;
6
+ LocatorClass.prototype.isEditable = async function (options) {
7
+ // ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L267
8
+ const result = await originalIsEditable.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
+ node.classList.remove("empirical-element-grab-highlight");
15
+ }, 2000);
16
+ });
17
+ }
18
+ catch (e) {
19
+ console.log("Failed to add highlight for locator method: isEditable", e);
20
+ }
21
+ return result;
22
+ };
23
+ }
24
+ exports.patchIsEditable = patchIsEditable;
package/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
7
7
  },
8
8
  "main": "dist/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "default": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./test": {
15
+ "default": "./dist/test/index.js",
16
+ "types": "./dist/test/index.d.ts"
17
+ }
18
+ },
9
19
  "repository": {
10
20
  "type": "git",
11
21
  "url": "https://github.com/empirical-run/empirical.git"