mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Filter empty items out of lists
The email template does this already when formatting the body of the message. But the spreadsheet preview doesn’t, which means you get lists like: - thing - thing - None This commit fixes that. This was a pre-existing bug, but gonna roll it in with this PR.
This commit is contained in:
@@ -83,7 +83,9 @@
|
|||||||
{% if text is iterable and text is not string %}
|
{% if text is iterable and text is not string %}
|
||||||
<ul class="list list-bullet">
|
<ul class="list list-bullet">
|
||||||
{% for item in text %}
|
{% for item in text %}
|
||||||
<li>{{ item }}</li>
|
{% if item %}
|
||||||
|
<li>{{ item }}</li>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ def test_upload_valid_csv_shows_preview_and_table(
|
|||||||
phone number,name,thing,thing,thing
|
phone number,name,thing,thing,thing
|
||||||
07700900001, A, foo, foo, foo
|
07700900001, A, foo, foo, foo
|
||||||
07700900002, B, foo, foo, foo
|
07700900002, B, foo, foo, foo
|
||||||
07700900003, C, foo, foo, foo
|
07700900003, C, foo, foo,
|
||||||
""")
|
""")
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
@@ -609,20 +609,50 @@ def test_upload_valid_csv_shows_preview_and_table(
|
|||||||
else:
|
else:
|
||||||
assert not page.select_one('.table-field-index').select_one('a')
|
assert not page.select_one('.table-field-index').select_one('a')
|
||||||
|
|
||||||
for index, cell in enumerate([
|
for row_index, row in enumerate([
|
||||||
'<td class="table-field-center-aligned "> <div class=""> 07700900001 </div> </td>',
|
|
||||||
'<td class="table-field-center-aligned "> <div class=""> A </div> </td>',
|
|
||||||
(
|
(
|
||||||
'<td class="table-field-center-aligned "> '
|
'<td class="table-field-center-aligned "> <div class=""> 07700900001 </div> </td>',
|
||||||
'<div class="table-field-status-default"> '
|
'<td class="table-field-center-aligned "> <div class=""> A </div> </td>',
|
||||||
'<ul class="list list-bullet"> '
|
(
|
||||||
'<li>foo</li> <li>foo</li> <li>foo</li> '
|
'<td class="table-field-center-aligned "> '
|
||||||
'</ul> '
|
'<div class="table-field-status-default"> '
|
||||||
'</div> '
|
'<ul class="list list-bullet"> '
|
||||||
'</td>'
|
'<li>foo</li> <li>foo</li> <li>foo</li> '
|
||||||
|
'</ul> '
|
||||||
|
'</div> '
|
||||||
|
'</td>'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'<td class="table-field-center-aligned "> <div class=""> 07700900002 </div> </td>',
|
||||||
|
'<td class="table-field-center-aligned "> <div class=""> B </div> </td>',
|
||||||
|
(
|
||||||
|
'<td class="table-field-center-aligned "> '
|
||||||
|
'<div class="table-field-status-default"> '
|
||||||
|
'<ul class="list list-bullet"> '
|
||||||
|
'<li>foo</li> <li>foo</li> <li>foo</li> '
|
||||||
|
'</ul> '
|
||||||
|
'</div> '
|
||||||
|
'</td>'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'<td class="table-field-center-aligned "> <div class=""> 07700900003 </div> </td>',
|
||||||
|
'<td class="table-field-center-aligned "> <div class=""> C </div> </td>',
|
||||||
|
(
|
||||||
|
'<td class="table-field-center-aligned "> '
|
||||||
|
'<div class="table-field-status-default"> '
|
||||||
|
'<ul class="list list-bullet"> '
|
||||||
|
'<li>foo</li> <li>foo</li> '
|
||||||
|
'</ul> '
|
||||||
|
'</div> '
|
||||||
|
'</td>'
|
||||||
|
)
|
||||||
),
|
),
|
||||||
]):
|
]):
|
||||||
assert normalize_spaces(str(page.select('table tbody td')[index + 1])) == cell
|
for index, cell in enumerate(row):
|
||||||
|
row = page.select('table tbody tr')[row_index]
|
||||||
|
assert normalize_spaces(str(row.select('td')[index + 1])) == cell
|
||||||
|
|
||||||
|
|
||||||
def test_show_all_columns_if_there_are_duplicate_recipient_columns(
|
def test_show_all_columns_if_there_are_duplicate_recipient_columns(
|
||||||
|
|||||||
Reference in New Issue
Block a user