Use folder buttons in empty state

It’s confusing to have one way of adding things when your service is new
(green button) but a different way once you’ve added your first thing
(the new grey buttons).

For services that have a `edit_folders` permission, this commit
standardises on the grey buttons for a consistent experience.
This commit is contained in:
Chris Hill-Scott
2019-01-03 10:43:57 +00:00
parent bbaa51443a
commit aaf3322662
3 changed files with 36 additions and 11 deletions

View File

@@ -35,21 +35,14 @@ from tests.conftest import service_one as create_sample_service
from tests.conftest import single_letter_contact_block
@pytest.mark.parametrize('extra_permissions', (
[],
['edit_folders'],
))
def test_should_show_empty_page_when_no_templates(
client_request,
service_one,
mock_get_organisations_and_services_for_user,
mock_get_service_templates_when_no_templates_exist,
mock_get_template_folders,
extra_permissions,
):
service_one['permissions'] += extra_permissions
page = client_request.get(
'main.choose_template',
service_id=service_one['id'],
@@ -68,6 +61,36 @@ def test_should_show_empty_page_when_no_templates(
assert len(page.select('main a')) == 1
def test_should_show_add_template_form_if_service_has_folder_permission(
client_request,
service_one,
mock_get_organisations_and_services_for_user,
mock_get_service_templates_when_no_templates_exist,
mock_get_template_folders,
):
service_one['permissions'] += ['edit_folders']
page = client_request.get(
'main.choose_template',
service_id=service_one['id'],
)
assert normalize_spaces(page.select_one('h1').text) == (
'Templates'
)
assert normalize_spaces(page.select_one('main p').text) == (
'You need a template before you can send emails or text messages.'
)
assert [
(item['name'], item['value']) for item in page.select('[type=radio]')
] == [
('add_template_by_template_type', 'email'),
('add_template_by_template_type', 'sms'),
]
assert not page.select('main a')
@pytest.mark.parametrize(
'user, expected_page_title, extra_args, expected_nav_links, expected_templates',
[