diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 63483c18e..7c9a43f57 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1284,7 +1284,7 @@ class Domain(TimeStampedModel, DomainHelper): now = timezone.now().date() threshold_date = now + timedelta(days=60) - return now < self.expiration_date <= threshold_date + return now <= self.expiration_date <= threshold_date def state_display(self, request=None): """Return the display status of the domain.""" diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 3f5413e5a..01d5636b7 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1,4 +1,4 @@ -from datetime import date +from datetime import date, timedelta from django.test import Client, TestCase, override_settings from django.contrib.auth import get_user_model from django_webtest import WebTest # type: ignore @@ -191,7 +191,7 @@ class HomeTests(TestWithUser): with self.subTest(domain_name=domain_name, state=state, expected_message=expected_message): # Create a domain and a UserRole with the given params test_domain, _ = Domain.objects.get_or_create(name=domain_name, state=state) - test_domain.expiration_date = date.today() + test_domain.expiration_date = date.today() + timedelta(days=61) test_domain.save() user_role, _ = UserDomainRole.objects.get_or_create( @@ -235,6 +235,30 @@ class HomeTests(TestWithUser): test_role.delete() test_domain.delete() + @less_console_noise_decorator + def test_state_help_text_is_expiring(self): + """Tests if each domain state has help text when expired""" + is_expiring_text = "This domain is expiring soon" + test_domain, _ = Domain.objects.get_or_create(name="is-expiring.gov", state=Domain.State.READY) + test_domain.expiration_date = date.today() + test_domain.save() + + test_role, _ = UserDomainRole.objects.get_or_create( + user=self.user, domain=test_domain, role=UserDomainRole.Roles.MANAGER + ) + + # Grab the json response of the domains list + response = self.client.get("/get-domains-json/") + + # Make sure the domain is in the response + self.assertContains(response, "is-expiring.gov", count=1) + + # Check that we have the right text content. + self.assertContains(response, is_expiring_text, count=1) + + test_role.delete() + test_domain.delete() + @less_console_noise_decorator def test_state_help_text_no_expiration_date(self): """Tests if each domain state has help text when expiration date is None"""