@empiricalrun/playwright-utils 0.20.3 → 0.20.4
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 +6 -0
- package/dist/overlay-tests/click.spec.js +26 -2
- package/dist/test/scripts/locator-highlights.js +7 -7
- package/dist/test/scripts/pw-locator-patch/highlight/click.d.ts +3 -2
- package/dist/test/scripts/pw-locator-patch/highlight/click.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/click.js +36 -29
- package/dist/test/scripts/pw-locator-patch/highlight/expect.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/expect.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/expect.js +17 -6
- package/dist/test/scripts/pw-locator-patch/highlight/inner-text.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/inner-text.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/inner-text.js +15 -3
- package/dist/test/scripts/pw-locator-patch/highlight/input-value.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/input-value.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/input-value.js +15 -3
- package/dist/test/scripts/pw-locator-patch/highlight/is-checked.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-checked.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-checked.js +15 -3
- package/dist/test/scripts/pw-locator-patch/highlight/is-disabled.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-disabled.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-disabled.js +15 -3
- package/dist/test/scripts/pw-locator-patch/highlight/is-editable.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-editable.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/is-editable.js +15 -3
- package/dist/test/scripts/pw-locator-patch/highlight/text-content.d.ts +2 -1
- package/dist/test/scripts/pw-locator-patch/highlight/text-content.d.ts.map +1 -1
- package/dist/test/scripts/pw-locator-patch/highlight/text-content.js +15 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -64,7 +64,7 @@ test_1.test.beforeEach(async ({ page }) => {
|
|
|
64
64
|
await (0, test_1.expect)(page.getByText("This is a toast message")).not.toBeVisible();
|
|
65
65
|
await (0, test_1.expect)(page.getByRole("button", { name: "Close" })).toBeVisible();
|
|
66
66
|
});
|
|
67
|
-
(0, test_1.test)("should not return patch method in error stack", async ({ page }) => {
|
|
67
|
+
(0, test_1.test)("should not return hover patch method in error stack", async ({ page, }) => {
|
|
68
68
|
await page.goto(`http://localhost:${PORT}/tos.html`);
|
|
69
69
|
let error;
|
|
70
70
|
try {
|
|
@@ -75,6 +75,30 @@ test_1.test.beforeEach(async ({ page }) => {
|
|
|
75
75
|
}
|
|
76
76
|
(0, test_1.expect)(error).toBeDefined();
|
|
77
77
|
(0, test_1.expect)(error.stack).toBeDefined();
|
|
78
|
+
(0, test_1.expect)(error.stack).not.toContain("pw-locator-patch");
|
|
78
79
|
(0, test_1.expect)(error.stack).not.toContain("hover.ts");
|
|
79
|
-
|
|
80
|
+
const firstLineThatStartsWithAt = error
|
|
81
|
+
.stack.split("\n")
|
|
82
|
+
.find((line) => line.trim().startsWith("at "));
|
|
83
|
+
(0, test_1.expect)(firstLineThatStartsWithAt).toBeDefined();
|
|
84
|
+
(0, test_1.expect)(firstLineThatStartsWithAt).toContain("overlay-tests/click.spec.ts:85");
|
|
85
|
+
});
|
|
86
|
+
(0, test_1.test)("should not return click patch method in error stack", async ({ page, }) => {
|
|
87
|
+
await page.goto(`http://localhost:${PORT}/tos.html`);
|
|
88
|
+
let error;
|
|
89
|
+
try {
|
|
90
|
+
await page.locator("div.some-random-class-name").click();
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
error = e;
|
|
94
|
+
}
|
|
95
|
+
(0, test_1.expect)(error).toBeDefined();
|
|
96
|
+
(0, test_1.expect)(error.stack).toBeDefined();
|
|
97
|
+
(0, test_1.expect)(error.stack).not.toContain("pw-locator-patch");
|
|
98
|
+
(0, test_1.expect)(error.stack).not.toContain("click.ts");
|
|
99
|
+
const firstLineThatStartsWithAt = error
|
|
100
|
+
.stack.split("\n")
|
|
101
|
+
.find((line) => line.trim().startsWith("at "));
|
|
102
|
+
(0, test_1.expect)(firstLineThatStartsWithAt).toBeDefined();
|
|
103
|
+
(0, test_1.expect)(firstLineThatStartsWithAt).toContain("overlay-tests/click.spec.ts:106");
|
|
80
104
|
});
|
|
@@ -19,11 +19,11 @@ exports.addLocatorHighlights = addLocatorHighlights;
|
|
|
19
19
|
function applyHighlights(page, testFn) {
|
|
20
20
|
const LocatorClass = page.locator("").constructor;
|
|
21
21
|
(0, hover_1.patchHover)(LocatorClass, testFn);
|
|
22
|
-
(0, expect_1.patchExpect)(LocatorClass);
|
|
23
|
-
(0, input_value_1.patchInputValue)(LocatorClass);
|
|
24
|
-
(0, is_checked_1.patchIsChecked)(LocatorClass);
|
|
25
|
-
(0, is_editable_1.patchIsEditable)(LocatorClass);
|
|
26
|
-
(0, is_disabled_1.patchIsDisabled)(LocatorClass);
|
|
27
|
-
(0, inner_text_1.patchInnerText)(LocatorClass);
|
|
28
|
-
(0, text_content_1.patchTextContent)(LocatorClass);
|
|
22
|
+
(0, expect_1.patchExpect)(LocatorClass, testFn);
|
|
23
|
+
(0, input_value_1.patchInputValue)(LocatorClass, testFn);
|
|
24
|
+
(0, is_checked_1.patchIsChecked)(LocatorClass, testFn);
|
|
25
|
+
(0, is_editable_1.patchIsEditable)(LocatorClass, testFn);
|
|
26
|
+
(0, is_disabled_1.patchIsDisabled)(LocatorClass, testFn);
|
|
27
|
+
(0, inner_text_1.patchInnerText)(LocatorClass, testFn);
|
|
28
|
+
(0, text_content_1.patchTextContent)(LocatorClass, testFn);
|
|
29
29
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Locator
|
|
1
|
+
import type { Locator } from "@playwright/test";
|
|
2
|
+
import { TestFn } from "../../types";
|
|
2
3
|
type OverlayElement = {
|
|
3
4
|
interceptor: string;
|
|
4
5
|
parent: string | undefined;
|
|
@@ -6,6 +7,6 @@ type OverlayElement = {
|
|
|
6
7
|
export declare function extractInterceptingElement(errorMessage: string): OverlayElement | undefined;
|
|
7
8
|
export declare function patchClick(LocatorClass: Function & {
|
|
8
9
|
prototype: Locator;
|
|
9
|
-
}, testFn:
|
|
10
|
+
}, testFn: TestFn): void;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=click.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/click.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/click.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA8BrC,KAAK,cAAc,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,GACnB,cAAc,GAAG,SAAS,CAiC5B;AAuGD,wBAAgB,UAAU,CACxB,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA+Df"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchClick = exports.extractInterceptingElement = void 0;
|
|
4
4
|
const planner_1 = require("@empiricalrun/test-gen/agent/master/planner");
|
|
5
5
|
const run_1 = require("@empiricalrun/test-gen/agent/master/run");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
6
7
|
// Static flag to track if click has been patched
|
|
7
8
|
const isClickPatched = new WeakMap();
|
|
8
9
|
const ERROR_SUBSTRING_INTERCEPTION = "intercepts pointer events";
|
|
@@ -63,7 +64,7 @@ function extractInterceptingElement(errorMessage) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
exports.extractInterceptingElement = extractInterceptingElement;
|
|
66
|
-
function
|
|
67
|
+
function overlayDescription(element) {
|
|
67
68
|
if (element) {
|
|
68
69
|
const { interceptor, parent } = element;
|
|
69
70
|
if (parent) {
|
|
@@ -155,44 +156,50 @@ function annotateForReport(testFn, description) {
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
function patchClick(LocatorClass, testFn) {
|
|
158
|
-
// Check if already patched
|
|
159
159
|
if (isClickPatched.get(LocatorClass)) {
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
const originalClick = LocatorClass.prototype.click;
|
|
163
163
|
//ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
|
|
164
164
|
LocatorClass.prototype.click = async function (options) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
catch (originalError) {
|
|
169
|
-
if (process.env.TEST_GEN_TOKEN) {
|
|
170
|
-
// Happening during test-gen, we ignore this
|
|
171
|
-
throw originalError;
|
|
172
|
-
}
|
|
173
|
-
if (!originalError.message?.includes(ERROR_SUBSTRING_INTERCEPTION)) {
|
|
174
|
-
throw originalError;
|
|
175
|
-
}
|
|
176
|
-
let overlayElement = undefined;
|
|
165
|
+
let result;
|
|
166
|
+
const stepName = `locator.click(${(0, utils_1.description)(this)})`;
|
|
167
|
+
await testFn.step(stepName, async () => {
|
|
177
168
|
try {
|
|
178
|
-
|
|
169
|
+
result = await originalClick.apply(this, [options]);
|
|
179
170
|
}
|
|
180
|
-
catch (
|
|
181
|
-
|
|
171
|
+
catch (originalError) {
|
|
172
|
+
if (originalError instanceof Error) {
|
|
173
|
+
Error.captureStackTrace(originalError, LocatorClass.prototype.click);
|
|
174
|
+
}
|
|
175
|
+
if (process.env.TEST_GEN_TOKEN) {
|
|
176
|
+
// Happening during test-gen, we ignore this
|
|
177
|
+
throw originalError;
|
|
178
|
+
}
|
|
179
|
+
if (!originalError.message?.includes(ERROR_SUBSTRING_INTERCEPTION)) {
|
|
180
|
+
throw originalError;
|
|
181
|
+
}
|
|
182
|
+
let overlayElement = undefined;
|
|
183
|
+
try {
|
|
184
|
+
overlayElement = extractInterceptingElement(originalError.message);
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
// Ignoring this error
|
|
188
|
+
}
|
|
189
|
+
annotateForReport(testFn, `Attempting to auto-dismiss overlay: ${overlayDescription(overlayElement)}`);
|
|
190
|
+
try {
|
|
191
|
+
await runAgentOnOverlay(this._frame._page, overlayElement);
|
|
192
|
+
}
|
|
193
|
+
catch (agentError) {
|
|
194
|
+
annotateForReport(testFn, `Error in overlay dismiss: ${agentError.toString()}`);
|
|
195
|
+
throw originalError;
|
|
196
|
+
}
|
|
197
|
+
annotateForReport(testFn, "Overlay was dismissed, retrying original action");
|
|
198
|
+
await originalClick.apply(this, [options]);
|
|
182
199
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
await runAgentOnOverlay(this._frame._page, overlayElement);
|
|
186
|
-
}
|
|
187
|
-
catch (agentError) {
|
|
188
|
-
annotateForReport(testFn, `Error in overlay dismiss: ${agentError.toString()}`);
|
|
189
|
-
throw originalError;
|
|
190
|
-
}
|
|
191
|
-
annotateForReport(testFn, "Overlay was dismissed, retrying original action");
|
|
192
|
-
await originalClick.apply(this, [options]);
|
|
193
|
-
}
|
|
200
|
+
}, { box: true });
|
|
201
|
+
return result;
|
|
194
202
|
};
|
|
195
|
-
// Set flag to indicate patching is complete
|
|
196
203
|
isClickPatched.set(LocatorClass, true);
|
|
197
204
|
}
|
|
198
205
|
exports.patchClick = patchClick;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/expect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,WAAW,CACzB,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QAkCf"}
|
|
@@ -3,19 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchExpect = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isExpectPatched = new WeakMap();
|
|
6
|
-
function patchExpect(LocatorClass) {
|
|
6
|
+
function patchExpect(LocatorClass, testFn) {
|
|
7
7
|
if (isExpectPatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
//@ts-ignore _expect returnsPromise<{ matches: boolean, received?: any, log?: string[], timedOut?: boolean }>
|
|
11
10
|
const originalExpect = LocatorClass.prototype._expect;
|
|
12
11
|
// @ts-ignore _expect is a private method in playwright
|
|
13
12
|
// https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L352
|
|
14
13
|
LocatorClass.prototype._expect = async function (expression, options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
let result;
|
|
15
|
+
const stepName = `locator._expect(${(0, utils_1.description)(this)})`;
|
|
16
|
+
await testFn.step(stepName, async () => {
|
|
17
|
+
try {
|
|
18
|
+
result = await originalExpect.apply(this, [expression, options]);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof Error) {
|
|
22
|
+
Error.captureStackTrace(error, LocatorClass.prototype._expect);
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
if (result.matches) {
|
|
27
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
28
|
+
}
|
|
29
|
+
}, { box: true });
|
|
19
30
|
return result;
|
|
20
31
|
};
|
|
21
32
|
isExpectPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"inner-text.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/inner-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,cAAc,CAC5B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA4Bf"}
|
|
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchInnerText = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isInnerTextPatched = new WeakMap();
|
|
6
|
-
function patchInnerText(LocatorClass) {
|
|
6
|
+
function patchInnerText(LocatorClass, testFn) {
|
|
7
7
|
if (isInnerTextPatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalInnerText = LocatorClass.prototype.innerText;
|
|
11
11
|
//ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L251
|
|
12
12
|
LocatorClass.prototype.innerText = async function (options) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let result;
|
|
14
|
+
const stepName = `locator.innerText(${(0, utils_1.description)(this)})`;
|
|
15
|
+
await testFn.step(stepName, async () => {
|
|
16
|
+
try {
|
|
17
|
+
result = await originalInnerText.apply(this, [options]);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
Error.captureStackTrace(error, LocatorClass.prototype.innerText);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
26
|
+
}, { box: true });
|
|
15
27
|
return result;
|
|
16
28
|
};
|
|
17
29
|
isInnerTextPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"input-value.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/input-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA4Bf"}
|
|
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchInputValue = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isInputValuePatched = new WeakMap();
|
|
6
|
-
function patchInputValue(LocatorClass) {
|
|
6
|
+
function patchInputValue(LocatorClass, testFn) {
|
|
7
7
|
if (isInputValuePatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalInputValue = LocatorClass.prototype.inputValue;
|
|
11
11
|
//ref: github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L255
|
|
12
12
|
LocatorClass.prototype.inputValue = async function (options) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let result;
|
|
14
|
+
const stepName = `locator.inputValue(${(0, utils_1.description)(this)})`;
|
|
15
|
+
await testFn.step(stepName, async () => {
|
|
16
|
+
try {
|
|
17
|
+
result = await originalInputValue.apply(this, [options]);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
Error.captureStackTrace(error, LocatorClass.prototype.inputValue);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
26
|
+
}, { box: true });
|
|
15
27
|
return result;
|
|
16
28
|
};
|
|
17
29
|
isInputValuePatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-checked.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-checked.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,cAAc,CAC5B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA4Bf"}
|
|
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchIsChecked = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isIsCheckedPatched = new WeakMap();
|
|
6
|
-
function patchIsChecked(LocatorClass) {
|
|
6
|
+
function patchIsChecked(LocatorClass, testFn) {
|
|
7
7
|
if (isIsCheckedPatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalIsChecked = LocatorClass.prototype.isChecked;
|
|
11
11
|
LocatorClass.prototype.isChecked = async function (options) {
|
|
12
12
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L259
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let result;
|
|
14
|
+
const stepName = `locator.isChecked(${(0, utils_1.description)(this)})`;
|
|
15
|
+
await testFn.step(stepName, async () => {
|
|
16
|
+
try {
|
|
17
|
+
result = await originalIsChecked.apply(this, [options]);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
Error.captureStackTrace(error, LocatorClass.prototype.isChecked);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
26
|
+
}, { box: true });
|
|
15
27
|
return result;
|
|
16
28
|
};
|
|
17
29
|
isIsCheckedPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA4Bf"}
|
|
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchIsDisabled = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isIsDisabledPatched = new WeakMap();
|
|
6
|
-
function patchIsDisabled(LocatorClass) {
|
|
6
|
+
function patchIsDisabled(LocatorClass, testFn) {
|
|
7
7
|
if (isIsDisabledPatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalIsDisabled = LocatorClass.prototype.isDisabled;
|
|
11
11
|
LocatorClass.prototype.isDisabled = async function (options) {
|
|
12
12
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L263
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let result;
|
|
14
|
+
const stepName = `locator.isDisabled(${(0, utils_1.description)(this)})`;
|
|
15
|
+
await testFn.step(stepName, async () => {
|
|
16
|
+
try {
|
|
17
|
+
result = await originalIsDisabled.apply(this, [options]);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
Error.captureStackTrace(error, LocatorClass.prototype.isDisabled);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
26
|
+
}, { box: true });
|
|
15
27
|
return result;
|
|
16
28
|
};
|
|
17
29
|
isIsDisabledPatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"is-editable.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/is-editable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,eAAe,CAC7B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA2Bf"}
|
|
@@ -3,14 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchIsEditable = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isIsEditablePatched = new WeakMap();
|
|
6
|
-
function patchIsEditable(LocatorClass) {
|
|
6
|
+
function patchIsEditable(LocatorClass, testFn) {
|
|
7
7
|
if (isIsEditablePatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalIsEditable = LocatorClass.prototype.isEditable;
|
|
11
11
|
LocatorClass.prototype.isEditable = async function (options) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let result;
|
|
13
|
+
const stepName = `locator.isEditable(${(0, utils_1.description)(this)})`;
|
|
14
|
+
await testFn.step(stepName, async () => {
|
|
15
|
+
try {
|
|
16
|
+
result = await originalIsEditable.apply(this, [options]);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof Error) {
|
|
20
|
+
Error.captureStackTrace(error, LocatorClass.prototype.isEditable);
|
|
21
|
+
}
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
25
|
+
}, { box: true });
|
|
14
26
|
return result;
|
|
15
27
|
};
|
|
16
28
|
isIsEditablePatched.set(LocatorClass, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"text-content.d.ts","sourceRoot":"","sources":["../../../../../src/test/scripts/pw-locator-patch/highlight/text-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,EAC/C,MAAM,EAAE,MAAM,QA4Bf"}
|
|
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.patchTextContent = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const isTextContentPatched = new WeakMap();
|
|
6
|
-
function patchTextContent(LocatorClass) {
|
|
6
|
+
function patchTextContent(LocatorClass, testFn) {
|
|
7
7
|
if (isTextContentPatched.get(LocatorClass)) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
const originalTextContent = LocatorClass.prototype.textContent;
|
|
11
11
|
// ref: https://github.com/microsoft/playwright/blob/69287f26bc514b740eac40160503d6fac8185d37/packages/playwright-core/src/client/locator.ts#L318
|
|
12
12
|
LocatorClass.prototype.textContent = async function (options) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let result;
|
|
14
|
+
const stepName = `locator.textContent(${(0, utils_1.description)(this)})`;
|
|
15
|
+
await testFn.step(stepName, async () => {
|
|
16
|
+
try {
|
|
17
|
+
result = await originalTextContent.apply(this, [options]);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error) {
|
|
21
|
+
Error.captureStackTrace(error, LocatorClass.prototype.textContent);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
await (0, utils_1.scrollAndHighlight)(this);
|
|
26
|
+
}, { box: true });
|
|
15
27
|
return result;
|
|
16
28
|
};
|
|
17
29
|
isTextContentPatched.set(LocatorClass, true);
|