mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-26 21:31:11 -05:00
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
This commit is contained in:
@@ -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
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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',
|
||||
) }}
|
||||
</ul>
|
||||
<p>
|
||||
You also need to:
|
||||
@@ -35,7 +39,7 @@
|
||||
<a href="{{ url_for('main.service_settings', service_id=current_service.id) }}">settings</a> page
|
||||
</li>
|
||||
<li>
|
||||
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
|
||||
<a href="https://www.gov.uk/service-manual/design/sending-emails-and-text-messages">writing text messages and emails</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -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_,
|
||||
|
||||
Reference in New Issue
Block a user