From 9f3cc8baf1b7a9a75c57ca3832df39887d7a05b1 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 30 May 2019 10:56:19 +0100 Subject: [PATCH] =?UTF-8?q?Only=20show=20=E2=80=98back=20to=20service?= =?UTF-8?q?=E2=80=99=20for=20active=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user deletes their service we take them to the ‘Choose service’ page. Like other non-service-specific pages this has a link to the last service you were looking at. But in this specific case the last service you were looking at is the one you’ve just deleted. Which means the link is confusing because: - you thought the thing was ‘gone’ - we’ve secretly renamed it to ‘_archived Example service name’ So this commit hides the link in this specific case. --- app/templates/withoutnav_template.html | 2 +- .../views/accounts/test_choose_accounts.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/templates/withoutnav_template.html b/app/templates/withoutnav_template.html index fa464ce7c..16fc3539d 100644 --- a/app/templates/withoutnav_template.html +++ b/app/templates/withoutnav_template.html @@ -2,7 +2,7 @@ {% block fullwidth_content %}
- {% if current_service and current_user.is_authenticated and current_user.belongs_to_service(current_service.id) %} + {% if current_service and current_service.active and current_user.is_authenticated and current_user.belongs_to_service(current_service.id) %} diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index 6d192b40b..5bc0815e4 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -144,6 +144,25 @@ def test_choose_account_should_not_show_back_to_service_link_if_not_signed_in( assert page.select_one('.navigation-service a') is None +@pytest.mark.parametrize('active', ( + False, + pytest.param(True, marks=pytest.mark.xfail(raises=AssertionError)), +)) +def test_choose_account_should_not_show_back_to_service_link_if_service_archived( + client_request, + service_one, + mock_get_orgs_and_services, + active, +): + service_one['active'] = active + with client_request.session_transaction() as session: + session['service_id'] = service_one['id'] + page = client_request.get('main.choose_account') + + assert normalize_spaces(page.select_one('h1').text) == 'Choose service' + assert page.select_one('.navigation-service a') is None + + @pytest.mark.parametrize('service, expected_status, page_text', ( (service_one, 200, ( 'Test Service Switch service '