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 8fa3034a0..138f83e04 100644
--- a/src/registrar/templates/home.html
+++ b/src/registrar/templates/home.html
@@ -53,9 +53,9 @@
Domains
{{ domain.expiration_date|date }} |
{# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
- {% if domain.is_expired and domain.state != "unknown" %}
+ {% 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 491b478ca..1e8a1a55b 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
@@ -1352,8 +1354,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")
@@ -1500,14 +1514,49 @@ def test_domain_detail_link_works(self):
detail_page = home_page.click("Manage", index=0)
self.assertContains(detail_page, "igorville.gov")
self.assertContains(detail_page, "Status")
-
- def test_unknown_domain_does_not_show_as_expired(self):
+
+ 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")
+ 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")
- # click the "Edit" link
- # detail_page = home_page.click("Manage", index=0)
- # self.assertContains(detail_page, "igorville.gov")
- # self.assertContains(detail_page, "Status")
+ 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
|