fix(nightly): refactor freeze-path feature test (#5557)
This commit is contained in:
parent
89756390e8
commit
2ed0b10679
3 changed files with 47 additions and 6 deletions
|
|
@ -0,0 +1,25 @@
|
|||
import { Page } from "playwright/test";
|
||||
|
||||
export const evaluateReactStateChanges = async (
|
||||
page: Page,
|
||||
selector: string,
|
||||
value: string,
|
||||
) => {
|
||||
await page.evaluate(
|
||||
({ selector, value }) => {
|
||||
const inputElement = document.querySelector(selector) as HTMLInputElement;
|
||||
if (inputElement) {
|
||||
const prototype = Object.getPrototypeOf(inputElement);
|
||||
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
||||
prototype,
|
||||
"value",
|
||||
)?.set;
|
||||
if (nativeInputValueSetter) {
|
||||
nativeInputValueSetter.call(inputElement, value);
|
||||
inputElement.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}
|
||||
}
|
||||
},
|
||||
{ selector, value },
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue