From bdcf7f01f79fd4e8acfafea0e1efae4019c50633 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 30 Apr 2026 11:40:45 -0500 Subject: [PATCH] Harden new issue dialog input test --- ui/src/components/NewIssueDialog.test.tsx | 39 ++++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/ui/src/components/NewIssueDialog.test.tsx b/ui/src/components/NewIssueDialog.test.tsx index 151ce9c7e63..03e8720fec6 100644 --- a/ui/src/components/NewIssueDialog.test.tsx +++ b/ui/src/components/NewIssueDialog.test.tsx @@ -222,6 +222,23 @@ async function flush() { }); } +async function typeTextareaValue(textarea: HTMLTextAreaElement, value: string) { + await act(async () => { + const valueSetter = Object.getOwnPropertyDescriptor( + window.HTMLTextAreaElement.prototype, + "value", + )?.set; + valueSetter?.call(textarea, value); + textarea.dispatchEvent(new InputEvent("input", { + bubbles: true, + data: value, + inputType: "insertText", + })); + textarea.dispatchEvent(new Event("change", { bubbles: true })); + }); + await flush(); +} + function renderDialog(container: HTMLDivElement) { const queryClient = new QueryClient({ defaultOptions: { @@ -244,6 +261,7 @@ describe("NewIssueDialog", () => { let container: HTMLDivElement; beforeEach(() => { + vi.useRealTimers(); container = document.createElement("div"); document.body.appendChild(container); dialogState.newIssueOpen = true; @@ -381,25 +399,8 @@ describe("NewIssueDialog", () => { expect(titleInput).not.toBeNull(); expect(descriptionInput).not.toBeNull(); - await act(async () => { - const valueSetter = Object.getOwnPropertyDescriptor( - HTMLTextAreaElement.prototype, - "value", - )?.set; - valueSetter?.call(titleInput, "Typed issue"); - titleInput!.dispatchEvent(new Event("input", { bubbles: true })); - }); - await flush(); - - await act(async () => { - const valueSetter = Object.getOwnPropertyDescriptor( - HTMLTextAreaElement.prototype, - "value", - )?.set; - valueSetter?.call(descriptionInput, "Typed description"); - descriptionInput!.dispatchEvent(new Event("input", { bubbles: true })); - }); - await flush(); + await typeTextareaValue(titleInput!, "Typed issue"); + await typeTextareaValue(descriptionInput!, "Typed description"); const submitButton = Array.from(container.querySelectorAll("button")) .find((button) => button.textContent?.includes("Create Issue"));