mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #1909 from alphagov/request-to-go-live-automation
Add a checklist to the request to go live page
This commit is contained in:
@@ -455,18 +455,76 @@ def test_should_raise_duplicate_name_handled(
|
||||
assert mock_verify_password.called
|
||||
|
||||
|
||||
@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'),
|
||||
])
|
||||
@pytest.mark.parametrize('count_of_email_templates, reply_to_email_addresses, expected_reply_to_checklist_item', [
|
||||
pytest.mark.xfail((0, [], ''), raises=IndexError),
|
||||
pytest.mark.xfail((0, [{}], ''), raises=IndexError),
|
||||
(1, [], 'Not done: You’ve added an email reply to address on the settings page'),
|
||||
(1, [{}], 'Done: You’ve added an email reply to address on the settings page'),
|
||||
])
|
||||
def test_should_show_request_to_go_live_checklist(
|
||||
client_request,
|
||||
mocker,
|
||||
count_of_users_with_manage_service,
|
||||
expected_user_checklist_item,
|
||||
count_of_templates,
|
||||
expected_templates_checklist_item,
|
||||
count_of_email_templates,
|
||||
reply_to_email_addresses,
|
||||
expected_reply_to_checklist_item,
|
||||
):
|
||||
|
||||
def _count_templates(service_id, template_type=None):
|
||||
return {
|
||||
'email': count_of_email_templates
|
||||
}.get(template_type, count_of_templates)
|
||||
|
||||
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',
|
||||
side_effect=_count_templates
|
||||
)
|
||||
mock_get_reply_to_email_addresses = mocker.patch(
|
||||
'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses',
|
||||
return_value=reply_to_email_addresses
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
'main.request_to_go_live', service_id=SERVICE_ONE_ID
|
||||
)
|
||||
assert page.h1.text == 'Request to go live'
|
||||
|
||||
checklist_items = page.select('main ul[class=bottom-gutter] li')
|
||||
|
||||
assert normalize_spaces(checklist_items[0].text) == expected_user_checklist_item
|
||||
assert normalize_spaces(checklist_items[1].text) == expected_templates_checklist_item
|
||||
assert normalize_spaces(checklist_items[2].text) == expected_reply_to_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')
|
||||
assert mock_count_templates.call_args_list == [
|
||||
call(SERVICE_ONE_ID),
|
||||
call(SERVICE_ONE_ID, template_type='email'),
|
||||
]
|
||||
|
||||
if count_of_email_templates:
|
||||
mock_get_reply_to_email_addresses.assert_called_once_with(SERVICE_ONE_ID)
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(
|
||||
client_request,
|
||||
@@ -564,6 +622,7 @@ def test_route_permissions(
|
||||
single_sms_sender,
|
||||
route,
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
):
|
||||
validate_route_permission(
|
||||
mocker,
|
||||
@@ -593,6 +652,7 @@ def test_route_invalid_permissions(
|
||||
api_user_active,
|
||||
service_one,
|
||||
route,
|
||||
mock_get_service_templates,
|
||||
):
|
||||
validate_route_permission(
|
||||
mocker,
|
||||
@@ -624,6 +684,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