Show preview of current branding

This adds a preview of the current branding to users on the page where
they can select which new branding they want. Also includes a tiny
content change to match the new content doc for this story.
This commit is contained in:
Katie Smith
2022-02-22 14:57:49 +00:00
parent 77e1c015c4
commit 4e409f7d93
2 changed files with 18 additions and 2 deletions

View File

@@ -25,9 +25,12 @@
Your emails currently have {{ branding_name }} branding.
</p>
{% set branding_id = current_service.email_branding_id if current_service.email_branding else '__NONE__' %}
<iframe src="{{ url_for('main.email_template', branding_style=branding_id) }}" class="branding-preview"></iframe>
{% if current_service.needs_to_change_email_branding %}
<p class="govuk-body">
You should be using your own branding instead. We can help you to set this up.
You should be using your own branding instead.
</p>
{% endif %}

View File

@@ -4772,6 +4772,7 @@ def test_update_service_organisation_does_not_update_if_same_value(
def test_show_email_branding_request_page_when_no_branding_is_set(
service_one,
client_request,
mocker,
mock_get_email_branding,
mock_get_letter_branding_by_id,
organisation_type,
@@ -4780,11 +4781,18 @@ def test_show_email_branding_request_page_when_no_branding_is_set(
service_one['email_branding'] = None
service_one['organisation_type'] = organisation_type
mocker.patch(
'app.models.service.Service.email_branding_id',
new_callable=PropertyMock,
return_value=None,
)
page = client_request.get(
'.email_branding_request', service_id=SERVICE_ONE_ID
)
assert mock_get_email_branding.called is False
assert page.find('iframe')['src'] == url_for('main.email_template', branding_style='__NONE__')
assert mock_get_letter_branding_by_id.called is False
button_text = normalize_spaces(page.select_one('.page-footer button').text)
@@ -4984,17 +4992,22 @@ def test_show_email_branding_request_page_when_email_branding_is_set(
client_request,
mock_get_email_branding,
mock_get_service_organisation,
active_user_with_permissions,
):
service_one['email_branding'] = sample_uuid()
mocker.patch(
'app.organisations_client.get_organisation',
return_value=organisation_json(),
)
mocker.patch(
'app.models.service.Service.email_branding_id',
new_callable=PropertyMock,
return_value='1234-abcd',
)
page = client_request.get(
'.email_branding_request', service_id=SERVICE_ONE_ID
)
assert page.find('iframe')['src'] == url_for('main.email_template', branding_style='1234-abcd')
assert [
(
radio['value'],