Don’t reformat numbers if there are errors

It’s confusing to at the same time:
1. change what you’ve inputted
2. tell you it’s wrong

This commit makes it so that 1. only happens if 2. doesn’t.
This commit is contained in:
Chris Hill-Scott
2019-02-27 12:05:28 +00:00
parent a24c853dce
commit 61ac7fa069
2 changed files with 42 additions and 5 deletions

View File

@@ -968,6 +968,9 @@ def test_should_error_if_all_volumes_zero(
},
_expected_status=200,
)
assert page.select('input[type=text]')[0]['value'] == ''
assert page.select('input[type=text]')[1]['value'] == '0'
assert page.select('input[type=text]')[2]['value'] == '0,00 0'
assert normalize_spaces(page.select_one('.banner-dangerous').text) == (
'no things supplied '
'Tell us some things'
@@ -975,6 +978,34 @@ def test_should_error_if_all_volumes_zero(
assert mock_update_service.called is False
def test_should_not_default_to_zero_if_some_fields_dont_validate(
client_request,
mock_update_service,
):
page = client_request.post(
'main.estimate_usage',
service_id=SERVICE_ONE_ID,
_data={
'volume_email': '1234',
'volume_sms': '',
'volume_letter': 'aaaaaaaaaaaaa',
'consent_to_research': 'yes',
},
_expected_status=200,
)
assert page.select('input[type=text]')[0]['value'] == '1234'
assert page.select('input[type=text]')[1]['value'] == ''
assert page.select('input[type=text]')[2]['value'] == 'aaaaaaaaaaaaa'
assert normalize_spaces(
page.select_one('label[for=volume_letter]').text
) == (
'How many letters do you expect to send in the next year? '
'For example, 5,000 '
'Must be a whole number'
)
assert mock_update_service.called is False
def test_non_gov_users_cant_request_to_go_live(
client_request,
api_nongov_user_active,