Skip to content

Commit

Permalink
fixed bug for search term removal and added test case in e2e_tests/te…
Browse files Browse the repository at this point in the history
…st_search.py
  • Loading branch information
pgandhizaizi authored and anthonyhashemi committed Mar 28, 2024
1 parent 2c745b0 commit f1c0e12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/templates/main/search-transferring-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ <h3 class="govuk-heading-s govuk-heading-s--search-term">Search terms applied</h
{% set new_query = filters['query'].replace(',' ~ search_terms[i],'') %}
{% endif %}
{% if search_terms | length == 1 %}
{% set search_term_url = url_for('main.search_transferring_body', _id = request.view_args['_id']) %}
{% set search_term_url = url_for('main.browse_transferring_body', _id = request.view_args['_id']) %}
{% else %}
{% set search_term_url = url_for('main.search_transferring_body', _id = request.view_args['_id'], query=new_query) %}
{% endif %}
Expand Down
19 changes: 19 additions & 0 deletions e2e_tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,25 @@ def test_search_transferring_body_search_multiple_terms(
verify_search_transferring_body_header_row(header_rows)
assert rows == expected_rows

def test_search_transferring_body_remove_all_terms_redirect_to_browse_transferring_body(
self, aau_user_page: Page
):
"""
Given a user on the search transferring body page
When they interact with the search form and submit a query with a search term
and then remove the search term
Then they should be redirected to browse transferring body page.
"""
aau_user_page.goto(f"{self.browse_route_url}")
aau_user_page.locator("#search-input").click()
aau_user_page.locator("#search-input").fill("dtp")
aau_user_page.get_by_role("button", name="Search").click()
aau_user_page.get_by_role("link", name="Testing A").click()
aau_user_page.get_by_role("link", name="dtp", exact=True).click()

url = f"{self.browse_transferring_body_route_url}/{self.transferring_body_id}"
expect(aau_user_page).to_have_url(url)

def test_search_transferring_body_aau_user_and_click_on_clear_all(
self, aau_user_page: Page
):
Expand Down

0 comments on commit f1c0e12

Please sign in to comment.