mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #4098 from alphagov/form-bug-fixes
Fix two small bugs with forms
This commit is contained in:
@@ -2361,6 +2361,27 @@ def test_incorrect_sms_sender_input(
|
||||
assert count_of_api_calls == 0
|
||||
|
||||
|
||||
def test_incorrect_sms_sender_input_with_multiple_errors_only_shows_the_first(
|
||||
client_request,
|
||||
no_sms_senders,
|
||||
mock_add_sms_sender,
|
||||
):
|
||||
# There are two errors with the SMS sender - the length and characters used. Only one
|
||||
# should be displayed on the page.
|
||||
page = client_request.post(
|
||||
'main.service_add_sms_sender',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_data={'sms_sender': '{}'},
|
||||
_expected_status=200
|
||||
)
|
||||
|
||||
error_message = page.select_one('.govuk-error-message')
|
||||
count_of_api_calls = len(mock_add_sms_sender.call_args_list)
|
||||
|
||||
assert normalize_spaces(error_message.text) == 'Error: Enter 3 characters or more'
|
||||
assert count_of_api_calls == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('reply_to_addresses, data, api_default_args', [
|
||||
([], {}, True),
|
||||
(create_multiple_email_reply_to_addresses(), {}, False),
|
||||
|
||||
@@ -74,7 +74,6 @@ def test_should_show_name_page(
|
||||
def test_should_redirect_after_name_change(
|
||||
client_request,
|
||||
mock_update_user_attribute,
|
||||
mock_email_is_not_already_in_use
|
||||
):
|
||||
client_request.post(
|
||||
'main.user_profile_name',
|
||||
@@ -109,6 +108,30 @@ def test_should_redirect_after_email_change(
|
||||
)
|
||||
)
|
||||
|
||||
assert mock_email_is_not_already_in_use.called
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address,error_message', [
|
||||
('me@example.com', 'Enter a public sector email address or find out who can use Notify'),
|
||||
('not_valid', 'Enter a valid email address') # 2 errors with email address, only first error shown
|
||||
])
|
||||
def test_should_show_errors_if_new_email_address_does_not_validate(
|
||||
client_request,
|
||||
mock_email_is_not_already_in_use,
|
||||
mock_get_organisations,
|
||||
email_address,
|
||||
error_message,
|
||||
):
|
||||
page = client_request.post(
|
||||
'main.user_profile_email',
|
||||
_data={'email_address': email_address},
|
||||
_expected_status=200,
|
||||
)
|
||||
|
||||
assert normalize_spaces(page.find('span', class_='govuk-error-message').text) == f'Error: {error_message}'
|
||||
# We only call API to check if the email address is already in use if there are no other errors
|
||||
assert not mock_email_is_not_already_in_use.called
|
||||
|
||||
|
||||
def test_should_show_authenticate_after_email_change(
|
||||
client_request,
|
||||
|
||||
Reference in New Issue
Block a user