test(form): run money forced values through every engine and strategy - #1432
Closed
gabrielseco wants to merge 11 commits into
Closed
gabrielseco wants to merge 11 commits into
gabrielseco wants to merge 11 commits into
Conversation
Portugal's extended work hours allowance is a forced money value computed from the salary. Onboarding built its render-time form without converting money fields to cents, so the allowance was computed from the salary in major units (100x too small), and the forced value was then written into the form state in cents while the form keeps money in major units. Validation recomputed the correct value and rejected the submission on a field with no input to show the error, blocking the step. - Onboarding's useJSONSchemaForm passes transformMoneyFields: true, since createHeadlessForm only defaults it on when no options are passed. - Forced money values are converted from cents before being set in the form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Default transformMoneyFields to true whenever it's not explicitly set, instead of only when the whole options object is missing. Callers that pass options without transformMoneyFields (e.g. only jsfModify) now get money fields converted to cents too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tails path The flow regression test only covers the legacy path while PRT is outside JSF_V1_CONTRACT_DETAILS_COUNTRIES. These test the Onboarding useJSONSchemaForm hook and JSONSchemaFormFields directly, so they keep covering the fix whichever countries are on v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Submitting a forced value already uses the field's `const` in cents (parseFormValuesToAPI overwrites the form value with it), and the default forced value component doesn't render `value`. The `transformMoneyFields` change alone fixes the PRT allowance; getForcedValue would only change what custom forcedValue components receive in `fieldData.value`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct submission of forced money values relies on parseFormValuesToAPI overwriting the form value with the field's const. Covers a top-level field and one nested in a fieldset; both fail with 100x the amount without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
createHeadlessForm now defaults transformMoneyFields per key (#1426), so the explicit override in useJSONSchemaForm is redundant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs the Portugal contract details schema through each combination of kit engine (jsf v0, jsf v1, no meta) and SDK form strategy (rebuild without options, rebuild with jsfModify, build once + handleValidation), and asserts the same money rules in every cell: computed forced values and their text in cents, forced non-money values untouched, dependent recomputation, visibility on submit, money minimum validation. With the #1195 default restored, the 11 rebuild-with-jsfModify cases fail on all three engines; every other cell passes either way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (75 total)
✅ Bundle size check passed |
…verted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
Contributor
📊 Coverage Report✅ Coverage increased! 🎉
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds one test suite that checks money amounts are handled in cents for every combination of form engine and form setup the SDK uses. It fails on the Portugal allowance regression from #1195, which none of the existing tests caught.
Why
handleValidation.What changed
Toggle details
src/common/tests/moneyEngineContract.test.ts. It uses the existing Portugal contract details fixture with itsx-rmt-metareplaced per engine: 3 engines × 3 strategies × 10 cases = 90 tests.createHeadlessForm(schema, values, options)on each render, andhandleValidationonly on validate or submit.createHeadlessForm(schema, {}, { transformMoneyFields: false }), thenhandleValidationon every change, the waycheckFieldUpdatesdoes it.ForcedValueFielddoes.handleValidationon every rebuild render. That recomputed theconstfrom cents and hid the regression. Rendering and validating have to be separate steps, or the suite passes on broken code.signing_bonus_amount); forced acknowledgement strings submitted as their const.createHeadlessFormrestored to feat(playground) - fix france arch problems only on playground #1195'soptions || { transformMoneyFields: true }, 11 tests fail, all in therebuild with jsfModifycolumn and on all three engines. The other columns pass either way. That's expected, since they aren't affected by the trap.it.eachover a rebuild country and a build-once country.x-rmt-metaand with a 1288000 minimum, while the fixture pins v0 and 1218000.Screenshots
N/A
Related Resources
Testing
createHeadlessFormis reverted to feat(playground) - fix france arch problems only on playground #1195's default🤖 Generated with Claude Code