Bump WTForms to 2.3.1

This involves three changes which broke our code.

To validate email addresses, the optional dependency `email-validator`
must be installed<sup>1</sup>. But since we don’t use WTForms’ email
validation, we shouldn’t need to subclass it – it can just be its own
self contained thing. Then we don’t need to add the extra dependency.

When rendering textareas, and extra `\r\n` is inserted at the beginning
<sup>2</sup>. Browsers will strip this when displaying the textbox and
submitting the form, but some of our tests need updating to account for
this.

The error message for when you don’t choose an option from some radio
buttons has now changed. Rather than just accepting WTForms’ new
message, this commit makes the error messages like the examples from
the Design System<sup>3</sup>. By default it will say ‘Select an
option’, but by passing in an extra parameter (`thing`) it can be
customised to be more specific, for example ‘Select a type of
organisation’.

***

1. https://github.com/wtforms/wtforms/pull/429
2. https://github.com/wtforms/wtforms/issues/238
3. https://design-system.service.gov.uk/components/radios/#error-messages
This commit is contained in:
Chris Hill-Scott
2020-04-22 17:49:03 +01:00
parent bc4f2166cd
commit 65bb72ef2f
14 changed files with 62 additions and 53 deletions

View File

@@ -1377,7 +1377,7 @@ def test_should_show_persist_estimated_volumes(
'consent_to_research': '',
},
'[data-error-label="consent_to_research"]',
'This field is required.'
'Select yes or no'
),
))
def test_should_error_if_bad_estimations_given(
@@ -4109,7 +4109,7 @@ def test_send_files_by_email_contact_details_displays_error_message_when_no_radi
},
_follow_redirects=True
)
assert normalize_spaces(page.find('span', class_='error-message').text) == 'Not a valid choice'
assert normalize_spaces(page.find('span', class_='error-message').text) == 'Select an option'
assert normalize_spaces(page.h1.text) == "Send files by email"