diff --git a/app/templates/views/notifications/check.html b/app/templates/views/notifications/check.html index e9f65c00d..19c5d34e4 100644 --- a/app/templates/views/notifications/check.html +++ b/app/templates/views/notifications/check.html @@ -1,5 +1,5 @@ {% extends "withnav_template.html" %} -{% from "components/radios.html" import radio_select %} +{% from "components/banner.html" import banner_wrapper %} {% from "components/message-count-label.html" import message_count_label %} {% block service_page_title %} @@ -8,17 +8,31 @@ {% block maincolumn_content %} {% if error == 'not-allowed-to-send-to' %} - {% with - count_of_recipients=1, - template_type_label='phone number' - %} - {% include "partials/check/not-allowed-to-send-to.html" %} - {% endwith %} +
+ {% call banner_wrapper(type='dangerous') %} + {% with + count_of_recipients=1, + template_type_label=( + 'phone number' if template.template_type == 'sms' else 'email address' + ) + %} + {% include "partials/check/not-allowed-to-send-to.html" %} + {% endwith %} + {% endcall %} +
{% elif error == 'too-many-messages' %} - {% include "partials/check/too-many-messages.html" %} +
+ {% call banner_wrapper(type='dangerous') %} + {% include "partials/check/too-many-messages.html" %} + {% endcall %} +
{% elif error == 'message-too-long' %} {# the only row_errors we can get when sending one off messages is that the message is too long #} - {% include "partials/check/message-too-long.html" %} +
+ {% call banner_wrapper(type='dangerous') %} + {% include "partials/check/message-too-long.html" %} + {% endcall %} +
{% else %}

Preview of {{ template.name }} diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 39d0e05a0..f025cae88 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -1937,6 +1937,35 @@ def test_send_notification_shows_error_if_400( _expected_status=200 ) - assert ' '.join(page.h1.text.split()) == expected_h1 - assert ' '.join(page.h1.parent.p.text.split()) == expected_err_details + assert normalize_spaces(page.select('.banner-dangerous h1')[0].text) == expected_h1 + assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == expected_err_details assert not page.find('input[type=submit]') + + +def test_send_notification_shows_email_error_in_trial_mode( + client_request, + fake_uuid, + mocker, + mock_get_service_email_template, +): + mocker.patch( + 'app.notification_api_client.send_notification', + side_effect=HTTPError(response=Mock(status_code=400), message=TRIAL_MODE_MSG) + ) + with client_request.session_transaction() as session: + session['recipient'] = 'test@example.com' + session['placeholders'] = {'date': 'foo', 'thing': 'bar'} + + page = client_request.post( + 'main.send_notification', + service_id=SERVICE_ONE_ID, + template_id=fake_uuid, + _expected_status=200, + ) + + assert normalize_spaces(page.select('.banner-dangerous h1')[0].text) == ( + 'You can’t send to this email address' + ) + assert normalize_spaces(page.select('.banner-dangerous p')[0].text) == ( + 'In trial mode you can only send to yourself and members of your team' + )