Skip to content

Commit

Permalink
Account for not state unknown when displaying expiration date
Browse files Browse the repository at this point in the history
  • Loading branch information
rachidatecs committed Jan 11, 2024
1 parent c21c417 commit 678ca6d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/registrar/templates/domain_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<span class="text-bold text-primary-darker">
Status:
</span>
{% 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 }}
Expand Down
4 changes: 2 additions & 2 deletions src/registrar/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ <h2>Domains</h2>
<td data-sort-value="{{ domain.expiration_date|date:"U" }}" data-label="Expires">{{ domain.expiration_date|date }}</td>
<td data-label="Status">
{# 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 }}
Expand Down
65 changes: 57 additions & 8 deletions src/registrar/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 678ca6d

Please sign in to comment.