Merge pull request #1333 from alphagov/fix-empty-table-message

Fix empty table message
This commit is contained in:
Chris Hill-Scott
2017-06-23 13:45:34 +01:00
committed by GitHub
3 changed files with 23 additions and 3 deletions
+2 -2
View File
@@ -386,7 +386,7 @@ def get_job_partials(job):
def add_preview_of_content_to_notifications(notifications): def add_preview_of_content_to_notifications(notifications):
return ( return [
dict( dict(
preview_of_content=( preview_of_content=(
str(Template(notification['template'], notification['personalisation'])) str(Template(notification['template'], notification['personalisation']))
@@ -396,4 +396,4 @@ def add_preview_of_content_to_notifications(notifications):
**notification **notification
) )
for notification in notifications for notification in notifications
) ]
+18
View File
@@ -9,6 +9,7 @@ from bs4 import BeautifulSoup
from app.main.views.jobs import get_time_left, get_status_filters from app.main.views.jobs import get_time_left, get_status_filters
from tests import notification_json from tests import notification_json
from tests.conftest import SERVICE_ONE_ID from tests.conftest import SERVICE_ONE_ID
from tests.app.test_utils import normalize_spaces
from freezegun import freeze_time from freezegun import freeze_time
@@ -135,6 +136,23 @@ def test_can_show_notifications(
assert json_content.keys() == {'counts', 'notifications'} assert json_content.keys() == {'counts', 'notifications'}
def test_shows_message_when_no_notifications(
client_request,
mock_get_detailed_service,
mock_get_notifications_with_no_notifications,
):
page = client_request.get(
'main.view_notifications',
service_id=SERVICE_ONE_ID,
message_type='sms',
)
assert normalize_spaces(page.select('tbody tr')[0].text) == (
'No messages found'
)
@pytest.mark.parametrize(( @pytest.mark.parametrize((
'initial_query_arguments,' 'initial_query_arguments,'
'form_post_data,' 'form_post_data,'
+3 -1
View File
@@ -1128,7 +1128,9 @@ def mock_get_notifications_with_no_notifications(mocker):
status=None, status=None,
limit_days=None, limit_days=None,
include_jobs=None, include_jobs=None,
include_from_test_key=None): include_from_test_key=None,
to=None,
):
return notification_json(service_id, rows=0) return notification_json(service_id, rows=0)
return mocker.patch( return mocker.patch(