Show letter branding preview when selecting a brand

This adds a preview pane which is visible when updating a letter brand.

If JavaScript is enabled, the preview pane shows on the set-letter-branding
page, and submitting the form saves updates the letter brand for a service
immediately. If Javascript is not enabled, there is a separate 'Preview email
branding' page which shows a preview of the brand and has a 'Save' button on it.
This commit is contained in:
Katie Smith
2019-02-15 14:47:39 +00:00
parent 44781e3b69
commit d904c7e5c5
12 changed files with 297 additions and 11 deletions

View File

@@ -798,6 +798,28 @@ def test_dont_show_preview_letter_templates_for_bad_filetype(
assert mock_get_service_template.called is False
@pytest.mark.parametrize('original_filename, new_filename', [
('geo', 'geo'),
('no-branding', None)
])
def test_letter_branding_preview_image(
mocker,
logged_in_platform_admin_client,
original_filename,
new_filename,
):
mocked_preview = mocker.patch(
'app.main.views.templates.TemplatePreview.from_example_template',
return_value='foo'
)
resp = logged_in_platform_admin_client.get(
url_for('.letter_branding_preview_image', filename=original_filename)
)
mocked_preview.assert_called_with(ANY, new_filename)
assert resp.get_data(as_text=True) == 'foo'
def test_choosing_to_copy_redirects(
client_request,
service_one,