From 30eeaec15459a7b1ae5299498cc2abd79f210489 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 16 Jul 2019 09:01:21 +0100 Subject: [PATCH] Add autocomplete to email address on register form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GOV.UK Design System recommends: > You should also set the autocomplete attribute to email. This lets > browsers autofill the email address on a user’s behalf if they’ve > entered it previously. Only doing this on the register and sign in forms because it’s unlikely to be helpful where a user is trying to enter someone else’s email address. --- app/templates/views/register.html | 2 +- app/templates/views/signin.html | 2 +- tests/app/main/views/test_manage_users.py | 10 ++++++++++ tests/app/main/views/test_register.py | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/templates/views/register.html b/app/templates/views/register.html index 04acc1b8b..bd2031e6c 100644 --- a/app/templates/views/register.html +++ b/app/templates/views/register.html @@ -14,7 +14,7 @@ Create an account

Create an account

{% call form_wrapper(autocomplete=True) %} {{ textbox(form.name, width='3-4') }} - {{ textbox(form.email_address, hint="Must be from a government organisation", width='3-4', safe_error_message=True) }} + {{ textbox(form.email_address, hint="Must be from a government organisation", width='3-4', safe_error_message=True, autocomplete='email') }}
{{ textbox(form.mobile_number, width='3-4', hint='We’ll send you a security code by text message') }}
diff --git a/app/templates/views/signin.html b/app/templates/views/signin.html index 3d23afab6..5e3f3b426 100644 --- a/app/templates/views/signin.html +++ b/app/templates/views/signin.html @@ -32,7 +32,7 @@ {% endif %} {% call form_wrapper(autocomplete=True) %} - {{ textbox(form.email_address) }} + {{ textbox(form.email_address, autocomplete='email') }} {{ textbox(form.password) }} {{ page_footer("Continue", secondary_link=url_for('.forgot_password'), secondary_link_text="Forgot your password?") }} {% endcall %} diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 5f3468953..43e97a4ec 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -387,6 +387,16 @@ def test_invite_user_allows_to_choose_auth( assert sms_auth_radio_button.has_attr("disabled") is False +def test_invite_user_has_correct_email_field( + client_request, + mock_get_users_by_service, + mock_get_template_folders, +): + email_field = client_request.get('main.invite_user', service_id=SERVICE_ONE_ID).select_one('#email_address') + assert email_field['spellcheck'] == 'false' + assert 'autocomplete' not in email_field + + def test_should_not_show_page_for_non_team_member( client_request, mock_get_users_by_service, diff --git a/tests/app/main/views/test_register.py b/tests/app/main/views/test_register.py index 1b24f5016..200a75a1b 100644 --- a/tests/app/main/views/test_register.py +++ b/tests/app/main/views/test_register.py @@ -16,6 +16,7 @@ def test_render_register_returns_template_with_form(client): page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') assert page.find('input', attrs={'name': 'auth_type'}).attrs['value'] == 'sms_auth' assert page.select_one('#email_address')['spellcheck'] == 'false' + assert page.select_one('#email_address')['autocomplete'] == 'email' assert 'Create an account' in response.get_data(as_text=True)