From 7be08e2f741ade2d147a73b129fee85da5a5cbe5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 27 Feb 2018 12:07:50 +0000 Subject: [PATCH] Check for templates before going live We need users to have created some templates before they go live, so we can see what kind of messages they intend to send. We can do this automatically based on the work done in https://github.com/alphagov/notifications-admin/pull/1892 --- app/main/views/service_settings.py | 3 +++ .../service-settings/request-to-go-live.html | 6 ++++- tests/app/main/views/test_service_settings.py | 25 ++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index fcc845654..60e6f1529 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -169,6 +169,9 @@ def request_to_go_live(service_id): service_id, 'manage_settings' ) > 1 ), + has_templates=( + service_api_client.count_service_templates(service_id) > 0 + ), ) diff --git a/app/templates/views/service-settings/request-to-go-live.html b/app/templates/views/service-settings/request-to-go-live.html index 65b1b6ac8..0670015cd 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -22,6 +22,10 @@ has_team_members, 'Another person in your team has the ‘Manage service’ permission', ) }} + {{ tick_cross_done_not_done( + has_templates, + 'You’ve added some templates', + ) }}

You also need to: @@ -35,7 +39,7 @@ settings page

  • - add the templates you want to start with, making sure they follow the GOV.UK Service Manual standards for + make sure your messages follow the GOV.UK Service Manual standards for writing text messages and emails
  • diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index ee0e80387..e1730de70 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -455,30 +455,46 @@ def test_should_raise_duplicate_name_handled( assert mock_verify_password.called -@pytest.mark.parametrize('count_of_users_with_manage_service, expected_checklist_item', [ +@pytest.mark.parametrize('count_of_users_with_manage_service, expected_user_checklist_item', [ (1, 'Not done: Another person in your team has the ‘Manage service’ permission'), (2, 'Done: Another person in your team has the ‘Manage service’ permission'), ]) +@pytest.mark.parametrize('count_of_templates, expected_templates_checklist_item', [ + (0, 'Not done: You’ve added some templates'), + (1, 'Done: You’ve added some templates'), + (2, 'Done: You’ve added some templates'), +]) def test_should_show_request_to_go_live_checklist( client_request, mocker, count_of_users_with_manage_service, - expected_checklist_item, + expected_user_checklist_item, + count_of_templates, + expected_templates_checklist_item, ): mock_count_users = mocker.patch( 'app.main.views.service_settings.user_api_client.get_count_of_users_with_permission', return_value=count_of_users_with_manage_service ) + mock_count_templates = mocker.patch( + 'app.main.views.service_settings.service_api_client.count_service_templates', + return_value=count_of_templates + ) + page = client_request.get( 'main.request_to_go_live', service_id=SERVICE_ONE_ID ) assert page.h1.text == 'Request to go live' - assert normalize_spaces(page.select('main ul li')[0].text) == expected_checklist_item + + assert normalize_spaces(page.select('main ul li')[0].text) == expected_user_checklist_item + assert normalize_spaces(page.select('main ul li')[1].text) == expected_templates_checklist_item + assert page.select_one('main .button')['href'] == url_for( 'main.submit_request_to_go_live', service_id=SERVICE_ONE_ID, ) mock_count_users.assert_called_once_with(SERVICE_ONE_ID, 'manage_settings') + mock_count_templates.assert_called_once_with(SERVICE_ONE_ID) def test_should_show_request_to_go_live( @@ -577,6 +593,7 @@ def test_route_permissions( single_sms_sender, route, mock_get_service_settings_page_common, + mock_get_service_templates, ): validate_route_permission( mocker, @@ -606,6 +623,7 @@ def test_route_invalid_permissions( api_user_active, service_one, route, + mock_get_service_templates, ): validate_route_permission( mocker, @@ -637,6 +655,7 @@ def test_route_for_platform_admin( single_sms_sender, route, mock_get_service_settings_page_common, + mock_get_service_templates, ): validate_route_permission(mocker, app_,