diff --git a/app/main/views/send.py b/app/main/views/send.py
index 354c5c8e2..b1a1cc53e 100644
--- a/app/main/views/send.py
+++ b/app/main/views/send.py
@@ -439,7 +439,10 @@ def _check_messages(service_id, template_type, upload_id, letters_as_pdf=False):
remaining_messages=remaining_messages,
choose_time_form=choose_time_form,
back_link=back_link,
- help=get_help_argument()
+ help=get_help_argument(),
+ trying_to_send_letters_in_trial_mode=bool(
+ current_service['restricted'] and template.template_type == 'letter'
+ ),
)
@@ -454,7 +457,8 @@ def check_messages(service_id, template_type, upload_id):
data['recipients'].too_many_rows or
not data['count_of_recipients'] or
not data['recipients'].has_recipient_columns or
- data['recipients'].missing_column_headers
+ data['recipients'].missing_column_headers or
+ data['trying_to_send_letters_in_trial_mode']
):
return render_template('views/check/column-errors.html', **data)
diff --git a/app/templates/views/check/column-errors.html b/app/templates/views/check/column-errors.html
index f8407792f..491eade0f 100644
--- a/app/templates/views/check/column-errors.html
+++ b/app/templates/views/check/column-errors.html
@@ -75,14 +75,29 @@
{% elif not recipients.allowed_to_send_to %}
+
{% with
count_of_recipients=count_of_recipients,
template_type_label=recipients.recipient_column_headers[0]
%}
{% include "partials/check/not-allowed-to-send-to.html" %}
{% endwith %}
+
+ {% elif trying_to_send_letters_in_trial_mode %}
+
+
+ You can’t send
+ {{ 'this letter' if count_of_recipients == 1 else 'these letters' }}
+
+
+ In trial mode you
+ can only preview how your letters will look
+
+
{% elif recipients.more_rows_than_can_send %}
+
{% include "partials/check/too-many-messages.html" %}
+
{% endif %}
{{ skip_to_file_contents() }}
diff --git a/app/templates/views/trial-mode.html b/app/templates/views/trial-mode.html
index 73fe27c11..a3e90e3fe 100644
--- a/app/templates/views/trial-mode.html
+++ b/app/templates/views/trial-mode.html
@@ -17,7 +17,7 @@
-
- you can only send messages to yourself
+ you can only send text messages and emails to yourself
-
you can add people to
@@ -26,10 +26,13 @@
{% else %}
your team,
{% endif %}
- then you can send messages to them too
+ then you can send text messages and emails to them too
-
- you can only send 50 messages per day
+ you can only send 50 text messages or emails per day
+
+ -
+ you can’t send any letters
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py
index 4b56a17f1..06504e8c0 100644
--- a/tests/app/main/views/test_send.py
+++ b/tests/app/main/views/test_send.py
@@ -24,6 +24,8 @@ from tests.conftest import (
mock_get_service_email_template,
normalize_spaces,
SERVICE_ONE_ID,
+ mock_get_service,
+ mock_get_live_service,
)
template_types = ['email', 'sms']
@@ -1577,6 +1579,58 @@ def test_check_messages_shows_trial_mode_error(
)
+@pytest.mark.parametrize('service_mock, error_should_be_shown', [
+ (mock_get_service, True),
+ (mock_get_live_service, False),
+])
+@pytest.mark.parametrize('number_of_rows, expected_error_message', [
+ (1, 'You can’t send this letter'),
+ (111, 'You can’t send these letters'),
+])
+def test_check_messages_shows_trial_mode_error_for_letters(
+ client_request,
+ api_user_active,
+ mock_get_service_letter_template,
+ mock_has_permissions,
+ mock_get_users_by_service,
+ mock_get_detailed_service_for_today,
+ mocker,
+ service_mock,
+ error_should_be_shown,
+ number_of_rows,
+ expected_error_message,
+):
+
+ service_mock(mocker, api_user_active)
+
+ mocker.patch('app.main.views.send.s3download', return_value='\n'.join(
+ ['address_line_1,address_line_2,postcode,'] +
+ ['First Last, 123 Street, SW1 1AA'] * number_of_rows
+ ))
+
+ with client_request.session_transaction() as session:
+ session['upload_data'] = {'template_id': ''}
+
+ page = client_request.get(
+ 'main.check_messages',
+ service_id=SERVICE_ONE_ID,
+ template_type='letter',
+ upload_id=uuid.uuid4(),
+ _test_page_title=False,
+ )
+
+ error = page.select('.banner-dangerous')
+
+ if error_should_be_shown:
+ assert normalize_spaces(error[0].text) == (
+ '{} '
+ 'In trial mode you can only preview how your letters will look '
+ 'Skip to file contents'
+ ).format(expected_error_message)
+ else:
+ assert not error
+
+
def test_check_messages_shows_over_max_row_error(
logged_in_client,
api_user_active,
@@ -1620,7 +1674,7 @@ def test_non_ascii_characters_in_letter_recipients_file_shows_error(
api_user_active,
mock_login,
mock_get_users_by_service,
- mock_get_service,
+ mock_get_live_service,
mock_has_permissions,
mock_get_service_letter_template,
mock_get_detailed_service_for_today,