test: reproduce NumberField typing regression within one task

This commit is contained in:
maoyingjie
2026-10-27 19:55:43 +08:00
parent 9720ba1d03
commit 5937577101
+7 -3
View File
@@ -202,9 +202,13 @@ describe("NumberField public contracts", () => {
["9", "49"],
["0", "490"],
] as const) {
await input.trigger("keydown", { key });
await input.setValue(text);
await input.trigger("input");
// Keep keydown and text insertion in one task: awaiting trigger() here
// would flush the old nextTick(restore) before typing and hide the bug.
input.element.dispatchEvent(
new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }),
);
(input.element as HTMLInputElement).value = text;
input.element.dispatchEvent(new Event("input", { bubbles: true }));
await nextTick();
await nextTick();
expect((input.element as HTMLInputElement).value).toBe(text);