-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DST-876 - Licensing - licensing grounds legal advisory not showing (#160
- Loading branch information
1 parent
8d466c3
commit 432e5b8
Showing
11 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from django.conf import settings | ||
from django.contrib.auth.models import User | ||
from django.contrib.sites.models import Site | ||
from django.db import IntegrityError | ||
from django.test import Client, RequestFactory | ||
from django.utils import timezone | ||
|
||
|
@@ -36,12 +37,15 @@ def vl_client(db) -> Client: | |
|
||
@pytest.fixture() | ||
def staff_user(db): | ||
return User.objects.create_user( | ||
"staff", | ||
"[email protected]", | ||
is_active=True, | ||
is_staff=True, | ||
) | ||
try: | ||
return User.objects.create_user( | ||
"staff", | ||
"[email protected]", | ||
is_active=True, | ||
is_staff=True, | ||
) | ||
except IntegrityError: | ||
return User.objects.get(username="staff") | ||
|
||
|
||
@pytest.fixture() | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
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,25 @@ | ||
import pytest | ||
from django.conf import settings | ||
|
||
from tests.test_frontend.conftest import PlaywrightTestBase as BasePlaywrightTestBase | ||
|
||
|
||
class PlaywrightTestBase(BasePlaywrightTestBase): | ||
@property | ||
def base_host(self) -> str: | ||
return settings.VIEW_A_LICENCE_DOMAIN.split(":")[0] | ||
|
||
|
||
@pytest.fixture(autouse=True, scope="function") | ||
def bypass_login(monkeypatch, staff_user): | ||
"""Overrides the get_user function to always return the staff user without authentication. | ||
Effectively bypasses the login process for all frontend tests. | ||
""" | ||
|
||
def patched_get_user(request): | ||
return staff_user | ||
|
||
monkeypatch.setattr("django.contrib.auth.get_user", patched_get_user) | ||
|
||
yield |
Empty file.
48 changes: 48 additions & 0 deletions
48
tests/test_frontend/test_view_a_licence/test_views/test_view_a_licence_application_view.py
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,48 @@ | ||
from apply_for_a_licence.choices import ( | ||
LicensingGroundsChoices, | ||
ProfessionalOrBusinessServicesChoices, | ||
TypeOfServicesChoices, | ||
WhoDoYouWantTheLicenceToCoverChoices, | ||
) | ||
from django.urls import reverse | ||
from playwright.sync_api import expect | ||
|
||
from tests.factories import LicenceFactory | ||
from tests.test_frontend.test_view_a_licence.conftest import PlaywrightTestBase | ||
|
||
|
||
class TestViewALicenceApplicationView(PlaywrightTestBase): | ||
def test_legal_grounds_legal_advisory(self): | ||
licence = LicenceFactory.create( | ||
who_do_you_want_the_licence_to_cover=WhoDoYouWantTheLicenceToCoverChoices.business.value, | ||
type_of_service=TypeOfServicesChoices.professional_and_business.value, | ||
professional_or_business_services=[ | ||
ProfessionalOrBusinessServicesChoices.legal_advisory.value, | ||
ProfessionalOrBusinessServicesChoices.architectural.value, | ||
], | ||
licensing_grounds=[LicensingGroundsChoices.energy.value], | ||
licensing_grounds_legal_advisory=[LicensingGroundsChoices.food.value, LicensingGroundsChoices.safety.value], | ||
) | ||
licence.assign_reference() | ||
licence.save() | ||
self.page.goto(self.base_url + reverse("view_a_licence:view_application", kwargs={"reference": licence.reference})) | ||
|
||
conditional_box = self.page.get_by_test_id("licensing-grounds-legal-advisory-box") | ||
expect(conditional_box).to_be_visible() | ||
assert "Licensing grounds (excluding legal advisory)" in conditional_box.text_content() | ||
assert LicensingGroundsChoices.food.label in conditional_box.text_content() | ||
assert LicensingGroundsChoices.safety.value in conditional_box.text_content() | ||
|
||
# now checking without legal advisory | ||
licence = LicenceFactory.create( | ||
who_do_you_want_the_licence_to_cover=WhoDoYouWantTheLicenceToCoverChoices.business.value, | ||
type_of_service=TypeOfServicesChoices.professional_and_business.value, | ||
professional_or_business_services=[ProfessionalOrBusinessServicesChoices.architectural.value], | ||
licensing_grounds=[LicensingGroundsChoices.energy.value], | ||
licensing_grounds_legal_advisory=None, | ||
) | ||
licence.assign_reference() | ||
licence.save() | ||
self.page.goto(self.base_url + reverse("view_a_licence:view_application", kwargs={"reference": licence.reference})) | ||
|
||
assert self.page.get_by_test_id("licensing-grounds-legal-advisory-box").count() == 0 |