diff --git a/app/templates/components/table.html b/app/templates/components/table.html
index 380d595d0..c0b927d77 100644
--- a/app/templates/components/table.html
+++ b/app/templates/components/table.html
@@ -83,7 +83,9 @@
{% if text is iterable and text is not string %}
{% for item in text %}
- - {{ item }}
+ {% if item %}
+ - {{ item }}
+ {% endif %}
{% endfor %}
{% else %}
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py
index 866ac2e55..61e50dd4e 100644
--- a/tests/app/main/views/test_send.py
+++ b/tests/app/main/views/test_send.py
@@ -585,7 +585,7 @@ def test_upload_valid_csv_shows_preview_and_table(
phone number,name,thing,thing,thing
07700900001, A, foo, foo, foo
07700900002, B, foo, foo, foo
- 07700900003, C, foo, foo, foo
+ 07700900003, C, foo, foo,
""")
page = client_request.get(
@@ -609,20 +609,50 @@ def test_upload_valid_csv_shows_preview_and_table(
else:
assert not page.select_one('.table-field-index').select_one('a')
- for index, cell in enumerate([
- ' 07700900001 | ',
- ' A | ',
+ for row_index, row in enumerate([
(
- ' '
- ' '
- ' | '
+ ' 07700900001 | ',
+ ' A | ',
+ (
+ ' '
+ ' '
+ ' | '
+ )
+ ),
+ (
+ ' 07700900002 | ',
+ ' B | ',
+ (
+ ' '
+ ' '
+ ' | '
+ )
+ ),
+ (
+ ' 07700900003 | ',
+ ' C | ',
+ (
+ ' '
+ ' '
+ ' | '
+ )
),
]):
- 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(