From 89fbfb4d6a213c73a6a3bb7b1c58cd46fc00142b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Mon, 13 Jan 2025 11:33:57 +0100 Subject: [PATCH 1/2] tests: Pair job description apply term with positive assertions --- tests/www/apply/test_process_external_transfer.py | 7 ++++--- tests/www/companies_views/test_job_description_views.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/www/apply/test_process_external_transfer.py b/tests/www/apply/test_process_external_transfer.py index b18afd69b6..e759ff8cbd 100644 --- a/tests/www/apply/test_process_external_transfer.py +++ b/tests/www/apply/test_process_external_transfer.py @@ -15,6 +15,7 @@ from tests.job_applications.factories import JobApplicationFactory from tests.jobs.factories import create_test_romes_and_appellations from tests.utils.test import parse_response_to_soup +from tests.www.companies_views.test_job_description_views import POSTULER INTERNAL_TRANSFER_CONFIRM_BUTTON = """ @@ -96,7 +97,7 @@ def test_step_1(client, snapshot): ) assertContains(response, other_company.name.capitalize()) assertContains(response, job_application.to_company.name.capitalize()) - assertNotContains(response, "Postuler") + assertNotContains(response, POSTULER) assertContains( response, "Transférer la candidature", @@ -141,7 +142,7 @@ def test_step_1(client, snapshot): count=2, ) assertContains(response, job_card_url, count=1) - assertNotContains(response, "Postuler") + assertNotContains(response, POSTULER) assertContains( response, "Transférer la candidature", @@ -157,7 +158,7 @@ def test_step_1(client, snapshot): count=1, ) assertContains(response, company_card_url, count=1) - assertNotContains(response, "Postuler") + assertNotContains(response, POSTULER) assertContains( response, "Transférer la candidature", diff --git a/tests/www/companies_views/test_job_description_views.py b/tests/www/companies_views/test_job_description_views.py index ac17b34689..cfebfc33d2 100644 --- a/tests/www/companies_views/test_job_description_views.py +++ b/tests/www/companies_views/test_job_description_views.py @@ -19,6 +19,9 @@ from tests.utils.test import assertSnapshotQueries +POSTULER = "Postuler" + + class JobDescriptionAbstract: @pytest.fixture(autouse=True) def abstract_setup_method(self): @@ -608,7 +611,7 @@ def test_prescriber_card_actions(self, client, snapshot): with assertSnapshotQueries(snapshot): response = client.get(self.url) - assertContains(response, "Postuler auprès de l'employeur inclusif") + assertContains(response, f"{POSTULER} auprès de l'employeur inclusif") assertContains(response, self.apply_start_url(self.company)) assertNotContains( response, @@ -621,14 +624,14 @@ def test_job_seeker_card_actions(self, client, snapshot): with assertSnapshotQueries(snapshot): response = client.get(self.url) - assertContains(response, "Postuler auprès de l'employeur inclusif") + assertContains(response, f"{POSTULER} auprès de l'employeur inclusif") assertContains(response, self.apply_start_url(self.company)) assertNotContains(response, self.update_job_description_url(self.job_description)) def test_anonymous_card_actions(self, client): response = client.get(self.url) - assertContains(response, "Postuler auprès de l'employeur inclusif") + assertContains(response, f"{POSTULER} auprès de l'employeur inclusif") assertContains(response, self.apply_start_url(self.company)) assertNotContains(response, self.update_job_description_url(self.job_description)) From cb4a02158b88e2d12cc4bac47a6654aa76f50fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 5 Nov 2024 10:14:36 +0100 Subject: [PATCH 2/2] Hide Edit button from job desc page when transferring to self MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transferring applications to one of my companies should go through internal transfer instead of external transfer. However, when a user does an external transfer and selects a job description from one of their companies, they shouldn’t be offered to modify that job description, but instead to transfer the application. --- itou/www/apply/views/process_views.py | 1 + .../apply/test_process_external_transfer.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/itou/www/apply/views/process_views.py b/itou/www/apply/views/process_views.py index a9c20f3e70..fbb81af73b 100644 --- a/itou/www/apply/views/process_views.py +++ b/itou/www/apply/views/process_views.py @@ -737,6 +737,7 @@ def get_context_data(self, **kwargs): return data | { "job_app_to_transfer": self.job_application, "matomo_custom_title": data["matomo_custom_title"] + " (transfert)", + "can_update_job_description": False, } diff --git a/tests/www/apply/test_process_external_transfer.py b/tests/www/apply/test_process_external_transfer.py index e759ff8cbd..555a6f4c31 100644 --- a/tests/www/apply/test_process_external_transfer.py +++ b/tests/www/apply/test_process_external_transfer.py @@ -166,6 +166,34 @@ def test_step_1(client, snapshot): ) +def test_step_1_same_company(client): + create_test_romes_and_appellations(["N1101"], appellations_per_rome=1) + vannes = create_city_vannes() + company = CompanyFactory(coords=vannes.coords, post_code="56760", with_membership=True) + job = JobDescriptionFactory(company=company) + + job_application = JobApplicationFactory(state=JobApplicationState.REFUSED, to_company=company) + employer = job_application.to_company.members.get() + client.force_login(employer) + + response = client.get( + reverse( + "apply:job_application_external_transfer_step_1_job_description_card", + kwargs={"job_application_id": job_application.pk, "job_description_id": job.pk}, + ) + ) + assertNotContains(response, POSTULER) + assertContains( + response, + "Transférer la candidature", + count=1, + ) + assertNotContains( + response, + reverse("companies_views:update_job_description", kwargs={"job_description_id": job.pk}), + ) + + def test_step_2_same_company(client): job_application = JobApplicationFactory(state=JobApplicationState.REFUSED, for_snapshot=True) company = job_application.to_company