Compare commits

...

5 Commits

Author SHA1 Message Date
Matt Carroll
48c5c131c6 update test on code from pairing with Rick 2025-05-02 12:52:17 -07:00
Matt Carroll
fbdd204466 remove fix (no longer needed) 2025-04-29 15:44:57 -07:00
Matt Carroll
bf777c4b99 Remove fix, rebase to pick up Seb's fix, refactor test to use waitForMicrotasks 2025-04-29 15:41:55 -07:00
Matt Carroll
58a09a3206 unfocus test 2025-04-29 15:25:54 -07:00
Matt Carroll
c4b0701ec7 Fix multiple form submissions from throwing 2025-04-29 15:25:54 -07:00

View File

@@ -1670,6 +1670,37 @@ describe('ReactDOMForm', () => {
expect(divRef.current.textContent).toEqual('Current username: acdlite');
});
it('parallel form submissions do not throw', async () => {
const formRef = React.createRef();
let resolve = null;
function App() {
async function submitForm() {
Scheduler.log('Action');
if (!resolve) {
await new Promise(res => {
resolve = res;
});
}
}
return <form ref={formRef} action={submitForm} />;
}
const root = ReactDOMClient.createRoot(container);
await act(() => root.render(<App />));
// Start first form submission
await act(async () => {
formRef.current.requestSubmit();
});
assertLog(['Action']);
// Submit form again while first form action is still pending
await act(async () => {
formRef.current.requestSubmit();
resolve(); // Resolve the promise to allow the first form action to complete
});
assertLog(['Action']);
});
it(
'requestFormReset works with inputs that are not descendants ' +
'of the form element',