mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-22 14:11:27 -04:00
Link each row in the spreadsheet
We’ve heard from some users, especially those sending letters, that they’d like to check that a spreadsheet they’ve uploaded has populated the template correctly. My reckon is that seeing just one row of the spreadsheet populate the template isn’t enough to give people confidence that everything’s working properly. This commit adds links to all but the currently-previewed row. Clicking that link will populate the preview with values from that row. These pages already exist; they were created in this PR: https://github.com/alphagov/notifications-admin/pull/1696
This commit is contained in:
@@ -553,7 +553,8 @@ def _check_messages(service_id, template_type, upload_id, preview_row, letters_a
|
||||
template.template_type == 'letter',
|
||||
not request.args.get('from_test'),
|
||||
)),
|
||||
required_recipient_columns=OrderedSet(recipients.recipient_column_headers) - optional_address_columns
|
||||
required_recipient_columns=OrderedSet(recipients.recipient_column_headers) - optional_address_columns,
|
||||
preview_row=preview_row,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,11 @@
|
||||
) %}
|
||||
{% call index_field() %}
|
||||
<span>
|
||||
{{ item.index + 2 }}
|
||||
{% if item.index == preview_row %}
|
||||
{{ item.index + 2 }}
|
||||
{% else %}
|
||||
<a href="{{ url_for('.check_messages', service_id=current_service.id, template_type=template.template_type, upload_id=upload_id, row_index=(item.index)) }}">{{ item.index + 2 }}</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endcall %}
|
||||
{% for column in recipients.column_headers %}
|
||||
|
||||
@@ -464,19 +464,22 @@ def test_upload_valid_csv_redirects_to_check_page(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_args, expected_recipient, expected_message', [
|
||||
@pytest.mark.parametrize('extra_args, expected_link_in_first_row, expected_recipient, expected_message', [
|
||||
(
|
||||
{},
|
||||
None,
|
||||
'To: 07700900001',
|
||||
'Test Service: A, Template <em>content</em> with & entity',
|
||||
),
|
||||
(
|
||||
{'row_index': 0},
|
||||
None,
|
||||
'To: 07700900001',
|
||||
'Test Service: A, Template <em>content</em> with & entity',
|
||||
),
|
||||
(
|
||||
{'row_index': 2},
|
||||
True,
|
||||
'To: 07700900003',
|
||||
'Test Service: C, Template <em>content</em> with & entity',
|
||||
),
|
||||
@@ -490,6 +493,7 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
mock_get_detailed_service_for_today,
|
||||
fake_uuid,
|
||||
extra_args,
|
||||
expected_link_in_first_row,
|
||||
expected_recipient,
|
||||
expected_message,
|
||||
):
|
||||
@@ -516,8 +520,16 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
assert page.select_one('.sms-message-recipient').text.strip() == expected_recipient
|
||||
assert page.select_one('.sms-message-wrapper').text.strip() == expected_message
|
||||
|
||||
assert page.select_one('.table-field-index').text.strip() == '2'
|
||||
|
||||
if expected_link_in_first_row:
|
||||
assert page.select_one('.table-field-index a')['href'] == url_for(
|
||||
'main.check_messages', service_id=SERVICE_ONE_ID, template_type='sms', upload_id=fake_uuid, row_index=0
|
||||
)
|
||||
else:
|
||||
assert not page.select_one('.table-field-index').select_one('a')
|
||||
|
||||
for index, cell in enumerate([
|
||||
'<td class="table-field-index"> <span> 2 </span> </td>',
|
||||
'<td class="table-field-center-aligned "> <div class=""> 07700900001 </div> </td>',
|
||||
'<td class="table-field-center-aligned "> <div class=""> A </div> </td>',
|
||||
(
|
||||
@@ -530,7 +542,7 @@ def test_upload_valid_csv_shows_preview_and_table(
|
||||
'</td>'
|
||||
),
|
||||
]):
|
||||
assert normalize_spaces(str(page.select('table tbody td')[index])) == cell
|
||||
assert normalize_spaces(str(page.select('table tbody td')[index + 1])) == cell
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row_index, expected_status', [
|
||||
|
||||
Reference in New Issue
Block a user