From 0697c626167112d07bc51c15b721dcabf90ca577 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 11 May 2017 10:55:44 +0100 Subject: [PATCH] Hide the recipient table on send yourself a test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Send yourself a test is: - a good way of explaining how placeholders work - a useful tool for checking your work before you send a big batch It’s not a good way of learning about the relationship between columns in a spreadsheet and placeholders. The ‘example spreadsheet’ thing is good at making that connection. The table on this page isn’t, because it doesn’t _feel_ like you’re making a spreadsheet with the send yourself a test feature (even though that’s what you’re doing in the background). This will be even more the case when we stop putting the input boxes horizontally on one page. By removing the table from this page it makes the page simpler, which allows people to focus on the important thing – what’s happening to their message. --- app/templates/views/check.html | 62 ++++++++++++++++--------------- tests/app/main/views/test_send.py | 30 +++++++++++++++ 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/app/templates/views/check.html b/app/templates/views/check.html index a9c3b3a2d..747e68744 100644 --- a/app/templates/views/check.html +++ b/app/templates/views/check.html @@ -185,37 +185,41 @@ {% endif %} -

{{ original_file_name }}

+ {% if not request.args.from_test %} - {% call(item, row_number) list_table( - recipients.initial_annotated_rows_with_errors if row_errors and not recipients.missing_column_headers else recipients.initial_annotated_rows, - caption=original_file_name, - caption_visible=False, - field_headings=[ - 'Row in file'|safe - ] + recipients.column_headers - ) %} - {{ index_field(item.index + 2) }} - {% for column in recipients.column_headers %} - {% if item['columns'][column].error and not recipients.missing_column_headers %} - {% call field() %} - - {{ item['columns'][column].error }} - {{ item['columns'][column].data if item['columns'][column].data != None }} - - {% endcall %} - {% elif item['columns'][column].ignore %} - {{ text_field(item['columns'][column].data or '', status='default') }} - {% else %} - {{ text_field(item['columns'][column].data or '') }} - {% endif %} - {% endfor %} - {% if item['columns'].get(None) %} - {% for column in item['columns'][None].data %} - {{ text_field(column, status='default') }} +

{{ original_file_name }}

+ + {% call(item, row_number) list_table( + recipients.initial_annotated_rows_with_errors if row_errors and not recipients.missing_column_headers else recipients.initial_annotated_rows, + caption=original_file_name, + caption_visible=False, + field_headings=[ + 'Row in file'|safe + ] + recipients.column_headers + ) %} + {{ index_field(item.index + 2) }} + {% for column in recipients.column_headers %} + {% if item['columns'][column].error and not recipients.missing_column_headers %} + {% call field() %} + + {{ item['columns'][column].error }} + {{ item['columns'][column].data if item['columns'][column].data != None }} + + {% endcall %} + {% elif item['columns'][column].ignore %} + {{ text_field(item['columns'][column].data or '', status='default') }} + {% else %} + {{ text_field(item['columns'][column].data or '') }} + {% endif %} {% endfor %} - {% endif %} - {% endcall %} + {% if item['columns'].get(None) %} + {% for column in item['columns'][None].data %} + {{ text_field(column, status='default') }} + {% endfor %} + {% endif %} + {% endcall %} + + {% endif %} {% if recipients.too_many_rows %} diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index a4c063a1e..9de1d52e4 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -282,6 +282,36 @@ def test_upload_valid_csv_shows_file_contents( assert normalize_spaces(str(page.select('table tbody td')[index])) == cell +def test_send_test_doesnt_show_file_contents( + logged_in_client, + mocker, + mock_get_service_template_with_placeholders, + mock_s3_upload, + mock_get_users_by_service, + mock_get_detailed_service_for_today, + service_one, + fake_uuid, +): + + mocker.patch('app.main.views.send.s3download', return_value=""" + phone number,name,thing,thing,thing + 07700900986, Jo, foo, foo, foo + """) + + response = logged_in_client.post( + url_for('main.send_test', service_id=service_one['id'], template_id=fake_uuid), + data={}, + follow_redirects=True, + ) + + assert response.status_code == 200 + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.select('h1')[0].text.strip() == 'Preview of Two week reminder' + assert len(page.select('table')) == 0 + assert len(page.select('.banner-dangerous')) == 0 + assert page.select('input[type=submit]')[0]['value'].strip() == 'Send 1 text message' + + def test_send_test_sms_message( logged_in_client, mocker,