diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 2a533bc30..00199291b 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -95,6 +95,8 @@ def view_notification(service_id, notification_id): page_count=page_count, show_recipient=True, redact_missing_personalisation=True, + sms_sender=notification['reply_to_text'], + email_reply_to=notification['reply_to_text'], ) template.values = personalisation if notification['job']: diff --git a/app/main/views/send.py b/app/main/views/send.py index 20d1deddc..04356069e 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -218,6 +218,10 @@ def set_sender(service_id, template_id): return redirect_to_one_off sender_details = get_sender_details(service_id, template['template_type']) + + if len(sender_details) == 1: + session['sender_id'] = sender_details[0]['id'] + if len(sender_details) <= 1: return redirect_to_one_off diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 3160c4cff..0a44ee326 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -949,3 +949,22 @@ def test_cancelling_a_letter_calls_the_api( ) assert cancel_endpoint.called + + +@pytest.mark.parametrize('notification_type', ['sms', 'email']) +def test_should_show_reply_to_from_notification( + mocker, + fake_uuid, + notification_type, + client_request, +): + notification = create_notification(reply_to_text='reply to info', template_type=notification_type) + mocker.patch('app.notification_api_client.get_notification', return_value=notification) + + page = client_request.get( + 'main.view_notification', + service_id=SERVICE_ONE_ID, + notification_id=fake_uuid, + ) + + assert 'reply to info' in page.text diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 8fe90dce6..06a7c8c56 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -254,6 +254,52 @@ def test_set_sender_redirects_if_no_sms_senders( ) +def test_set_sender_redirects_if_one_email_sender( + client_request, + fake_uuid, + mock_get_service_email_template, + single_reply_to_email_address, +): + client_request.get( + '.set_sender', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + _expected_status=302, + _expected_url=url_for( + '.send_one_off', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + _external=True, + ) + ) + + with client_request.session_transaction() as session: + assert session['sender_id'] == '1234' + + +def test_set_sender_redirects_if_one_sms_sender( + client_request, + fake_uuid, + mock_get_service_template, + single_sms_sender, +): + client_request.get( + '.set_sender', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + _expected_status=302, + _expected_url=url_for( + '.send_one_off', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + _external=True, + ) + ) + + with client_request.session_transaction() as session: + assert session['sender_id'] == '1234' + + def test_that_test_files_exist(): assert len(test_spreadsheet_files) == 8 assert len(test_non_spreadsheet_files) == 6 diff --git a/tests/conftest.py b/tests/conftest.py index e1d8eee1d..98e2a551e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4174,13 +4174,15 @@ def create_notification( key_type=None, postage=None, sent_one_off=True, + reply_to_text=None, ): noti = notification_json( service_id, rows=1, status=notification_status, template_type=template_type, - postage=postage + postage=postage, + reply_to_text=reply_to_text, )['notifications'][0] noti['id'] = notifification_id or sample_uuid()