Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSS-2016: policy teams search #776

Merged
merged 32 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
474163d
Building forms
EPedley Aug 9, 2024
82b7161
Building views
EPedley Aug 9, 2024
a74c132
Adding views to URLs file
EPedley Aug 9, 2024
caccc0e
Building HTML files
EPedley Aug 9, 2024
a30a72a
Adding funcs to get data from API
EPedley Aug 9, 2024
6c5e2b0
Adding policy team section to barrier details page
EPedley Aug 9, 2024
04afb23
Formatting
EPedley Aug 9, 2024
524f363
Adding policy team dummy data to metadata file
EPedley Aug 9, 2024
56b8ea9
Adding new tests
EPedley Aug 9, 2024
f20ca1d
Updating dummy barrier to include policy team info
EPedley Aug 9, 2024
88ed786
Adding history functionality
EPedley Aug 9, 2024
0c8b15a
Formatting
EPedley Aug 9, 2024
9c4951f
Amending for Flake8 error
EPedley Aug 13, 2024
d338f3c
Making policy team descriptions dynamic
EPedley Aug 13, 2024
04dfaae
Formatting
EPedley Aug 13, 2024
efcc056
Removing Barrier Category from page
EPedley Aug 13, 2024
7efe4ca
Removing comments
EPedley Aug 13, 2024
6ec1a6f
Frontend test for policy teams
EPedley Aug 13, 2024
beb0dc4
Formatting
EPedley Aug 13, 2024
1868094
removing unused imports
EPedley Aug 13, 2024
ac02692
Cleaning up tests
EPedley Aug 13, 2024
2ddedc4
Formatting
EPedley Aug 13, 2024
92d86c7
updating to absolute imports
EPedley Aug 13, 2024
ef450ed
Formatting
EPedley Aug 13, 2024
cfd019d
fixing faulty test
EPedley Aug 13, 2024
6bc1d5f
Adding HTML
EPedley Aug 14, 2024
c9e7e3f
Primary functionality
EPedley Aug 14, 2024
cc4a782
Frontend test
EPedley Aug 14, 2024
8cead82
Formatting
EPedley Aug 14, 2024
b84c7de
Removing category filtering from search page
EPedley Aug 14, 2024
77ba798
Removing category search tests
EPedley Aug 14, 2024
e824ebc
Merge branch 'develop' into TSS-2016_Polcy_Teams_Search
Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions barriers/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class BarrierSearchForm(forms.Form):
label="Category",
required=False,
)
policy_team = forms.MultipleChoiceField(
label="Policy team",
required=False,
)
region = forms.MultipleChoiceField(
label="Overseas region",
required=False,
Expand Down Expand Up @@ -260,6 +264,7 @@ def __init__(self, metadata, *args, **kwargs):
self.set_sector_choices()
self.set_organisation_choices()
self.set_category_choices()
self.set_policy_team_choices()
self.set_region_choices()
self.set_status_choices()
self.set_tags_choices()
Expand Down Expand Up @@ -335,6 +340,13 @@ def set_category_choices(self):
choices.sort(key=itemgetter(1))
self.fields["category"].choices = choices

def set_policy_team_choices(self):
choices = [
(str(policy_team["id"]), policy_team["title"])
for policy_team in self.metadata.data["policy_teams"]
]
self.fields["policy_team"].choices = choices

def set_region_choices(self):
choices = [
(country["id"], country["name"])
Expand Down Expand Up @@ -454,6 +466,7 @@ def get_api_search_parameters(self):
params["ignore_all_sectors"] = self.cleaned_data.get("ignore_all_sectors")
params["organisation"] = ",".join(self.cleaned_data.get("organisation", []))
params["category"] = ",".join(self.cleaned_data.get("category", []))
params["policy_team"] = ",".join(self.cleaned_data.get("policy_team", []))
params["status"] = ",".join(self.cleaned_data.get("status", []))
params["tags"] = ",".join(self.cleaned_data.get("tags", []))
for status_value in STATUS_WITH_DATE_FILTER:
Expand Down
6 changes: 3 additions & 3 deletions templates/barriers/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]
)
ReactApp.renderMultiSelectFilter("organisation")
ReactApp.renderMultiSelectFilter("category", "Search categories")
ReactApp.renderMultiSelectFilter("policy_team", "Search policy teams")
ReactApp.renderMultiSelectFilter("region")
ReactApp.renderAsyncSearchResults()
})
Expand Down Expand Up @@ -63,7 +63,7 @@ <h2 class="filter-list-title">Filter barriers by:</h2>
{% include "partials/forms/checkbox_filter.html" with field=form.trade_direction %}
{% include "partials/forms/checkbox_filter.html" with field=form.sector %}
{% include "partials/forms/checkbox_filter.html" with field=form.organisation %}
{% include "partials/forms/checkbox_filter.html" with field=form.category %}
{% include "partials/forms/checkbox_filter.html" with field=form.policy_team %}
{% include "partials/forms/checkbox_filter.html" with field=form.region %}
{% comment %} {% include 'partials/forms/checkbox_filter.html' with field=form.top_priority_status %}
{% include 'partials/forms/checkbox_filter.html' with field=form.priority_level %} {% endcomment %}
Expand Down Expand Up @@ -154,7 +154,7 @@ <h3 class="visually-hidden">Active filters:</h3>
{% include 'barriers/partials/active_filter.html' with filter=filters.trade_direction %}
{% include 'barriers/partials/active_filter.html' with filter=filters.sector %}
{% include 'barriers/partials/active_filter.html' with filter=filters.organisation %}
{% include 'barriers/partials/active_filter.html' with filter=filters.category %}
{% include 'barriers/partials/active_filter.html' with filter=filters.policy_team %}
{% include 'barriers/partials/active_filter.html' with filter=filters.search %}
{% include 'barriers/partials/active_filter.html' with filter=filters.region %}
{% include 'barriers/partials/active_filter.html' with filter=filters.combined_priority %}
Expand Down
20 changes: 19 additions & 1 deletion test_frontend/test_search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from playwright.sync_api import expect

