From e74d4089537cd709242723f2039faf407278f861 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 21 May 2018 10:06:16 +0100 Subject: [PATCH] Allow users to preview all letters in trial mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you’re in trial mode you can’t send letters for real. But you can still upload a spreadsheet with multiple rows, and there’s no reason why you shouldn’t be able to explore how Notify populate the letter for each row of the spreadsheet (since this is something we let you do when you can send the messages for real). --- app/templates/views/check/column-errors.html | 11 ++++++++++- tests/app/main/views/test_send.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/templates/views/check/column-errors.html b/app/templates/views/check/column-errors.html index 7790d52d6..64e44f49b 100644 --- a/app/templates/views/check/column-errors.html +++ b/app/templates/views/check/column-errors.html @@ -162,7 +162,16 @@ ) %} {% call index_field() %} - {{ item.index + 2 }} + {% set displayed_index = item.index + 2 %} + {% if ( + trying_to_send_letters_in_trial_mode and + (not errors or recipients.more_rows_than_can_send) and + displayed_index != preview_row + ) %} + {{ displayed_index }} + {% else %} + {{ displayed_index }} + {% endif %} {% endcall %} {% for column in column_headers %} diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 8bcf93d44..cc0a45328 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -2168,7 +2168,8 @@ def test_check_messages_shows_trial_mode_error( ]) @pytest.mark.parametrize('number_of_rows, expected_error_message', [ (1, 'You can’t send this letter'), - (111, 'You can’t send these letters'), + (11, 'You can’t send these letters'), # Less than trial mode limit + (111, 'You can’t send these letters'), # More than trial mode limit ]) def test_check_messages_shows_trial_mode_error_for_letters( client_request, @@ -2219,6 +2220,9 @@ def test_check_messages_shows_trial_mode_error_for_letters( else: assert not error + if number_of_rows > 1: + assert page.select_one('.table-field-index a').text == '3' + def test_check_messages_shows_data_errors_before_trial_mode_errors_for_letters( mocker, @@ -2233,6 +2237,7 @@ def test_check_messages_shows_data_errors_before_trial_mode_errors_for_letters( mocker.patch('app.main.views.send.s3download', return_value='\n'.join( ['address_line_1,address_line_2,postcode,'] + + [' , ,11SW1 1AA'] + [' , ,11SW1 1AA'] )) @@ -2255,9 +2260,10 @@ def test_check_messages_shows_data_errors_before_trial_mode_errors_for_letters( assert normalize_spaces(page.select_one('.banner-dangerous').text) == ( 'There is a problem with example.xlsx ' - 'You need to enter missing data in 1 row ' + 'You need to enter missing data in 2 rows ' 'Skip to file contents' ) + assert not page.select('.table-field-index a') def test_check_messages_column_error_doesnt_show_optional_columns(