diff --git a/caseworker/queues/views/cases.py b/caseworker/queues/views/cases.py index 48e5162a01..1a684a90cb 100644 --- a/caseworker/queues/views/cases.py +++ b/caseworker/queues/views/cases.py @@ -143,9 +143,11 @@ def get_params(self): if session_sort_by: params["sort_by"] = session_sort_by elif self.queue_pk == ALL_CASES_QUEUE_ID: - params["sort_by"] = "submitted_at" - else: + # newest to oldest params["sort_by"] = "-submitted_at" + else: + # oldest to newest + params["sort_by"] = "submitted_at" self.request.session["case_search_sort_by"] = params["sort_by"] diff --git a/core/forms/layouts.py b/core/forms/layouts.py index 6d77aa8ac5..a1e79ee273 100644 --- a/core/forms/layouts.py +++ b/core/forms/layouts.py @@ -90,11 +90,39 @@ class ConditionalCheckboxesQuestion(BaseConditionalQuestion): template = "%s/layout/conditional_checkboxes_question.html" +class F680ConditionalCheckboxesQuestion(ConditionalCheckboxesQuestion): + def render(self, bound_field, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs): + template = self.get_template_name(template_pack) + + mapped_choices = {choice[1]: choice for choice in bound_field.field.choices} + value = self.value + choice = mapped_choices[value] + position = list(mapped_choices.keys()).index(self.value) + + conditional_content = "" + for field in self.fields: + if field in form.declared_fields: + conditional_content += render_field( + field, form, form_style, context, template_pack=template_pack, **kwargs + ) + + context.update( + {"choice": choice, "field": bound_field, "position": position, "conditional_content": conditional_content} + ) + + return render_to_string(template, context.flatten()) + + class ConditionalCheckboxes(BaseConditional): question_class = ConditionalCheckboxesQuestion template = "%s/layout/conditional_checkboxes.html" +class F680ConditionalCheckboxes(BaseConditional): + question_class = F680ConditionalCheckboxesQuestion + template = "%s/layout/conditional_checkboxes.html" + + class ConditionalCheckbox(TemplateNameMixin): template = "%s/layout/conditional_checkbox.html" diff --git a/exporter/f680/application_sections/additional_information/__init__.py b/exporter/f680/application_sections/additional_information/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/exporter/f680/application_sections/additional_information/constants.py b/exporter/f680/application_sections/additional_information/constants.py new file mode 100644 index 0000000000..a1af1b72ab --- /dev/null +++ b/exporter/f680/application_sections/additional_information/constants.py @@ -0,0 +1,2 @@ +class FormSteps: + NOTES_FOR_CASEWORKER = "NOTES_FOR_CASEWORKER" diff --git a/exporter/f680/application_sections/additional_information/forms.py b/exporter/f680/application_sections/additional_information/forms.py new file mode 100644 index 0000000000..bcfffe0c5b --- /dev/null +++ b/exporter/f680/application_sections/additional_information/forms.py @@ -0,0 +1,17 @@ +from django import forms + +from core.common.forms import BaseForm + + +class NotesForCaseOfficerForm(BaseForm): + class Layout: + TITLE = "Notes" + SUBMIT_BUTTON_TEXT = "Save and continue" + + note = forms.CharField( + label="Add note", + widget=forms.Textarea(attrs={"cols": "80"}), + ) + + def get_layout_fields(self): + return ("note",) diff --git a/exporter/f680/application_sections/additional_information/tests/__init__.py b/exporter/f680/application_sections/additional_information/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/exporter/f680/application_sections/additional_information/tests/test_views.py b/exporter/f680/application_sections/additional_information/tests/test_views.py new file mode 100644 index 0000000000..60fb1eba0f --- /dev/null +++ b/exporter/f680/application_sections/additional_information/tests/test_views.py @@ -0,0 +1,153 @@ +import pytest + +from django.urls import reverse + +from core import client + +from ..forms import NotesForCaseOfficerForm +from ..constants import FormSteps + + +@pytest.fixture() +def unset_f680_feature_flag(settings): + settings.FEATURE_FLAG_ALLOW_F680 = False + + +@pytest.fixture(autouse=True) +def setup(mock_exporter_user_me, settings): + settings.FEATURE_FLAG_ALLOW_F680 = True + + +@pytest.fixture +def missing_application_id(): + return "6bb0828c-1520-4624-b729-7f3e6e5b9f5d" + + +@pytest.fixture +def missing_f680_application_wizard_url(missing_application_id): + return reverse( + "f680:additional_information:notes_wizard", + kwargs={"pk": missing_application_id}, + ) + + +@pytest.fixture +def f680_application_wizard_url(data_f680_case): + return reverse( + "f680:additional_information:notes_wizard", + kwargs={"pk": data_f680_case["id"]}, + ) + + +@pytest.fixture +def mock_f680_application_get_404(requests_mock, missing_application_id): + url = client._build_absolute_uri(f"/exporter/f680/application/{missing_application_id}/") + return requests_mock.get(url=url, json={}, status_code=404) + + +@pytest.fixture +def mock_f680_application_get(requests_mock, data_f680_case): + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.get(url=url, json=data_f680_case) + + +@pytest.fixture +def mock_f680_application_get_existing_data(requests_mock, data_f680_case): + data_f680_case["application"] = { + "additional_information": {"answers": {"note": "Some note text"}, "questions": {"note": "Add note"}} + } + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.get(url=url, json=data_f680_case) + + +@pytest.fixture +def mock_patch_f680_application(requests_mock, data_f680_case): + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.patch(url=url, json=data_f680_case) + + +@pytest.fixture +def post_to_step(post_to_step_factory, f680_application_wizard_url): + return post_to_step_factory(f680_application_wizard_url) + + +@pytest.fixture +def goto_step(goto_step_factory, f680_application_wizard_url): + return goto_step_factory(f680_application_wizard_url) + + +class TestAdditionalInformationView: + + def test_GET_no_application_404( + self, + authorized_client, + missing_f680_application_wizard_url, + mock_f680_application_get_404, + ): + response = authorized_client.get(missing_f680_application_wizard_url) + assert response.status_code == 404 + + def test_GET_success( + self, + authorized_client, + mock_f680_application_get, + f680_application_wizard_url, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert isinstance(response.context["form"], NotesForCaseOfficerForm) + + def test_GET_no_feature_flag_forbidden( + self, + authorized_client, + mock_f680_application_get, + f680_application_wizard_url, + unset_f680_feature_flag, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert response.context["title"] == "Forbidden" + + def test_POST_approval_type_and_submit_wizard_success( + self, post_to_step, goto_step, mock_f680_application_get, mock_patch_f680_application + ): + response = post_to_step( + FormSteps.NOTES_FOR_CASEWORKER, + {"note": "Some information"}, + ) + assert response.status_code == 302 + assert mock_patch_f680_application.called_once + assert mock_patch_f680_application.last_request.json() == { + "application": { + "name": "F680 Test 1", + "additional_information": {"answers": {"note": "Some information"}, "questions": {"note": "Add note"}}, + } + } + + def test_POST_to_step_validation_error( + self, + post_to_step, + goto_step, + mock_f680_application_get, + ): + goto_step(FormSteps.NOTES_FOR_CASEWORKER) + response = post_to_step( + FormSteps.NOTES_FOR_CASEWORKER, + {}, + ) + assert response.status_code == 200 + assert response.context["form"]["note"].errors == ["This field is required."] + + def test_GET_with_existing_data_success( + self, + authorized_client, + mock_f680_application_get_existing_data, + f680_application_wizard_url, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert isinstance(response.context["form"], NotesForCaseOfficerForm) + assert response.context["form"]["note"].initial == "Some note text" diff --git a/exporter/f680/application_sections/additional_information/urls.py b/exporter/f680/application_sections/additional_information/urls.py new file mode 100644 index 0000000000..4b8cb9daf7 --- /dev/null +++ b/exporter/f680/application_sections/additional_information/urls.py @@ -0,0 +1,10 @@ +from django.urls import path + +from . import views + + +app_name = "additional_information" + +urlpatterns = [ + path("notes/", views.NotesForCaseOfficersView.as_view(), name="notes_wizard"), +] diff --git a/exporter/f680/application_sections/additional_information/views.py b/exporter/f680/application_sections/additional_information/views.py new file mode 100644 index 0000000000..e5e4aa4d7b --- /dev/null +++ b/exporter/f680/application_sections/additional_information/views.py @@ -0,0 +1,11 @@ +from exporter.f680.application_sections.views import F680ApplicationSectionWizard + +from .constants import FormSteps +from .forms import NotesForCaseOfficerForm + + +class NotesForCaseOfficersView(F680ApplicationSectionWizard): + form_list = [ + (FormSteps.NOTES_FOR_CASEWORKER, NotesForCaseOfficerForm), + ] + section = "additional_information" diff --git a/exporter/f680/application_sections/approval_details/__init__.py b/exporter/f680/application_sections/approval_details/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/exporter/f680/application_sections/approval_details/constants.py b/exporter/f680/application_sections/approval_details/constants.py new file mode 100644 index 0000000000..8b460f0236 --- /dev/null +++ b/exporter/f680/application_sections/approval_details/constants.py @@ -0,0 +1,2 @@ +class FormSteps: + APPROVAL_TYPE = "APPROVAL_TYPE" diff --git a/exporter/f680/application_sections/approval_details/forms.py b/exporter/f680/application_sections/approval_details/forms.py new file mode 100644 index 0000000000..f1f1b0736a --- /dev/null +++ b/exporter/f680/application_sections/approval_details/forms.py @@ -0,0 +1,84 @@ +from django import forms +from django.db.models import TextChoices +from django.template.loader import render_to_string + +from crispy_forms_gds.layout.content import HTML + +from core.common.forms import BaseForm, TextChoice +from core.forms.layouts import F680ConditionalCheckboxes, F680ConditionalCheckboxesQuestion + + +class ApprovalTypeForm(BaseForm): + class Layout: + TITLE = "Select the types of approvals you need" + TITLE_AS_LABEL_FOR = "approval_choices" + SUBMIT_BUTTON_TEXT = "Save and continue" + + class ApprovalTypeChoices(TextChoices): + INITIAL_DISCUSSIONS_OR_PROMOTING = ( + "initial_discussion_or_promoting", + "Initial discussions or promoting products", + ) + DEMONSTRATION_IN_THE_UK = ( + "demonstration_in_uk", + "Demonstration in the United Kingdom to overseas customers", + ) + DEMONSTRATION_OVERSEAS = "demonstration_overseas", "Demonstration overseas" + TRAINING = "training", "Training" + THROUGH_LIFE_SUPPORT = "through_life_support", "Through life support" + SUPPLY = "supply", "Supply" + + ApprovalTypeChoices = ( + TextChoice(ApprovalTypeChoices.INITIAL_DISCUSSIONS_OR_PROMOTING), + TextChoice(ApprovalTypeChoices.DEMONSTRATION_IN_THE_UK), + TextChoice(ApprovalTypeChoices.DEMONSTRATION_OVERSEAS), + TextChoice(ApprovalTypeChoices.TRAINING), + TextChoice(ApprovalTypeChoices.THROUGH_LIFE_SUPPORT), + TextChoice(ApprovalTypeChoices.SUPPLY), + ) + + approval_choices = forms.MultipleChoiceField( + label=Layout.TITLE, + choices=(), + error_messages={ + "required": "Select an approval choice", + }, + widget=forms.CheckboxSelectMultiple(), + ) + + demonstration_in_uk = forms.CharField( + label="Explain what you are demonstrating and why", + help_text="Explain what materials will be involved and if you'll use a substitute product", + widget=forms.Textarea(attrs={"rows": 5}), + required=False, + ) + + demonstration_overseas = forms.CharField( + label="Explain what you are demonstrating and why", + help_text="Explain what materials will be involved and if you'll use a substitute product", + widget=forms.Textarea(attrs={"rows": 5}), + required=False, + ) + + approval_details_text = forms.CharField( + label="Provide details about what you're seeking approval to do", + widget=forms.Textarea(attrs={"rows": 5}), + required=False, + ) + + def __init__(self, *args, **kwargs): + self.conditional_checkbox_choices = ( + F680ConditionalCheckboxesQuestion(choices.label, choices.value) for choices in self.ApprovalTypeChoices + ) + super().__init__(*args, **kwargs) + self.fields["approval_choices"].choices = self.ApprovalTypeChoices + + def get_layout_fields(self): + return ( + F680ConditionalCheckboxes("approval_choices", *self.conditional_checkbox_choices), + "approval_details_text", + HTML.details( + "Help with exceptional circumstances", + render_to_string("f680/forms/help_with_approval_type.html"), + ), + ) diff --git a/exporter/f680/application_sections/approval_details/tests/__init__.py b/exporter/f680/application_sections/approval_details/tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/exporter/f680/application_sections/approval_details/tests/test_views.py b/exporter/f680/application_sections/approval_details/tests/test_views.py new file mode 100644 index 0000000000..4197f7f48b --- /dev/null +++ b/exporter/f680/application_sections/approval_details/tests/test_views.py @@ -0,0 +1,193 @@ +import pytest + +from django.urls import reverse + +from core import client + +from ..forms import ApprovalTypeForm +from ..constants import FormSteps + + +@pytest.fixture() +def unset_f680_feature_flag(settings): + settings.FEATURE_FLAG_ALLOW_F680 = False + + +@pytest.fixture(autouse=True) +def setup(mock_exporter_user_me, settings): + settings.FEATURE_FLAG_ALLOW_F680 = True + + +@pytest.fixture +def missing_application_id(): + return "6bb0828c-1520-4624-b729-7f3e6e5b9f5d" + + +@pytest.fixture +def missing_f680_application_wizard_url(missing_application_id): + return reverse( + "f680:approval_details:type_wizard", + kwargs={"pk": missing_application_id}, + ) + + +@pytest.fixture +def f680_application_wizard_url(data_f680_case): + return reverse( + "f680:approval_details:type_wizard", + kwargs={"pk": data_f680_case["id"]}, + ) + + +@pytest.fixture +def mock_f680_application_get_404(requests_mock, missing_application_id): + url = client._build_absolute_uri(f"/exporter/f680/application/{missing_application_id}/") + return requests_mock.get(url=url, json={}, status_code=404) + + +@pytest.fixture +def mock_f680_application_get(requests_mock, data_f680_case): + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.get(url=url, json=data_f680_case) + + +@pytest.fixture +def mock_f680_application_get_existing_data(requests_mock, data_f680_case): + data_f680_case["application"] = { + "approval_details": { + "answers": { + "approval_choices": [ + "initial_discussion_or_promoting", + "demonstration_in_uk", + "demonstration_overseas", + "training", + "through_life_support", + "supply", + ], + "demonstration_in_uk": "Test text 1", + "demonstration_overseas": "Test text 2", + }, + "questions": { + "approval_choices": None, + "demonstration_in_uk": "Explain what you are demonstrating and why", + "demonstration_overseas": "Explain what you are demonstrating and why", + }, + }, + } + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.get(url=url, json=data_f680_case) + + +@pytest.fixture +def mock_patch_f680_application(requests_mock, data_f680_case): + application_id = data_f680_case["id"] + url = client._build_absolute_uri(f"/exporter/f680/application/{application_id}/") + return requests_mock.patch(url=url, json=data_f680_case) + + +@pytest.fixture +def post_to_step(post_to_step_factory, f680_application_wizard_url): + return post_to_step_factory(f680_application_wizard_url) + + +@pytest.fixture +def goto_step(goto_step_factory, f680_application_wizard_url): + return goto_step_factory(f680_application_wizard_url) + + +class TestApprovalDetailsView: + + def test_GET_no_application_404( + self, + authorized_client, + missing_f680_application_wizard_url, + mock_f680_application_get_404, + ): + response = authorized_client.get(missing_f680_application_wizard_url) + assert response.status_code == 404 + + def test_GET_success( + self, + authorized_client, + mock_f680_application_get, + f680_application_wizard_url, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert isinstance(response.context["form"], ApprovalTypeForm) + + def test_GET_no_feature_flag_forbidden( + self, + authorized_client, + mock_f680_application_get, + f680_application_wizard_url, + unset_f680_feature_flag, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert response.context["title"] == "Forbidden" + + def test_POST_approval_type_and_submit_wizard_success( + self, post_to_step, goto_step, mock_f680_application_get, mock_patch_f680_application + ): + response = post_to_step( + FormSteps.APPROVAL_TYPE, + {"approval_choices": ["training", "supply"]}, + ) + assert response.status_code == 302 + assert mock_patch_f680_application.called_once + assert mock_patch_f680_application.last_request.json() == { + "application": { + "name": "F680 Test 1", + "approval_details": { + "answers": { + "approval_choices": ["training", "supply"], + "demonstration_in_uk": "", + "demonstration_overseas": "", + "approval_details_text": "", + }, + "questions": { + "approval_choices": "Select the types of approvals you need", + "demonstration_in_uk": "Explain what you are demonstrating and why", + "demonstration_overseas": "Explain what you are demonstrating and why", + "approval_details_text": "Provide details about what you're seeking approval to do", + }, + }, + } + } + + def test_POST_to_step_validation_error( + self, + post_to_step, + goto_step, + mock_f680_application_get, + ): + goto_step(FormSteps.APPROVAL_TYPE) + response = post_to_step( + FormSteps.APPROVAL_TYPE, + {}, + ) + assert response.status_code == 200 + assert "Select an approval choice" in response.context["form"]["approval_choices"].errors + + def test_GET_with_existing_data_success( + self, + authorized_client, + mock_f680_application_get_existing_data, + f680_application_wizard_url, + ): + response = authorized_client.get(f680_application_wizard_url) + assert response.status_code == 200 + assert isinstance(response.context["form"], ApprovalTypeForm) + assert response.context["form"]["approval_choices"].initial == [ + "initial_discussion_or_promoting", + "demonstration_in_uk", + "demonstration_overseas", + "training", + "through_life_support", + "supply", + ] + assert response.context["form"]["demonstration_in_uk"].initial == "Test text 1" + assert response.context["form"]["demonstration_overseas"].initial == "Test text 2" diff --git a/exporter/f680/application_sections/approval_details/urls.py b/exporter/f680/application_sections/approval_details/urls.py new file mode 100644 index 0000000000..32351c694b --- /dev/null +++ b/exporter/f680/application_sections/approval_details/urls.py @@ -0,0 +1,10 @@ +from django.urls import path + +from . import views + + +app_name = "approval_details" + +urlpatterns = [ + path("type/", views.ApprovalTypeView.as_view(), name="type_wizard"), +] diff --git a/exporter/f680/application_sections/approval_details/views.py b/exporter/f680/application_sections/approval_details/views.py new file mode 100644 index 0000000000..bfb4dfabc6 --- /dev/null +++ b/exporter/f680/application_sections/approval_details/views.py @@ -0,0 +1,10 @@ +from exporter.f680.application_sections.views import F680ApplicationSectionWizard +from .constants import FormSteps +from .forms import ApprovalTypeForm + + +class ApprovalTypeView(F680ApplicationSectionWizard): + form_list = [ + (FormSteps.APPROVAL_TYPE, ApprovalTypeForm), + ] + section = "approval_details" diff --git a/exporter/f680/constants.py b/exporter/f680/constants.py index 17ba9c48cd..452db76305 100644 --- a/exporter/f680/constants.py +++ b/exporter/f680/constants.py @@ -1,2 +1,6 @@ class ApplicationFormSteps: APPLICATION_NAME = "APPLICATION_NAME" + + +class ApprovalTypeSteps: + APPROVAL_TYPE = "APPROVAL_TYPE" diff --git a/exporter/f680/urls.py b/exporter/f680/urls.py index 8b35360176..070fd5cef4 100644 --- a/exporter/f680/urls.py +++ b/exporter/f680/urls.py @@ -12,4 +12,12 @@ "/general-application-details/", include("exporter.f680.application_sections.general_application_details.urls"), ), + path( + "/approval-details/", + include("exporter.f680.application_sections.approval_details.urls"), + ), + path( + "/additional-information/", + include("exporter.f680.application_sections.additional_information.urls"), + ), ] diff --git a/exporter/templates/core/registration/includes/address-details-uk.html b/exporter/templates/core/registration/includes/address-details-uk.html index 31f7903946..95dcd36551 100644 --- a/exporter/templates/core/registration/includes/address-details-uk.html +++ b/exporter/templates/core/registration/includes/address-details-uk.html @@ -36,7 +36,7 @@
- County or state + County
{{ registration_data.site.address.region}} diff --git a/exporter/templates/f680/forms/help_with_approval_type.html b/exporter/templates/f680/forms/help_with_approval_type.html new file mode 100644 index 0000000000..cca54b2402 --- /dev/null +++ b/exporter/templates/f680/forms/help_with_approval_type.html @@ -0,0 +1,21 @@ +

+ Initial discussions or promoting the products
+ Talking about or promoting your products to potential customers, including offering enhanced through life support to an existing customer. This can be in the UK or overseas. It includes meetings hosted by government organisations. + +

+

+ Product demonstrations in the UK or overseas
+ Carrying out a 'live' activity to showcase your products. Trials and evaluations count as demonstrations. You can demonstrate the actual products or substitutes. You must include any substitutes as products in your application. The demonstration can take place anywhere, but you must include all entities and locations in your application. +

+

+ Training
+ You do not need training approval to provide basic instructions for how to a use products. You do need training approval to teach operational employment of products, including tactics, techniques and procedures. Training can happen in the UK or overseas. +

+

+ Through life support
+ This covers all aspect of an export programme. It includes exporting and delivering products to a customer. It also includes all support offered throughout the life of products, such as maintenance, enhancements, obsolescence management and disposal. You must have a valid F680 throughout the life of the export programme. +

+

+ Supply
+ Content TBC needs to come from MOD as this is a new option. +

diff --git a/exporter/templates/f680/summary.html b/exporter/templates/f680/summary.html index edb384bef1..cc1994cde2 100644 --- a/exporter/templates/f680/summary.html +++ b/exporter/templates/f680/summary.html @@ -41,6 +41,46 @@

+

+ 2. + Complete approval details +

+
    +
  • +
    + Approval type + {% if application.application.approval_details %} +
    + Completed +
    + {% else %} +
    + Not Started +
    + {% endif %} +
    +
  • +
+

+ 4. + Additional Information +

+
    +
  • +
    + Notes for case officers + {% if application.application.additional_information.answers.note %} +
    + Completed +
    + {% else %} +
    + Not Started +
    + {% endif %} +
    +
  • +
diff --git a/unit_tests/caseworker/queues/views/test_cases.py b/unit_tests/caseworker/queues/views/test_cases.py index 518d657e6f..a4d81ab7a9 100644 --- a/unit_tests/caseworker/queues/views/test_cases.py +++ b/unit_tests/caseworker/queues/views/test_cases.py @@ -19,7 +19,7 @@ "queue_id": ["00000000-0000-0000-0000-000000000001"], "selected_tab": ["all_cases"], "hidden": ["true"], - "sort_by": ["submitted_at"], + "sort_by": ["-submitted_at"], } @@ -313,7 +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"], + "sort_by": ["submitted_at"], } @@ -620,7 +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"], + "sort_by": ["-submitted_at"], } in head_request_history @@ -655,7 +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"], + "sort_by": ["-submitted_at"], } @@ -684,7 +684,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab_name], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } head_request_history = [x.qs for x in mock_cases_search_head.request_history] assert { @@ -692,7 +692,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": ["all_cases"], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history tabs_with_hidden_param = ("my_cases", "open_queries") @@ -702,7 +702,7 @@ def test_tabs_on_team_queue( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history @@ -717,7 +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"], + "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") @@ -727,7 +727,7 @@ def test_tabs_on_team_queue_with_hidden_param( "page": ["1"], "queue_id": [queue_pk], "selected_tab": [tab], - "sort_by": ["-submitted_at"], + "sort_by": ["submitted_at"], } in head_request_history @@ -1156,8 +1156,8 @@ def test_product_search_is_visible_to_specific_users_only( def test_queue_view_sort_params_persist(authorized_client): response = authorized_client.get(reverse("core:index")) assert response.status_code == 200 - assert authorized_client.session["case_search_sort_by"] == "submitted_at" + assert authorized_client.session["case_search_sort_by"] == "-submitted_at" - authorized_client.get(reverse("core:index") + "?sort_by=-submitted_at") + authorized_client.get(reverse("core:index") + "?sort_by=submitted_at") assert response.status_code == 200 - assert authorized_client.session["case_search_sort_by"] == "-submitted_at" + assert authorized_client.session["case_search_sort_by"] == "submitted_at"