from .utils import get_base_url, retry
from test_frontend.utils import clean_full_url, get_base_url, retry


@retry()
Expand Down Expand Up @@ -57,3 +57,21 @@ def test_saved_search(page, create_test_barrier, session_data):

# back to search page
expect(page.get_by_role("link", name="Export type: Goods Activate")).to_be_visible()


@retry()
def test_search_for_a_barrier_with_policy_name_filter(
page, create_test_barrier, session_data
):

title = session_data["barrier_title"]
url = create_test_barrier(title=title)
page.goto(clean_full_url(url))

page.goto(get_search_page())
page.get_by_role("group", name="Policy team").locator("svg").click()
page.get_by_text("Gender", exact=True).click()
# remove focus on search box to allow the search results to update
page.get_by_role("heading", name="Market access barriers Search").click()

expect(page.get_by_text(title)).to_be_visible()
9 changes: 9 additions & 0 deletions tests/barriers/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def test_search_form_choices(self, mock_list):
category_choices = form.fields["category"].choices
assert len(category_choices) == len(category_list)

policy_team_list = set(
[policy_team["id"] for policy_team in metadata.data["policy_teams"]]
)
policy_team_choices = form.fields["policy_team"].choices
assert len(policy_team_choices) == len(policy_team_list)

region_list = set(
[region["id"] for region in metadata.get_overseas_region_list()]
)
Expand All @@ -81,6 +87,7 @@ def test_search_filters(self, mock_list):
"aa22c9d2-5f95-e211-a939-e4115bead28a",
],
"category": ["130", "141"],
"policy_team": ["10", "11"],
"region": [
"3e6809d6-89f6-4590-8458-1d0dab73ad1a",
"5616ccf5-ab4a-4c2c-9624-13c69be3c46b",
Expand All @@ -104,6 +111,7 @@ def test_search_filters(self, mock_list):
"aa22c9d2-5f95-e211-a939-e4115bead28a",
]
assert form.cleaned_data["category"] == ["130", "141"]
assert form.cleaned_data["policy_team"] == ["10", "11"]
assert form.cleaned_data["region"] == [
"3e6809d6-89f6-4590-8458-1d0dab73ad1a",
"5616ccf5-ab4a-4c2c-9624-13c69be3c46b",
Expand All @@ -128,6 +136,7 @@ def test_search_filters(self, mock_list):
"aa22c9d2-5f95-e211-a939-e4115bead28a"
),
category="130,141",
policy_team="10,11",
status="2",
user="1",
archived="0",
Expand Down
2 changes: 1 addition & 1 deletion tests/barriers/test_search_filter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BarrierSearchFilterValuesTestCase(MarketAccessTestCase):
form_class = BarrierSearchForm
parsed_checkboxes = None

excluded_fields = ["extra_location"]
excluded_fields = ["extra_location", "category"]

@classmethod
def generate_test_for_checkbox_values_equal_to_choices(cls, field_name):
Expand Down