-
Notifications
You must be signed in to change notification settings - Fork 1
MPDX-9597 UI - Add validation for required salary cap fields in MaxAllowableStep #1785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,25 @@ describe('MaxAllowableSection', () => { | |
| 'Your combined maximum allowable salary exceeds your maximum allowable salary of $125,000.00', | ||
| ); | ||
| }); | ||
|
|
||
| it('shows required errors when split cap fields are empty', async () => { | ||
| const { findByText } = render( | ||
| <TestComponent | ||
| salaryRequestMock={{ | ||
| manuallySplitCap: true, | ||
| salaryCap: null, | ||
| spouseSalaryCap: null, | ||
| }} | ||
| />, | ||
| ); | ||
|
|
||
| expect( | ||
| await findByText('Maximum Allowable Salary is required'), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[Suggestion] Optional: asserting `aria-invalid="true"` on the field alongside the text check would verify the error is wired to the correct input, not just present somewhere in the DOM. Current pattern matches the rest of this file (`warns when cap exceeds hard cap` uses the same getByText style), so no change required.
|
||
| ).toBeInTheDocument(); | ||
| expect( | ||
| await findByText('Spouse Maximum Allowable Salary is required'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('shows message to users with exception cap', async () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,10 +70,12 @@ | |
|
|
||
| return yup.object({ | ||
| salaryCap: amount(t('Maximum Allowable Salary'), t, { | ||
| required: true, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[Suggestion] Required errors display immediately on mount when this section first appears (before the user has interacted), because `useAutoSave` validates synchronously on every render. Consistent with existing behavior - the `max` error works the same way. Correct for this opt-in context (user checked the split-cap checkbox). Flagged for design awareness only. If validate-on-blur is ever desired, that is a `useAutoSave` change, not a change here.
|
||
| max: calculations?.hardCap, | ||
| maxMessage, | ||
| }), | ||
| spouseSalaryCap: amount(t('Spouse Maximum Allowable Salary'), t, { | ||
| required: true, | ||
|
Check warning on line 78 in src/components/HrTools/SalaryCalculator/YourInformation/MaxAllowableSection/MaxAllowableSection.tsx
|
||
| max: calculations?.hardCap, | ||
| maxMessage, | ||
| }), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.