From b822914e23f977c2e13aefec897e426617c1f1e0 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 6 Jan 2020 10:55:47 +0000 Subject: [PATCH 1/2] Send asset path to Header component The SVG fallback image for the GOV.UK logo starts its path as '/assets/images' by default unless you send in an alternative root. This sends in our static asset host root to stop the image 404'ing on browsers that load it. --- app/templates/admin_template.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index feefab8da..896dc6efd 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -125,7 +125,8 @@ "homepageUrl": url_for('main.show_accounts_or_dashboard'), "productName": "Notify", "navigation": navigation, - "navigationClasses": "govuk-header__navigation--end" + "navigationClasses": "govuk-header__navigation--end", + "assetsPath": asset_path + "images" }) }} {% endblock %} From 6726ad31b9b13e59197507e0416f8ceeca5caa04 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 6 Jan 2020 11:40:12 +0000 Subject: [PATCH 2/2] Add test for SVG fallback image path It's the only resource that uses the `asset_path` template variable in `template.njk` so this checks that works as expected. From feedback on the associated pull request: https://github.com/alphagov/notifications-admin/pull/3241#issuecomment-571102394 --- tests/app/main/views/test_index.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 2e652200b..d5c744c0e 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -177,6 +177,15 @@ def test_css_is_served_from_correct_path(client_request): ][index]) +def test_resources_that_use_asset_path_variable_have_correct_path(client_request): + + page = client_request.get('main.documentation') # easy static page + + logo_svg_fallback = page.select_one('.govuk-header__logotype-crown-fallback-image') + + assert logo_svg_fallback['src'].startswith('https://static.example.com/images/govuk-logotype-crown.png') + + @pytest.mark.parametrize('extra_args, email_branding_retrieved', ( ( {},