From 218a5445a45ede12481a63f4b6a409874d1a14d9 Mon Sep 17 00:00:00 2001 From: Xavier Fernandez Date: Mon, 27 Jan 2025 11:43:55 +0100 Subject: [PATCH] apply: make table view the default for prescribers --- itou/www/apply/views/list_views.py | 2 +- tests/www/apply/__snapshots__/test_list.ambr | 12 ++++----- tests/www/apply/test_list.py | 2 +- tests/www/apply/test_list_prescriptions.py | 27 ++++++++++++-------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/itou/www/apply/views/list_views.py b/itou/www/apply/views/list_views.py index 80a666f2774..11e3bf9c7c5 100644 --- a/itou/www/apply/views/list_views.py +++ b/itou/www/apply/views/list_views.py @@ -206,7 +206,7 @@ def list_prescriptions(request, template_name="apply/list_prescriptions.html"): try: display_kind = JobApplicationsDisplayKind(request.GET.get("display")) except ValueError: - display_kind = JobApplicationsDisplayKind.LIST + display_kind = JobApplicationsDisplayKind.TABLE context = { "title": title, diff --git a/tests/www/apply/__snapshots__/test_list.ambr b/tests/www/apply/__snapshots__/test_list.ambr index 540da099deb..3562eb6637f 100644 --- a/tests/www/apply/__snapshots__/test_list.ambr +++ b/tests/www/apply/__snapshots__/test_list.ambr @@ -244,7 +244,7 @@ chez - + Hit pit @@ -298,7 +298,7 @@
- Voir sa candidature + Voir sa candidature
@@ -321,7 +321,7 @@ chez - + Hit pit @@ -380,7 +380,7 @@

- Voir sa candidature + Voir sa candidature @@ -403,7 +403,7 @@ chez - + Hit pit @@ -462,7 +462,7 @@

- Voir sa candidature + Voir sa candidature diff --git a/tests/www/apply/test_list.py b/tests/www/apply/test_list.py index f4e86d9a3b3..498081b4671 100644 --- a/tests/www/apply/test_list.py +++ b/tests/www/apply/test_list.py @@ -57,7 +57,7 @@ def test_list_warns_about_long_awaiting_applications(client, snapshot): assert str(results_section) == snapshot(name="SIAE - warnings for 2222 and 3333") client.force_login(sender) - response = client.get(reverse("apply:list_prescriptions")) + response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST}) results_section = parse_response_to_soup(response, selector="#job-applications-section") assert str(results_section) == snapshot(name="PRESCRIBER - warnings for 2222 and 3333") diff --git a/tests/www/apply/test_list_prescriptions.py b/tests/www/apply/test_list_prescriptions.py index 5de1f365c6a..d0afee046aa 100644 --- a/tests/www/apply/test_list_prescriptions.py +++ b/tests/www/apply/test_list_prescriptions.py @@ -45,7 +45,7 @@ def test_get(client): organization = job_application.sender_prescriber_organization client.force_login(job_application.sender) - response = client.get(reverse("apply:list_prescriptions")) + response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST}) # Has link to export with back_url set exports_link = unquote( add_url_params(reverse("apply:list_prescriptions_exports"), {"back_url": reverse("apply:list_prescriptions")}) @@ -95,7 +95,7 @@ def test_as_unauthorized_prescriber(client, snapshot): list_url = reverse("apply:list_prescriptions") with assertSnapshotQueries(snapshot(name="SQL queries for prescriptions list")): - response = client.get(list_url) + response = client.get(list_url, {"display": JobApplicationsDisplayKind.LIST}) assertContains(response, "

S… U…

") assertNotContains(response, "Supersecretname") @@ -224,8 +224,8 @@ def test_list_display_kind(client): LIST_VIEW_MARKER = '
' for display_param, expected_marker in [ - ({}, LIST_VIEW_MARKER), - ({"display": "invalid"}, LIST_VIEW_MARKER), + ({}, TABLE_VIEW_MARKER), + ({"display": "invalid"}, TABLE_VIEW_MARKER), ({"display": JobApplicationsDisplayKind.LIST}, LIST_VIEW_MARKER), ({"display": JobApplicationsDisplayKind.TABLE}, TABLE_VIEW_MARKER), ]: @@ -240,7 +240,7 @@ def test_list_display_kind(client): def test_filters(client, snapshot): client.force_login(PrescriberFactory()) - response = client.get(reverse("apply:list_prescriptions")) + response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST}) assert response.status_code == 200 filter_form = parse_response_to_soup(response, "#offcanvasApplyFilters") assert str(filter_form) == snapshot() @@ -260,24 +260,29 @@ def test_archived(client): """ client.force_login(prescriber) + filter_params = {"display": JobApplicationsDisplayKind.LIST} url = reverse("apply:list_prescriptions") - response = client.get(url) + response = client.get(url, data=filter_params) assertContains(response, active.pk) assertNotContains(response, archived.pk) assertNotContains(response, archived_badge_html, html=True) - response = client.get(url, data={"archived": ""}) + filter_params["archived"] = "" + response = client.get(url, data=filter_params) assertContains(response, active.pk) assertNotContains(response, archived.pk) assertNotContains(response, archived_badge_html, html=True) - response = client.get(url, data={"archived": "archived"}) + filter_params["archived"] = "archived" + response = client.get(url, data=filter_params) assertNotContains(response, active.pk) assertContains(response, archived.pk) assertContains(response, archived_badge_html, html=True, count=1) - response = client.get(url, data={"archived": "all"}) + filter_params["archived"] = "all" + response = client.get(url, data=filter_params) assertContains(response, active.pk) assertContains(response, archived.pk) assertContains(response, archived_badge_html, html=True, count=1) - response = client.get(url, data={"archived": "invalid"}) + filter_params["archived"] = "invalid" + response = client.get(url, data=filter_params) assertContains(response, active.pk) assertContains(response, archived.pk) assertContains(response, archived_badge_html, html=True, count=1) @@ -531,7 +536,7 @@ def test_reset_filter_button_snapshot(client, snapshot): job_application = JobApplicationFactory() client.force_login(job_application.sender) - filter_params = {"states": [job_application.state]} + filter_params = {"states": [job_application.state], "display": JobApplicationsDisplayKind.LIST} response = client.get(reverse("apply:list_prescriptions"), filter_params) assert str(parse_response_to_soup(response, selector="#apply-list-filter-counter")) == snapshot(