From 4e409f7d93f80142775e57288abefe80225a27fe Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Tue, 22 Feb 2022 14:57:49 +0000 Subject: [PATCH] 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. --- .../branding/email-branding-options.html | 5 ++++- tests/app/main/views/test_service_settings.py | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/templates/views/service-settings/branding/email-branding-options.html b/app/templates/views/service-settings/branding/email-branding-options.html index 7e9d7edc1..7354e448d 100644 --- a/app/templates/views/service-settings/branding/email-branding-options.html +++ b/app/templates/views/service-settings/branding/email-branding-options.html @@ -25,9 +25,12 @@ Your emails currently have {{ branding_name }} branding.

+ {% set branding_id = current_service.email_branding_id if current_service.email_branding else '__NONE__' %} + + {% if current_service.needs_to_change_email_branding %}

- You should be using your own branding instead. We can help you to set this up. + You should be using your own branding instead.

{% endif %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index d9c302b82..1ead2e1f4 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -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'],