diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html
index 6d67925bc..09fc189e4 100644
--- a/src/registrar/templates/domain_detail.html
+++ b/src/registrar/templates/domain_detail.html
@@ -17,9 +17,10 @@
Status:
- {% if domain.is_expired %}
+ {# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
+ {% if domain.is_expired and domain.state != domain.State.UNKNOWN %}
Expired
- {% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED%}
+ {% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %}
DNS needed
{% else %}
{{ domain.state|title }}
diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html
index 15835920b..138f83e04 100644
--- a/src/registrar/templates/home.html
+++ b/src/registrar/templates/home.html
@@ -52,9 +52,10 @@
Domains
{{ domain.expiration_date|date }} |
- {% if domain.is_expired %}
+ {# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
+ {% if domain.is_expired and domain.state != domain.State.UNKNOWN %}
Expired
- {% elif domain.state == "unknown" or domain.state == "dns needed"%}
+ {% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %}
DNS needed
{% else %}
{{ domain.state|title }}
diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py
index d0e58491a..cc9b1d9f6 100644
--- a/src/registrar/tests/test_views.py
+++ b/src/registrar/tests/test_views.py
@@ -35,6 +35,8 @@
User,
)
from registrar.views.application import ApplicationWizard, Step
+from datetime import date, datetime, timedelta
+from django.utils import timezone
from .common import less_console_noise
@@ -94,18 +96,6 @@ def test_home_lists_domain_applications(self):
# clean up
application.delete()
- def test_home_lists_domains(self):
- response = self.client.get("/")
- domain, _ = Domain.objects.get_or_create(name="igorville.gov")
- self.assertNotContains(response, "igorville.gov")
- role, _ = UserDomainRole.objects.get_or_create(user=self.user, domain=domain, role=UserDomainRole.Roles.MANAGER)
- response = self.client.get("/")
- # count = 2 because it is also in screenreader content
- self.assertContains(response, "igorville.gov", count=2)
- self.assertContains(response, "Expired")
- # clean up
- role.delete()
-
def test_application_form_view(self):
response = self.client.get("/register/", follow=True)
self.assertContains(
@@ -1605,8 +1595,20 @@ def setUp(self):
self.domain_with_ip, _ = Domain.objects.get_or_create(name="nameserverwithip.gov")
self.domain_just_nameserver, _ = Domain.objects.get_or_create(name="justnameserver.com")
self.domain_no_information, _ = Domain.objects.get_or_create(name="noinformation.gov")
- self.domain_on_hold, _ = Domain.objects.get_or_create(name="on-hold.gov", state=Domain.State.ON_HOLD)
- self.domain_deleted, _ = Domain.objects.get_or_create(name="deleted.gov", state=Domain.State.DELETED)
+ self.domain_on_hold, _ = Domain.objects.get_or_create(
+ name="on-hold.gov",
+ state=Domain.State.ON_HOLD,
+ expiration_date=timezone.make_aware(
+ datetime.combine(date.today() + timedelta(days=1), datetime.min.time())
+ ),
+ )
+ self.domain_deleted, _ = Domain.objects.get_or_create(
+ name="deleted.gov",
+ state=Domain.State.DELETED,
+ expiration_date=timezone.make_aware(
+ datetime.combine(date.today() + timedelta(days=1), datetime.min.time())
+ ),
+ )
self.domain_dsdata, _ = Domain.objects.get_or_create(name="dnssec-dsdata.gov")
self.domain_multdsdata, _ = Domain.objects.get_or_create(name="dnssec-multdsdata.gov")
@@ -1754,6 +1756,49 @@ def test_domain_detail_link_works(self):
self.assertContains(detail_page, "igorville.gov")
self.assertContains(detail_page, "Status")
+ def test_unknown_domain_does_not_show_as_expired_on_homepage(self):
+ """An UNKNOWN domain does not show as expired on the homepage.
+ It shows as 'DNS needed'"""
+ # At the time of this test's writing, there are 6 UNKNOWN domains inherited
+ # from constructors. Let's reset.
+ Domain.objects.all().delete()
+ UserDomainRole.objects.all().delete()
+ self.domain, _ = Domain.objects.get_or_create(name="igorville.gov")
+ home_page = self.app.get("/")
+ self.assertNotContains(home_page, "igorville.gov")
+ self.role, _ = UserDomainRole.objects.get_or_create(
+ user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
+ )
+ home_page = self.app.get("/")
+ self.assertContains(home_page, "igorville.gov")
+ igorville = Domain.objects.get(name="igorville.gov")
+ self.assertEquals(igorville.state, Domain.State.UNKNOWN)
+ self.assertNotContains(home_page, "Expired")
+ self.assertContains(home_page, "DNS needed")
+
+ def test_unknown_domain_does_not_show_as_expired_on_detail_page(self):
+ """An UNKNOWN domain does not show as expired on the detail page.
+ It shows as 'DNS needed'"""
+ # At the time of this test's writing, there are 6 UNKNOWN domains inherited
+ # from constructors. Let's reset.
+ Domain.objects.all().delete()
+ UserDomainRole.objects.all().delete()
+
+ self.domain, _ = Domain.objects.get_or_create(name="igorville.gov")
+ self.domain_information, _ = DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain)
+ self.role, _ = UserDomainRole.objects.get_or_create(
+ user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER
+ )
+
+ home_page = self.app.get("/")
+ self.assertContains(home_page, "igorville.gov")
+ igorville = Domain.objects.get(name="igorville.gov")
+ self.assertEquals(igorville.state, Domain.State.UNKNOWN)
+ detail_page = home_page.click("Manage", index=0)
+ self.assertNotContains(detail_page, "Expired")
+
+ self.assertContains(detail_page, "DNS needed")
+
def test_domain_detail_blocked_for_ineligible_user(self):
"""We could easily duplicate this test for all domain management
views, but a single url test should be solid enough since all domain
|