Skip to content

Commit

Permalink
Always pass through a sort by field for cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincarrogan committed Feb 14, 2025
1 parent 413c16f commit aa45f75
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions caseworker/queues/views/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ def get_params(self):
if params.get("return_to"):
del params["return_to"]

if not params.get("sort_by"):
# There is a default sort on the API side but we're overriding this
# here so that we control the sorting on the frontend
if self.queue_pk == ALL_CASES_QUEUE_ID:
params["sort_by"] = "submitted_at"
else:
params["sort_by"] = "-submitted_at"

return params

def _set_is_hidden(self, tab_name, is_hidden_by_form):
Expand Down
9 changes: 9 additions & 0 deletions unit_tests/caseworker/queues/views/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"queue_id": ["00000000-0000-0000-0000-000000000001"],
"selected_tab": ["all_cases"],
"hidden": ["true"],
"sort_by": ["submitted_at"],
}


Expand Down Expand Up @@ -312,6 +313,7 @@ def test_cases_queue_page_assigned_queues(authorized_client, mock_cases_search_t
"queue_id": [queue_pk],
"selected_tab": ["all_cases"],
"hidden": ["false"],
"sort_by": ["-submitted_at"],
}


Expand Down Expand Up @@ -618,6 +620,7 @@ def test_tabs_with_all_cases_default(authorized_client, mock_cases_search, mock_
"page": ["1"],
"queue_id": ["00000000-0000-0000-0000-000000000001"],
"selected_tab": [tab],
"sort_by": ["submitted_at"],
} in head_request_history


Expand Down Expand Up @@ -652,6 +655,7 @@ def test_tabs_on_all_cases_queue(authorized_client, mock_cases_search, tab_name,
"page": ["1"],
"queue_id": ["00000000-0000-0000-0000-000000000001"],
"selected_tab": [tab_name],
"sort_by": ["submitted_at"],
}


Expand Down Expand Up @@ -680,13 +684,15 @@ def test_tabs_on_team_queue(
"page": ["1"],
"queue_id": [queue_pk],
"selected_tab": [tab_name],
"sort_by": ["-submitted_at"],
}
head_request_history = [x.qs for x in mock_cases_search_head.request_history]
assert {
"hidden": ["false"],
"page": ["1"],
"queue_id": [queue_pk],
"selected_tab": ["all_cases"],
"sort_by": ["-submitted_at"],
} in head_request_history

tabs_with_hidden_param = ("my_cases", "open_queries")
Expand All @@ -696,6 +702,7 @@ def test_tabs_on_team_queue(
"page": ["1"],
"queue_id": [queue_pk],
"selected_tab": [tab],
"sort_by": ["-submitted_at"],
} in head_request_history


Expand All @@ -710,6 +717,7 @@ def test_tabs_on_team_queue_with_hidden_param(
"page": ["1"],
"queue_id": [queue_pk],
"selected_tab": ["all_cases"],
"sort_by": ["-submitted_at"],
}
head_request_history = [x.qs for x in mock_cases_search_head.request_history]
tabs_with_hidden_param = ("all_cases", "my_cases", "open_queries")
Expand All @@ -719,6 +727,7 @@ def test_tabs_on_team_queue_with_hidden_param(
"page": ["1"],
"queue_id": [queue_pk],
"selected_tab": [tab],
"sort_by": ["-submitted_at"],
} in head_request_history


Expand Down

0 comments on commit aa45f75

Please sign in to comment.