Add ‘no templates’ message for broadcast services

This shouldn’t talk about emails, text messages or letters.
This commit is contained in:
Chris Hill-Scott
2020-07-14 14:52:52 +01:00
parent 41624295c9
commit 008e4befb4
2 changed files with 36 additions and 7 deletions

View File

@@ -24,14 +24,19 @@
<p class="govuk-body">
{% if current_user.has_permissions('manage_templates') %}
You need a template before you can send
You need a template before you can
{% else %}
You need to ask your service manager to add templates before you can send
You need to ask your service manager to add templates before you can
{% endif %}
{% if 'letter' in current_service.permissions %}
emails, text messages or letters
{%- else -%}
emails or text messages
{% if current_service.has_permission('broadcast') %}
prepare a broadcast
{%- else %}
send
{% if 'letter' in current_service.permissions %}
emails, text messages or letters
{%- else -%}
emails or text messages
{%- endif %}
{%- endif %}.
</p>

View File

@@ -27,13 +27,37 @@ from tests.conftest import (
)
@pytest.mark.parametrize('permissions, expected_message', (
(['email'], (
'You need a template before you can send emails or text messages.'
)),
(['sms'], (
'You need a template before you can send emails or text messages.'
)),
(['letter'], (
'You need a template before you can send emails, text messages or letters.'
)),
(['sms', 'letter'], (
'You need a template before you can send emails, text messages or letters.'
)),
(['email', 'sms', 'letter'], (
'You need a template before you can send emails, text messages or letters.'
)),
(['broadcast'], (
'You need a template before you can prepare a broadcast.'
)),
))
def test_should_show_empty_page_when_no_templates(
client_request,
service_one,
mock_get_service_templates_when_no_templates_exist,
mock_get_template_folders,
permissions,
expected_message,
):
service_one['permissions'] = permissions
page = client_request.get(
'main.choose_template',
service_id=service_one['id'],
@@ -43,7 +67,7 @@ def test_should_show_empty_page_when_no_templates(
'Templates'
)
assert normalize_spaces(page.select_one('main p').text) == (
'You need a template before you can send emails or text messages.'
expected_message
)
assert page.select_one('#add_new_folder_form')
assert page.select_one('#add_new_template_form')