-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tests/www/apply/__snapshots__/test_process_outward_transfer.ambr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# serializer version: 1 | ||
# name: test_step_1[progress] | ||
''' | ||
<div class="c-stepper mb-4"> | ||
<div class="d-flex"> | ||
<div class="flex-fill"> | ||
<h2>Transférer la candidature de Jane DOE</h2> | ||
<div class="progress progress--emploi mb-3"> | ||
|
||
<div aria-valuemax="100" aria-valuemin="0" aria-valuenow="25" class="progress-bar progress-bar-25" role="progressbar"> | ||
</div> | ||
|
||
</div> | ||
|
||
<span>Rechercher un emploi inclusif</span> | ||
|
||
</div> | ||
<div class="d-flex justify-content-end"> | ||
<a class="btn btn-link btn-ico" href="/apply/11111111-1111-1111-1111-111111111111/siae/details"> | ||
<i aria-hidden="true" class="ri-close-line"></i> | ||
<span>Quitter</span> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
''' | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import pytest | ||
from django.template.defaultfilters import urlencode | ||
from django.urls import reverse | ||
from pytest_django.asserts import assertContains, assertNotContains | ||
|
||
from itou.job_applications.enums import JobApplicationState | ||
from tests.cities.factories import create_city_guerande, create_city_vannes | ||
from tests.companies.factories import CompanyFactory, JobDescriptionFactory | ||
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 | ||
|
||
|
||
@pytest.mark.parametrize("state", JobApplicationState) | ||
def test_step_1_status_checks(client, state): | ||
job_application = JobApplicationFactory(state=state) | ||
employer = job_application.to_company.members.get() | ||
client.force_login(employer) | ||
response = client.get( | ||
reverse("apply:job_application_outward_transfer_step_1", kwargs={"job_application_id": job_application.pk}) | ||
) | ||
assert response.status_code == (200 if state == JobApplicationState.REFUSED else 404) | ||
|
||
|
||
def test_step_1(client, snapshot): | ||
# Create other companies | ||
create_test_romes_and_appellations(["N1101"], appellations_per_rome=1) | ||
vannes = create_city_vannes() | ||
COMPANY_VANNES = "Entreprise Vannes" | ||
other_company = CompanyFactory(name=COMPANY_VANNES, coords=vannes.coords, post_code="56760", with_membership=True) | ||
job = JobDescriptionFactory(company=other_company) | ||
|
||
guerande = create_city_guerande() | ||
COMPANY_GUERANDE = "Entreprise Guérande" | ||
CompanyFactory(name=COMPANY_GUERANDE, coords=guerande.coords, post_code="44350") | ||
|
||
# create job application to transfer | ||
job_application = JobApplicationFactory( | ||
state=JobApplicationState.REFUSED, | ||
for_snapshot=True, | ||
to_company__post_code="56760", | ||
to_company__coords=vannes.coords, | ||
to_company__city=vannes.name, | ||
) | ||
employer = job_application.to_company.members.get() | ||
client.force_login(employer) | ||
|
||
# Go th step 1 | ||
transfer_step_1_url = reverse( | ||
"apply:job_application_outward_transfer_step_1", kwargs={"job_application_id": job_application.pk} | ||
) | ||
response = client.get(transfer_step_1_url) | ||
assert str(parse_response_to_soup(response, ".c-stepper")) == snapshot(name="progress") | ||
|
||
# search is centered on job app company city : only vannes companies should be displayed | ||
assertContains( | ||
response, | ||
'<p class="mb-0"><strong>2 résultats</strong></p>', | ||
html=True, | ||
count=1, | ||
) | ||
assertContains(response, other_company.name.capitalize()) | ||
assertContains(response, job_application.to_company.name.capitalize()) | ||
assertNotContains(response, "Postuler") | ||
assertContains( | ||
response, | ||
"<span>Transférer la candidature</span>", | ||
count=2, | ||
) | ||
|
||
# Check outgoing links | ||
transfer_step_2_base_url = reverse( | ||
"apply:job_application_outward_transfer_step_2", | ||
kwargs={"job_application_id": job_application.pk, "company_pk": other_company.pk}, | ||
) | ||
assertContains( | ||
response, | ||
f"{transfer_step_2_base_url}?back_url={urlencode(transfer_step_1_url)}", | ||
count=1, | ||
) | ||
|
||
company_card_url = ( | ||
reverse("companies_views:card", kwargs={"siae_id": other_company.pk}) | ||
+ f"?back_url={urlencode(transfer_step_1_url)}" | ||
) | ||
assertContains(response, company_card_url, count=1) | ||
|
||
job_card_url = ( | ||
reverse("companies_views:job_description_card", kwargs={"job_description_id": job.pk}) | ||
+ f"?back_url={urlencode(transfer_step_1_url)}" | ||
) | ||
assertContains(response, job_card_url, count=1) | ||
|
||
# Check company card | ||
response = client.get(company_card_url) | ||
assert str(parse_response_to_soup(response, ".c-stepper")) == snapshot(name="progress") | ||
assertContains( | ||
response, | ||
f"{transfer_step_2_base_url}?back_url={urlencode(company_card_url)}", | ||
count=2, | ||
) | ||
assertContains(response, job_card_url, count=1) | ||
assertNotContains(response, "Postuler") | ||
assertContains( | ||
response, | ||
"<span>Transférer la candidature</span>", | ||
count=2, | ||
) | ||
|
||
# Check job description card | ||
response = client.get(job_card_url) | ||
assert str(parse_response_to_soup(response, ".c-stepper")) == snapshot(name="progress") | ||
assertContains( | ||
response, | ||
f"{transfer_step_2_base_url}?job_description_id={job.pk}&back_url={urlencode(job_card_url)}", | ||
count=1, | ||
) | ||
assertContains(response, company_card_url, count=1) | ||
assertNotContains(response, "Postuler") | ||
assertContains( | ||
response, | ||
"<span>Transférer la candidature</span>", | ||
count=1, | ||
) | ||
|
||
|
||
def test_step_2_same_company(): | ||
pass | ||
|
||
|
||
def test_step_2_inward_transfer(): | ||
pass |