mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 05:28:24 -04:00
Remove old tour and help arguments from sending flow
We no longer need the `start_tour` page as this has been replaced with the new `begin_tour` page. We also no longer need to handle the `help` argument in the `send_test_step` or `send_one_off_step` as these no longer are responsible for the tour and don't need to show the help text. Worth pointing out, the new tour joins into the send one off flow. When doing a GET `check_tour_notification`, and submitting the form shown on this page you are POSTed to `send_notification` with `help=3`. Also for general sending of one off notifications, the POST to `send_notification` is done with `help=0` which is a bit of a hack to make sure that we don't show a back link on the `view_notification` page for when someone gets there having just sent a one off notification. This use of `help=0` may be a candidate for a refactor in the future as it feels like a bit of a hacky way of doing things and is therefore not as clear to developers what is going on. Also removes the help argument from the csv routes used here. There is no reason that we need to ever show help for CSVs and this is leftover code from when we used to do the tour that way.
This commit is contained in:
@@ -1381,54 +1381,36 @@ def test_send_one_off_does_not_send_without_the_correct_permissions(
|
||||
create_active_user_with_permissions(),
|
||||
create_active_caseworking_user(),
|
||||
))
|
||||
@pytest.mark.parametrize('template_type, partial_url, expected_h1, tour_shown', [
|
||||
@pytest.mark.parametrize('template_type, partial_url, expected_h1', [
|
||||
(
|
||||
'sms',
|
||||
partial(url_for, 'main.send_test'),
|
||||
'Personalise this message',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'sms',
|
||||
partial(url_for, 'main.send_one_off'),
|
||||
'Send ‘Two week reminder’',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'sms',
|
||||
partial(url_for, 'main.send_test', help=1),
|
||||
'Example text message',
|
||||
True,
|
||||
),
|
||||
(
|
||||
'email',
|
||||
partial(url_for, 'main.send_test', help=1),
|
||||
'Example text message',
|
||||
True,
|
||||
),
|
||||
(
|
||||
'email',
|
||||
partial(url_for, 'main.send_test'),
|
||||
'Personalise this message',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'email',
|
||||
partial(url_for, 'main.send_one_off'),
|
||||
'Send ‘Two week reminder’',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'letter',
|
||||
partial(url_for, 'main.send_test'),
|
||||
'Send ‘Two week reminder’',
|
||||
False,
|
||||
),
|
||||
(
|
||||
'letter',
|
||||
partial(url_for, 'main.send_one_off'),
|
||||
'Send ‘Two week reminder’',
|
||||
False,
|
||||
),
|
||||
])
|
||||
def test_send_one_off_or_test_has_correct_page_titles(
|
||||
@@ -1441,7 +1423,6 @@ def test_send_one_off_or_test_has_correct_page_titles(
|
||||
template_type,
|
||||
partial_url,
|
||||
expected_h1,
|
||||
tour_shown,
|
||||
user,
|
||||
):
|
||||
mocker.patch('app.user_api_client.get_user', return_value=user)
|
||||
@@ -1458,7 +1439,7 @@ def test_send_one_off_or_test_has_correct_page_titles(
|
||||
assert response.status_code == 200
|
||||
assert page.h1.text.strip() == expected_h1
|
||||
|
||||
assert (len(page.select('.banner-tour')) == 1) == tour_shown
|
||||
assert len(page.select('.banner-tour')) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint, step_index, prefilled, expected_field_label', [
|
||||
@@ -1773,32 +1754,6 @@ def test_no_link_to_use_existing_list_for_service_without_lists(
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user', (
|
||||
create_active_user_with_permissions(),
|
||||
create_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)
|
||||
|
||||
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', (
|
||||
create_active_user_with_permissions(),
|
||||
create_active_caseworking_user(),
|
||||
@@ -1974,7 +1929,7 @@ def test_send_test_redirects_to_start_if_index_out_of_bounds_and_some_placeholde
|
||||
('main.send_test', 'main.send_test_step'),
|
||||
('main.send_one_off', 'main.send_one_off_step'),
|
||||
])
|
||||
def test_send_test_sms_message_redirects_with_help_argument(
|
||||
def test_send_test_sms_message_redirects(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
@@ -1991,14 +1946,12 @@ def test_send_test_sms_message_redirects_with_help_argument(
|
||||
endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
help=1,
|
||||
_expected_status=302,
|
||||
_expected_response=url_for(
|
||||
expected_redirect,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
step_index=0,
|
||||
help=1,
|
||||
_external=True,
|
||||
)
|
||||
)
|
||||
@@ -2112,49 +2065,6 @@ def test_send_test_sms_message_back_link_with_multiple_placeholders(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('step_index, expected_back_link', (
|
||||
(0, partial(
|
||||
url_for,
|
||||
'main.start_tour',
|
||||
)),
|
||||
(1, partial(
|
||||
url_for,
|
||||
'main.send_test_step',
|
||||
step_index=0,
|
||||
help=2,
|
||||
)),
|
||||
(2, partial(
|
||||
url_for,
|
||||
'main.send_test_step',
|
||||
step_index=1,
|
||||
help=2,
|
||||
))
|
||||
))
|
||||
def test_send_test_sms_message_back_link_in_tour(
|
||||
client_request,
|
||||
mock_get_service_template_with_multiple_placeholders,
|
||||
mock_has_no_jobs,
|
||||
step_index,
|
||||
expected_back_link,
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = '07900900123'
|
||||
session['placeholders'] = {'phone number': '07900900123', 'one': 'bar'}
|
||||
|
||||
page = client_request.get(
|
||||
'main.send_test_step',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=unchanging_fake_uuid,
|
||||
step_index=step_index,
|
||||
help=2,
|
||||
)
|
||||
|
||||
assert page.select_one('.govuk-back-link')['href'] == expected_back_link(
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=unchanging_fake_uuid,
|
||||
)
|
||||
|
||||
|
||||
def test_send_test_letter_redirects_to_right_url(
|
||||
platform_admin_client,
|
||||
fake_uuid,
|
||||
@@ -3972,37 +3882,6 @@ def test_check_notification_redirects_if_session_not_populated(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('existing_session_items', [
|
||||
{},
|
||||
{'recipient': '07700900001'},
|
||||
{'name': 'Jo'}
|
||||
])
|
||||
def test_check_notification_redirects_with_help_if_session_not_populated(
|
||||
logged_in_client,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
existing_session_items,
|
||||
mock_get_service_template_with_placeholders
|
||||
):
|
||||
with logged_in_client.session_transaction() as session:
|
||||
session.update(existing_session_items)
|
||||
|
||||
resp = logged_in_client.get(url_for(
|
||||
'main.check_notification',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
help='2'
|
||||
))
|
||||
|
||||
assert resp.location == url_for(
|
||||
'main.send_test',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
help='2',
|
||||
_external=True
|
||||
)
|
||||
|
||||
|
||||
def test_check_notification_shows_preview(
|
||||
client_request,
|
||||
service_one,
|
||||
@@ -4031,6 +3910,8 @@ def test_check_notification_shows_preview(
|
||||
|
||||
# assert tour not visible
|
||||
assert not page.select('.banner-tour')
|
||||
|
||||
# post to send_notification with help=0 to ensure no back link is then shown
|
||||
assert page.form.attrs['action'] == url_for(
|
||||
'main.send_notification',
|
||||
service_id=service_one['id'],
|
||||
@@ -4039,37 +3920,6 @@ def test_check_notification_shows_preview(
|
||||
)
|
||||
|
||||
|
||||
def test_check_notification_shows_help(
|
||||
client_request,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_get_service_template
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = '07700900001'
|
||||
session['placeholders'] = {}
|
||||
|
||||
page = client_request.get(
|
||||
'main.check_notification',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
help='2'
|
||||
)
|
||||
assert page.select_one('.banner-tour')
|
||||
assert page.form.attrs['action'] == url_for(
|
||||
'main.send_notification',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
help='3'
|
||||
)
|
||||
assert page.select_one('.govuk-back-link')['href'] == url_for(
|
||||
'main.send_test',
|
||||
service_id=service_one['id'],
|
||||
template_id=fake_uuid,
|
||||
help='2'
|
||||
)
|
||||
|
||||
|
||||
def test_check_notification_shows_back_link(
|
||||
mocker,
|
||||
client_request,
|
||||
|
||||
@@ -2209,56 +2209,6 @@ def test_should_create_sms_or_broadcast_template_without_downgrading_unicode_cha
|
||||
)
|
||||
|
||||
|
||||
def test_should_show_template_as_first_page_of_tour(
|
||||
client_request,
|
||||
mock_get_service_template,
|
||||
service_one,
|
||||
fake_uuid,
|
||||
):
|
||||
|
||||
page = client_request.get(
|
||||
'main.start_tour',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
)
|
||||
|
||||
assert normalize_spaces(
|
||||
page.select('.banner-tour .heading-medium')[0].text
|
||||
) == (
|
||||
'Try sending yourself this example'
|
||||
)
|
||||
|
||||
assert normalize_spaces(
|
||||
page.select('.sms-message-wrapper')[0].text
|
||||
) == (
|
||||
'service one: Template <em>content</em> with & entity'
|
||||
)
|
||||
|
||||
assert page.select('a.govuk-button')[0]['href'] == url_for(
|
||||
'.send_test', service_id=SERVICE_ONE_ID, template_id=fake_uuid, help=2
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type', ['email', 'letter'])
|
||||
def test_cant_see_email_template_in_tour(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mocker,
|
||||
template_type,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.service_api_client.get_service_template',
|
||||
return_value={'data': create_template(template_type=template_type)}
|
||||
)
|
||||
|
||||
client_request.get(
|
||||
'main.start_tour',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
_expected_status=404,
|
||||
)
|
||||
|
||||
|
||||
def test_should_show_message_before_redacting_template(
|
||||
client_request,
|
||||
mock_get_service_template,
|
||||
|
||||
@@ -536,6 +536,14 @@ def test_should_200_for_check_tour_notification(
|
||||
'service one: hello hi howdy'
|
||||
)
|
||||
|
||||
# post to send_notification keeps help argument
|
||||
assert page.form.attrs['action'] == url_for(
|
||||
'main.send_notification',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=fake_uuid,
|
||||
help='3'
|
||||
)
|
||||
|
||||
|
||||
def test_back_link_from_check_tour_notification_points_to_last_tour_step(
|
||||
client_request,
|
||||
|
||||
Reference in New Issue
Block a user