From 773ba92e93c20d0f16897fc7975d8af71a91cffa Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 30 Apr 2026 09:59:46 -0500 Subject: [PATCH] Stabilize new issue dialog submit test Co-Authored-By: Paperclip --- ui/src/components/NewIssueDialog.test.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/src/components/NewIssueDialog.test.tsx b/ui/src/components/NewIssueDialog.test.tsx index f938af87e53..ae61cbcab7d 100644 --- a/ui/src/components/NewIssueDialog.test.tsx +++ b/ui/src/components/NewIssueDialog.test.tsx @@ -222,6 +222,20 @@ async function flush() { }); } +async function waitForAssertion(assertion: () => void, attempts = 20) { + let lastError: unknown; + for (let attempt = 0; attempt < attempts; attempt += 1) { + try { + assertion(); + return; + } catch (error) { + lastError = error; + await flush(); + } + } + throw lastError; +} + function renderDialog(container: HTMLDivElement) { const queryClient = new QueryClient({ defaultOptions: { @@ -404,7 +418,9 @@ describe("NewIssueDialog", () => { const submitButton = Array.from(container.querySelectorAll("button")) .find((button) => button.textContent?.includes("Create Issue")); expect(submitButton).not.toBeUndefined(); - expect(submitButton?.hasAttribute("disabled")).toBe(false); + await waitForAssertion(() => { + expect(submitButton?.hasAttribute("disabled")).toBe(false); + }); await act(async () => { submitButton!.dispatchEvent(new MouseEvent("click", { bubbles: true }));