diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html
index 1812c424b..a6d907a23 100644
--- a/app/templates/views/templates/_template.html
+++ b/app/templates/views/templates/_template.html
@@ -49,7 +49,11 @@
{% endif %}
Change
Edit
- Edit
+ {% if current_service.count_letter_contact_details %}
+ Edit
+ {% else %}
+ Edit
+ {% endif %}
{% endif %}
{{ template|string }}
diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py
index a87863940..c1ad1bbca 100644
--- a/tests/app/main/views/test_templates.py
+++ b/tests/app/main/views/test_templates.py
@@ -27,6 +27,7 @@ from tests.conftest import (
ElementNotFound,
active_caseworking_user,
active_user_view_permissions,
+ fake_uuid,
mock_get_service_email_template,
mock_get_service_letter_template,
mock_get_service_template,
@@ -687,17 +688,26 @@ def test_should_show_sms_template_with_downgraded_unicode_characters(
assert rendered_msg in page.text
+@pytest.mark.parametrize('mock_contact_block, expected_partial_url', (
+ (no_letter_contact_blocks, partial(
+ url_for, 'main.service_add_letter_contact', from_template=fake_uuid(),
+ )),
+ (single_letter_contact_block, partial(
+ url_for, 'main.set_template_sender', template_id=fake_uuid(),
+ )),
+))
def test_should_let_letter_contact_block_be_changed_for_the_template(
mocker,
mock_get_service_letter_template,
mock_get_template_folders,
- no_letter_contact_blocks,
client_request,
service_one,
fake_uuid,
+ mock_contact_block,
+ expected_partial_url
):
- service_one['permissions'].append('letter')
mocker.patch('app.main.views.templates.get_page_count_for_letter', return_value=1)
+ mock_contact_block(mocker)
page = client_request.get(
'main.view_template',
@@ -706,11 +716,9 @@ def test_should_let_letter_contact_block_be_changed_for_the_template(
_test_page_title=False,
)
- assert page.find('a', {'class': 'edit-template-link-letter-contact'})['href'] == url_for(
- 'main.set_template_sender',
- service_id=SERVICE_ONE_ID,
- template_id=fake_uuid,
- )
+ assert page.select_one(
+ 'a.edit-template-link-letter-contact'
+ )['href'] == expected_partial_url(service_id=SERVICE_ONE_ID)
def test_should_show_page_template_with_priority_select_if_platform_admin(