Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[Suggestion] Optional: consider a test for the partial-empty state (one field filled, one null) to confirm only the empty field shows the required error. Not blocking - useAutoSave handles fields independently and the existing tests cover the fully-filled happy path.

const { findByText } = render(
<TestComponent
salaryRequestMock={{
manuallySplitCap: true,
salaryCap: null,
spouseSalaryCap: null,
}}
/>,
);

expect(
await findByText('Maximum Allowable Salary is required'),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@

return yup.object({
salaryCap: amount(t('Maximum Allowable Salary'), t, {
required: true,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (main)

❌ Getting worse: Complex Method

MaxAllowableStep:React.FC already has high cyclomatic complexity, and now it increases in Lines of Code from 183 to 185. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
max: calculations?.hardCap,
maxMessage,
}),
Expand Down
Loading