Skip to content
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

feat(ChildrenWithAge): add maximum possible value to joint-responsibility & daycare #4219

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 @@ -8,7 +8,7 @@
.dnb-icon {
display: inline-block;

// sine we use vertical-align: top on the SVG
// since we use vertical-align: top on the SVG
// we have to move center the alignment here again
// else basic text afterwards will get aligned on top
vertical-align: middle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function EditContainer({
tr.ChildrenWithAge.dayCareExpenses.required,
}}
minimum={1}
maximum={1000000}
decimalLimit={0}
allowNegative={false}
/>
Expand Down Expand Up @@ -174,6 +175,7 @@ function EditContainer({
tr.ChildrenWithAge.jointResponsibilityExpenses.required,
}}
minimum={1}
maximum={1000000}
decimalLimit={0}
allowNegative={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,55 @@ describe('ChildrenWithAge', () => {
expect(screen.queryByRole('alert')).not.toBeInTheDocument()
})

it('should not accept values over 1000000 as joint-responsibility expense', async () => {
render(
<ChildrenWithAge
enableAdditionalQuestions={['joint-responsibility']}
/>
)

await userEvent.click(document.querySelectorAll('button')[0])
await userEvent.click(document.querySelectorAll('button')[4])
await userEvent.type(document.querySelectorAll('input')[2], '10000001')

const input = document.querySelectorAll('.dnb-input__input')[2]

fireEvent.blur(input)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)
})

it('should not accept values over 1000000 as daycare expense', async () => {
render(<ChildrenWithAge enableAdditionalQuestions={['daycare']} />)

await userEvent.click(document.querySelectorAll('button')[0])
await userEvent.click(document.querySelectorAll('button')[5])
await userEvent.type(document.querySelectorAll('input')[2], '10000001')

const input = document.querySelectorAll('.dnb-input__input')[2]

fireEvent.blur(input)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)

expect(screen.getByRole('alert')).toHaveTextContent(
nbNO['nb-NO'].NumberField.errorMaximum.replace(
'{maximum}',
'1000000'
)
)
})

it('should show summary with Nei when hasChildren changes to false', async () => {
render(
<Form.Handler>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-placeholder="0"
aria-required="true"
class="dnb-input__input"
id="id-rbq"
id="id-rdu"
inputmode="numeric"
name="id-rbq"
name="id-rdu"
type="text"
/>,
},
Expand Down Expand Up @@ -125,9 +125,9 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-placeholder="0"
aria-required="true"
class="dnb-input__input"
id="id-rbv"
id="id-re3"
inputmode="numeric"
name="id-rbv"
name="id-re3"
type="text"
/>,
},
Expand Down Expand Up @@ -331,7 +331,7 @@ exports[`ChildrenWithAge should match snapshot 1`] = `
aria-valuenow="2"
aria-valuetext="2"
class="dnb-input__input"
id="id-rbg"
id="id-rdk"
inputmode="numeric"
name="countChildren"
role="spinbutton"
Expand Down
Loading