Test: Regression tests for submitting not stuck on Promise<void> onSubmit (#903)#1079
Test: Regression tests for submitting not stuck on Promise<void> onSubmit (#903)#1079
Conversation
📝 WalkthroughWalkthroughTwo regression tests are added to ReactFinalForm.test.js to verify that the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1079 +/- ##
==========================================
- Coverage 98.60% 98.16% -0.45%
==========================================
Files 18 18
Lines 359 381 +22
Branches 105 115 +10
==========================================
+ Hits 354 374 +20
- Misses 5 7 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ReactFinalForm.test.js`:
- Around line 1047-1048: The test currently only asserts the final submitting
state is false; update the assertions around recordSubmitting to also verify
that submitting was true at some point during the submission lifecycle. After
computing calls = recordSubmitting.mock.calls.map((c) => c[0]), add an assertion
using expect(calls).toContain(true) (in addition to the existing
expect(calls[calls.length - 1]).toBe(false)) so the test validates the
transition from true -> false for the submitting state (references:
recordSubmitting, submitting).
| const calls = recordSubmitting.mock.calls.map((c) => c[0]); | ||
| expect(calls[calls.length - 1]).toBe(false); |
There was a problem hiding this comment.
Add assertion to verify submitting was true during submission.
For consistency with the first regression test and to ensure this test validates the complete state transition (not just the final state), add the toContain(true) assertion:
Proposed fix
const calls = recordSubmitting.mock.calls.map((c) => c[0]);
+ expect(calls).toContain(true); // was submitting at some point
expect(calls[calls.length - 1]).toBe(false);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const calls = recordSubmitting.mock.calls.map((c) => c[0]); | |
| expect(calls[calls.length - 1]).toBe(false); | |
| const calls = recordSubmitting.mock.calls.map((c) => c[0]); | |
| expect(calls).toContain(true); // was submitting at some point | |
| expect(calls[calls.length - 1]).toBe(false); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/ReactFinalForm.test.js` around lines 1047 - 1048, The test currently only
asserts the final submitting state is false; update the assertions around
recordSubmitting to also verify that submitting was true at some point during
the submission lifecycle. After computing calls =
recordSubmitting.mock.calls.map((c) => c[0]), add an assertion using
expect(calls).toContain(true) (in addition to the existing
expect(calls[calls.length - 1]).toBe(false)) so the test validates the
transition from true -> false for the submitting state (references:
recordSubmitting, submitting).
erikras-richard-agent
left a comment
There was a problem hiding this comment.
Two clean regression tests for #903. Both variants (async void, Promise.resolve) verify submitting resets to false. codecov failure is just threshold noise on a test-only PR.
CI ✅ (real checks) — Approved.
Summary
Regression tests for #903.
Investigation
The reported bug: when
onSubmitreturnsPromise<void>(async function with no awaits),submittinggets stuck astrue.Finding: The bug is not reproducible in the current implementation. The notification cycle correctly fires after the Promise resolves, setting
submittingback tofalse.Tests Added
async () => {}(no awaits) — confirmssubmittingtransitions true → false() => Promise.resolve()— same verificationAlso see: final-form/final-form#548 (same tests at the core level)
Summary by CodeRabbit