mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Offer link to upload
‘Upload recipients’ and ‘Send to one recipient’ have always been slightly clunky phrases. Now that basic view jumps straight into the ‘Send to one recipient’ flow there’s no way for users to get to the ‘Upload recipients’ flow. By adding a link to it from the ‘Send to one recipient’ flow it’s possible for users of basic view to access it. But we don’t want to introduce too much inconsistency between basic view and admin view because users will be migrating from one to another. They might also be talking to their manager, who wouldn’t be able to tell them where to click if they were looking at two completely different interfaces. This also means that we can keep the left-hand navigation in basic view nice and simple with the two options (‘Templates’ and ‘Sent messages’), rather than trying to introduce something like ‘Send one message’ and ‘Send lots of messages’ later on.
This commit is contained in:
@@ -1191,6 +1191,101 @@ def test_skip_link_will_not_show_on_sms_one_off_if_service_has_no_mobile_number(
|
||||
assert not skip_links
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user, link_index', (
|
||||
(active_user_with_permissions, 1),
|
||||
(active_caseworking_user, 0),
|
||||
))
|
||||
def test_send_one_off_offers_link_to_upload(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_template,
|
||||
mock_has_jobs,
|
||||
user,
|
||||
link_index,
|
||||
):
|
||||
client_request.login(user(fake_uuid))
|
||||
|
||||
page = client_request.get(
|
||||
'main.send_one_off',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
link = page.select('main a')[link_index]
|
||||
|
||||
assert link.text.strip() == 'Upload a list of phone numbers'
|
||||
assert link['href'] == url_for(
|
||||
'main.send_messages',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
active_user_with_permissions,
|
||||
active_caseworking_user,
|
||||
))
|
||||
def test_link_to_upload_not_offered_in_tour(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_template,
|
||||
user,
|
||||
):
|
||||
client_request.login(user(fake_uuid))
|
||||
|
||||
page = client_request.get(
|
||||
'main.send_test',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
help=1,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
# We’re in the tour…
|
||||
assert page.select('.banner-tour')
|
||||
# …but first link on the page is ‘Back’, so not preceeded by ‘Upload’
|
||||
assert page.select_one('main a').text == 'Back'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
active_user_with_permissions,
|
||||
active_caseworking_user,
|
||||
))
|
||||
@pytest.mark.parametrize('endpoint, step_index', (
|
||||
('main.send_one_off_step', 1),
|
||||
('main.send_test_step', 0),
|
||||
))
|
||||
def test_link_to_upload_not_offered_when_entering_personalisation(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_service_template_with_placeholders,
|
||||
mock_has_jobs,
|
||||
user,
|
||||
endpoint,
|
||||
step_index,
|
||||
):
|
||||
client_request.login(user(fake_uuid))
|
||||
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = '07900900900'
|
||||
session['placeholders'] = {'phone number': '07900900900'}
|
||||
|
||||
page = client_request.get(
|
||||
endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
step_index=step_index,
|
||||
)
|
||||
|
||||
# We’re entering personalisation
|
||||
assert page.select_one('input[type=text]')['name'] == 'placeholder_value'
|
||||
assert page.select_one('label[for=placeholder_value]').text.strip() == 'name'
|
||||
# …but first link on the page is ‘Back’, so not preceeded by ‘Upload’
|
||||
assert page.select_one('main a').text == 'Back'
|
||||
assert 'Upload' not in page.select_one('main').text
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
active_user_with_permissions,
|
||||
active_caseworking_user,
|
||||
@@ -1208,9 +1303,8 @@ def test_skip_link_will_not_show_on_sms_one_off_if_service_has_no_mobile_number(
|
||||
),
|
||||
])
|
||||
def test_send_test_redirects_to_end_if_step_out_of_bounds(
|
||||
logged_in_client,
|
||||
client_request,
|
||||
mock_has_no_jobs,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
endpoint,
|
||||
placeholders,
|
||||
@@ -1218,26 +1312,24 @@ def test_send_test_redirects_to_end_if_step_out_of_bounds(
|
||||
mocker,
|
||||
user,
|
||||
):
|
||||
mocker.patch('app.user_api_client.get_user', return_value=user(fake_uuid))
|
||||
client_request.login(user(fake_uuid))
|
||||
|
||||
with logged_in_client.session_transaction() as session:
|
||||
with client_request.session_transaction() as session:
|
||||
session['placeholders'] = placeholders
|
||||
|
||||
response = logged_in_client.get(url_for(
|
||||
client_request.get(
|
||||
endpoint,
|
||||
service_id=service_one['id'],
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
step_index=999,
|
||||
))
|
||||
|
||||
assert response.status_code == 302
|
||||
expected_url = url_for(
|
||||
expected_redirect,
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
_external=True,
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
expected_redirect,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
assert response.location == expected_url
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
|
||||
Reference in New Issue
Block a user