Skip to content

Test: Regression tests for submitting not stuck on Promise<void> onSubmit (#903)#1079

Merged
erikras merged 1 commit intomainfrom
fix-903-submitting-stuck
Feb 17, 2026
Merged

Test: Regression tests for submitting not stuck on Promise<void> onSubmit (#903)#1079
erikras merged 1 commit intomainfrom
fix-903-submitting-stuck

Conversation

@erikras-gilfoyle-agent
Copy link
Copy Markdown
Contributor

@erikras-gilfoyle-agent erikras-gilfoyle-agent commented Feb 17, 2026

Summary

Regression tests for #903.

Investigation

The reported bug: when onSubmit returns Promise<void> (async function with no awaits), submitting gets stuck as true.

Finding: The bug is not reproducible in the current implementation. The notification cycle correctly fires after the Promise resolves, setting submitting back to false.

Tests Added

  1. async () => {} (no awaits) — confirms submitting transitions true → false
  2. () => Promise.resolve() — same verification

Also see: final-form/final-form#548 (same tests at the core level)

Summary by CodeRabbit

  • Tests
    • Added regression tests to verify that the form submission state correctly resets after asynchronous submission completion in multiple scenarios.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

Two regression tests are added to ReactFinalForm.test.js to verify that the submitting state resets to false after asynchronous onSubmit completion. Both tests render a form, trigger submission, and assert the state transitions via different async patterns.

Changes

Cohort / File(s) Summary
Regression Tests for Async Submission State
src/ReactFinalForm.test.js
Adds two regression tests verifying submitting state resets to false after async onSubmit completes. Test 1 uses an async function with no awaits; Test 2 returns Promise.resolve(). Both record state transitions and assert final state is false after microtask resolution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 When forms go async in the night,
The submitting state sets things right,
From true it goes to false so neat,
These tests keep quality complete! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding regression tests for a specific bug fix related to the submitting state issue with Promise onSubmit handlers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-903-submitting-stuck

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.16%. Comparing base (f25a24e) to head (17f6041).
⚠️ Report is 10 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment on lines +1047 to +1048
const calls = recordSubmitting.mock.calls.map((c) => c[0]);
expect(calls[calls.length - 1]).toBe(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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).

Copy link
Copy Markdown
Contributor

@erikras-richard-agent erikras-richard-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@erikras erikras merged commit f3803b0 into main Feb 17, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants