From 2ede3ef8f0f54386565b099653ac1c4f8ca6f85c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 26 Aug 2020 10:59:29 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20filter=20=E2=80=98All=20of?= =?UTF-8?q?=E2=80=99=20choice=20with=20live=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because the ‘All of’ choice appears above the search field, it shouldn’t be filtered by the search field. We can fix this by wrapping the sub-areas in a `
` and make the selector more specific. --- app/templates/views/broadcast/sub-areas.html | 6 ++++-- tests/app/main/views/test_broadcast.py | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/templates/views/broadcast/sub-areas.html b/app/templates/views/broadcast/sub-areas.html index 35cf74fb7..ca638b459 100644 --- a/app/templates/views/broadcast/sub-areas.html +++ b/app/templates/views/broadcast/sub-areas.html @@ -22,9 +22,11 @@ {{ form.select_all }}
- {{ live_search(target_selector='.govuk-checkboxes__item', show=show_search_form, form=search_form, label='Or by electoral ward') }} + {{ live_search(target_selector='#sub-areas .govuk-checkboxes__item', show=show_search_form, form=search_form, label='Or by electoral ward') }} - {{ form.areas }} +
+ {{ form.areas }} +
{{ sticky_page_footer('Add to broadcast') }} diff --git a/tests/app/main/views/test_broadcast.py b/tests/app/main/views/test_broadcast.py index 287dad680..1e1616a50 100644 --- a/tests/app/main/views/test_broadcast.py +++ b/tests/app/main/views/test_broadcast.py @@ -468,21 +468,33 @@ def test_choose_broadcast_sub_area_page( 'Choose an area of Aberdeen City' ) live_search = page.select_one("[data-module=live-search]") - assert live_search['data-targets'] == '.govuk-checkboxes__item' + assert live_search['data-targets'] == '#sub-areas .govuk-checkboxes__item' assert live_search.select_one('input')['type'] == 'search' - choices = [ + all_choices = [ ( choice.select_one('input')['value'], normalize_spaces(choice.select_one('label').text), ) for choice in page.select('form[method=post] .govuk-checkboxes__item') ] - assert choices[:3] == [ + sub_choices = [ + ( + choice.select_one('input')['value'], + normalize_spaces(choice.select_one('label').text), + ) + for choice in page.select('form[method=post] #sub-areas .govuk-checkboxes__item') + ] + assert all_choices[:3] == [ ('y', 'All of Aberdeen City'), ('wd20-S13002845', 'Airyhall/Broomhill/Garthdee'), ('wd20-S13002836', 'Bridge of Don'), ] - assert choices[-1:] == [ + assert sub_choices[:3] == [ + ('wd20-S13002845', 'Airyhall/Broomhill/Garthdee'), + ('wd20-S13002836', 'Bridge of Don'), + ('wd20-S13002835', 'Dyce/Bucksburn/Danestone'), + ] + assert all_choices[-1:] == sub_choices[-1:] == [ ('wd20-S13002846', 'Torry/Ferryhill'), ]