From 7411256fc2bd76d716f839ebc9a1cba9a154ce45 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 14 Jun 2017 16:25:20 +0100 Subject: [PATCH] Add hidden form to re-`post` AJAX requests Serializing the search box form is bad, because the AJAX thing submit any changes that the user makes to the contents of the box. This results in unexpected behaviour. --- app/templates/views/notifications.html | 8 ++++++-- tests/app/main/views/test_activity.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index a323c9ae8..7540720b2 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -24,7 +24,6 @@ method="post" action="{{ url_for('.view_notifications', service_id=current_service.id, message_type=message_type) }}" class="grid-row" - id="search-form" >
{{ textbox( @@ -34,11 +33,16 @@ ) }}
- +
+
+ + +
+ {{ ajax_block( partials, url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status, page=page), diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 61c5cc873..b0f230ced 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -193,7 +193,11 @@ def test_search_recipient_form( query_dict = parse_qs(url.query) assert query_dict == {} - assert page.find("input", {'name': 'to'})['value'] == expected_search_box_contents + recipient_inputs = page.select("input[name=to]") + assert(len(recipient_inputs) == 2) + + for field in recipient_inputs: + assert field['value'] == expected_search_box_contents def test_should_show_notifications_for_a_service_with_next_previous(