-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[open-formulieren/open-forms#5006] Updated addressNL component to man…
…ually fill in city and streetname Until now the addressNL component would retrieve the city and street name based on the postcode and housenumber. These fields were always read-only but now we want to be able to fill in city and street name if something goes wrong with the API call.
- Loading branch information
Showing
9 changed files
with
327 additions
and
122 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import {screen} from '@testing-library/dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
import {renderForm} from 'jstests/formio/utils'; | ||
|
||
const addressNLForm = { | ||
type: 'form', | ||
components: [ | ||
{ | ||
key: 'addressnl', | ||
type: 'addressNL', | ||
label: 'Address NL', | ||
validate: { | ||
required: true, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
describe('The addressNL component', () => { | ||
afterEach(() => { | ||
document.body.innerHTML = ''; | ||
}); | ||
test('Postcode provided and missing housenumber', async () => { | ||
const user = userEvent.setup({delay: 50}); | ||
await renderForm(addressNLForm, { | ||
evalContext: { | ||
requiredFieldsWithAsterisk: true, | ||
}, | ||
}); | ||
const postcode = screen.getByLabelText('Postcode'); | ||
const houseNumber = screen.getByLabelText('House number'); | ||
|
||
await user.type(postcode, '1017 CJ'); | ||
|
||
expect(houseNumber).toHaveClass('utrecht-textbox--invalid'); | ||
expect(houseNumber).toHaveAttribute('aria-describedby'); | ||
expect(houseNumber).toHaveAttribute('aria-invalid'); | ||
}); | ||
test('Postcode missing and housenumber provided', async () => { | ||
const user = userEvent.setup({delay: 50}); | ||
await renderForm(addressNLForm, { | ||
evalContext: { | ||
requiredFieldsWithAsterisk: true, | ||
}, | ||
}); | ||
const postcode = screen.getByLabelText('Postcode'); | ||
const houseNumber = screen.getByLabelText('House number'); | ||
|
||
await user.type(houseNumber, '22'); | ||
|
||
expect(postcode).toHaveClass('utrecht-textbox--invalid'); | ||
expect(postcode).toHaveAttribute('aria-describedby'); | ||
expect(postcode).toHaveAttribute('aria-invalid'); | ||
}); | ||
}); |
Oops, something went wrong.