mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-28 11:10:36 +02:00
Merge branch 'main' into nl/1895-CISA-regions-questions-domain-req
This commit is contained in:
commit
05b6bcd181
16 changed files with 465 additions and 31 deletions
|
@ -21,7 +21,16 @@ from registrar.admin import (
|
|||
UserDomainRoleAdmin,
|
||||
VerifiedByStaffAdmin,
|
||||
)
|
||||
from registrar.models import Domain, DomainRequest, DomainInformation, User, DomainInvitation, Contact, Website
|
||||
from registrar.models import (
|
||||
Domain,
|
||||
DomainRequest,
|
||||
DomainInformation,
|
||||
User,
|
||||
DomainInvitation,
|
||||
Contact,
|
||||
Website,
|
||||
DraftDomain,
|
||||
)
|
||||
from registrar.models.user_domain_role import UserDomainRole
|
||||
from registrar.models.verified_by_staff import VerifiedByStaff
|
||||
from .common import (
|
||||
|
@ -697,6 +706,126 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
)
|
||||
self.mock_client = MockSESClient()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_analyst_can_see_and_edit_alternative_domain(self):
|
||||
"""Tests if an analyst can still see and edit the alternative domain field"""
|
||||
|
||||
# Create fake creator
|
||||
_creator = User.objects.create(
|
||||
username="MrMeoward",
|
||||
first_name="Meoward",
|
||||
last_name="Jones",
|
||||
)
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
|
||||
|
||||
fake_website = Website.objects.create(website="thisisatest.gov")
|
||||
_domain_request.alternative_domains.add(fake_website)
|
||||
_domain_request.save()
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the alternative domain
|
||||
self.assertContains(response, "thisisatest.gov")
|
||||
|
||||
# Check that the page contains the url we expect
|
||||
expected_href = reverse("admin:registrar_website_change", args=[fake_website.id])
|
||||
self.assertContains(response, expected_href)
|
||||
|
||||
# Navigate to the website to ensure that we can still edit it
|
||||
response = self.client.get(
|
||||
"/admin/registrar/website/{}/change/".format(fake_website.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "thisisatest.gov")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_analyst_can_see_and_edit_requested_domain(self):
|
||||
"""Tests if an analyst can still see and edit the requested domain field"""
|
||||
|
||||
# Create fake creator
|
||||
_creator = User.objects.create(
|
||||
username="MrMeoward",
|
||||
first_name="Meoward",
|
||||
last_name="Jones",
|
||||
)
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Filter to get the latest from the DB (rather than direct assignment)
|
||||
requested_domain = DraftDomain.objects.filter(name=_domain_request.requested_domain.name).get()
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, requested_domain.name)
|
||||
|
||||
# Check that the page contains the url we expect
|
||||
expected_href = reverse("admin:registrar_draftdomain_change", args=[requested_domain.id])
|
||||
self.assertContains(response, expected_href)
|
||||
|
||||
# Navigate to the website to ensure that we can still edit it
|
||||
response = self.client.get(
|
||||
"/admin/registrar/draftdomain/{}/change/".format(requested_domain.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "city.gov")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_analyst_can_see_current_websites(self):
|
||||
"""Tests if an analyst can still see current website field"""
|
||||
|
||||
# Create fake creator
|
||||
_creator = User.objects.create(
|
||||
username="MrMeoward",
|
||||
first_name="Meoward",
|
||||
last_name="Jones",
|
||||
)
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
|
||||
|
||||
fake_website = Website.objects.create(website="thisisatest.gov")
|
||||
_domain_request.current_websites.add(fake_website)
|
||||
_domain_request.save()
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the current website
|
||||
self.assertContains(response, "thisisatest.gov")
|
||||
|
||||
def test_domain_sortable(self):
|
||||
"""Tests if the DomainRequest sorts by domain correctly"""
|
||||
with less_console_noise():
|
||||
|
@ -1547,6 +1676,10 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
# Test for the copy link
|
||||
self.assertContains(response, "usa-button__clipboard", count=4)
|
||||
|
||||
# Test that Creator counts display properly
|
||||
self.assertNotContains(response, "Approved domains")
|
||||
self.assertContains(response, "Active requests")
|
||||
|
||||
def test_save_model_sets_restricted_status_on_user(self):
|
||||
with less_console_noise():
|
||||
# make sure there is no user with this email
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue