Let platform admin users use a contact list

Platform admin users now have a link to upload a contact list. This
commit gives them access to the page where they can use this.

Once this commit is merged we have a way of testing the whole flow end
to end, without giving it to all users yet.
This commit is contained in:
Chris Hill-Scott
2020-03-15 15:54:49 +00:00
parent f76a9e787a
commit ec2f36d054
2 changed files with 58 additions and 0 deletions

View File

@@ -33,6 +33,9 @@
<div class="govuk-grid-column-full">
{% if link_to_upload %}
<a class="govuk-link govuk-link--no-visited-state govuk-!-margin-right-3" href="{{ url_for('.send_messages', service_id=current_service.id, template_id=template.id) }}">Upload a list of {{ recipient_count_label(999, template.template_type) }}</a>
{% if current_user.platform_admin %}
<a class="govuk-link govuk-link--no-visited-state govuk-!-margin-right-3" href="{{ url_for('.choose_from_contact_list', service_id=current_service.id, template_id=template.id) }}">Use a saved list</a>
{% endif %}
{% endif %}
{% if skip_link %}
<a href="{{ skip_link[1] }}" class="govuk-link govuk-link--no-visited-state govuk-!-margin-right-3">{{ skip_link[0] }}</a>

View File

@@ -38,6 +38,7 @@ from tests.conftest import (
create_active_user_with_permissions,
create_multiple_email_reply_to_addresses,
create_multiple_sms_senders,
create_platform_admin_user,
create_template,
mock_get_service_email_template,
mock_get_service_letter_template,
@@ -1410,6 +1411,60 @@ def test_send_one_off_offers_link_to_upload(
)
@pytest.mark.parametrize('user', (
pytest.param(
create_platform_admin_user(),
),
pytest.param(
create_active_user_with_permissions(),
marks=pytest.mark.xfail(raises=AssertionError),
),
))
def test_platform_admin_has_link_to_use_existing_list(
client_request,
mock_get_service_template,
mock_has_jobs,
fake_uuid,
user,
):
client_request.login(user)
page = client_request.get(
'main.send_one_off',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
_follow_redirects=True,
)
assert [
(link.text, link['href']) for link in page.select('form a')
] == [
(
'Upload a list of phone numbers',
url_for(
'main.send_messages',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
),
),
(
'Use a saved list',
url_for(
'main.choose_from_contact_list',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
),
),
(
'Use my phone number',
url_for(
'main.send_test',
service_id=SERVICE_ONE_ID,
template_id=fake_uuid,
),
),
]
@pytest.mark.parametrize('user', (
create_active_user_with_permissions(),
create_active_caseworking_user(),