From 75636e869edc6517580798ae247707c8d3b1557f Mon Sep 17 00:00:00 2001 From: Nat Budin Date: Tue, 6 Oct 2026 05:26:46 -0700 Subject: [PATCH] Make the "save before it failed" proposal test deterministic It clicked Submit as soon as the page rendered, and whether the form's first autosave was already in flight by then was a race (it lost on a CI run). The failing save is now delayed, and the test waits for it to have started before clicking Submit. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_013mDr1nhgyzST2iPzCzMcCd --- .../javascript/EventProposals/EditEventProposal.test.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/javascript/EventProposals/EditEventProposal.test.tsx b/test/javascript/EventProposals/EditEventProposal.test.tsx index a4cb89a995..6b133a4881 100644 --- a/test/javascript/EventProposals/EditEventProposal.test.tsx +++ b/test/javascript/EventProposals/EditEventProposal.test.tsx @@ -21,6 +21,7 @@ describe('EditEventProposal', () => { let deletes: { method: string; path: string }[]; let submitError: Error | undefined; let updateError: Error | undefined; + let updateDelay: number | undefined; beforeEach(() => { user = userEvent.setup(); @@ -29,6 +30,7 @@ describe('EditEventProposal', () => { deletes = []; submitError = undefined; updateError = undefined; + updateDelay = undefined; }); const proposalResult = () => buildEventProposalFields(); @@ -55,6 +57,7 @@ describe('EditEventProposal', () => { updateEventProposal: { __typename: 'UpdateEventProposalPayload', event_proposal: proposalResult() }, }, }, + delay: updateDelay, maxUsageCount: 50, }, { @@ -145,9 +148,13 @@ describe('EditEventProposal', () => { it('does not submit, and shows the error, if the save before it failed', async () => { updateError = new Error('Title is too long'); + // (slow enough that the save is certainly still in flight when Submit is clicked, rather than racing it) + updateDelay = 300; const { findByRole, findByText, queryByText } = await renderPage(); + const submitButton = await findByRole('button', { name: 'Submit proposal' }); + await waitFor(() => expect(updates).toHaveBeenCalled()); - await user.click(await findByRole('button', { name: 'Submit proposal' })); + await user.click(submitButton); expect(await findByText(/Title is too long/)).toBeTruthy(); expect(submits).not.toHaveBeenCalled();