Don’t show pagination links when searching

The search form makes a post request, so that phone numbers and email
addresses don’t show up in logs or browser history.

At most the API will return 50 results, with some pagination links. We
can’t easily give you links to click in the admin app, because links can
only perform get requests.

Because the value of seeing more than 50 results feels quite low (users
will probably make their search more specific before scrolling through
all 50) let’s just show a message saying only the first 50 results are
displayed.
This commit is contained in:
Chris Hill-Scott
2020-05-06 14:30:32 +01:00
parent 0955060c20
commit f30187b529
3 changed files with 39 additions and 2 deletions

View File

@@ -527,6 +527,35 @@ def test_should_show_notifications_for_a_service_with_next_previous(
assert 'page 1' in prev_page_link.text.strip()
def test_doesnt_show_pagination_with_search_term(
client_request,
service_one,
active_user_with_permissions,
mock_get_notifications_with_previous_next,
mock_get_service_statistics,
mock_get_service_data_retention,
mock_get_no_api_keys,
mocker,
):
page = client_request.post(
'main.view_notifications',
service_id=service_one['id'],
message_type='sms',
_data={
'to': 'test@example.com',
},
_expected_status=200,
)
assert len(page.select('tbody tr')) == 50
assert not page.find('a', {'rel': 'next'})
assert not page.find('a', {'rel': 'previous'})
assert normalize_spaces(
page.select_one('.table-show-more-link').text
) == (
'Only showing the first 50 messages'
)
@pytest.mark.parametrize(
"job_created_at, expected_message", [
("2016-01-10 11:09:00.000000+00:00", "Data available for 7 days"),