diff --git a/src/registrar/templates/domain_nameservers.html b/src/registrar/templates/domain_nameservers.html index f201388c4..fde74920f 100644 --- a/src/registrar/templates/domain_nameservers.html +++ b/src/registrar/templates/domain_nameservers.html @@ -5,8 +5,8 @@ {% block domain_content %} - {# this is right after the messages block in the parent template. We use > not >= to account for the blank form. #} - {% if formset.total_form_count > formset.max_num %} + {# this is right after the messages block in the parent template. #} + {% if formset.initial|length >= formset.max_num %}
diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index cafdf49b0..8fbf052a4 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -1471,6 +1471,47 @@ class MockEppLib(TestCase): ], ) + infoDomainTwelveHosts = fakedEppObject( + "twelvenameserversdomain.gov", + cr_date=make_aware(datetime(2023, 5, 25, 19, 45, 35)), + contacts=[], + hosts=[ + "ns1.my-nameserver-1.com", + "ns1.my-nameserver-2.com", + "ns1.cats-are-superior3.com", + "ns1.explosive-chicken-nuggets.com", + "ns5.example.com", + "ns6.example.com", + "ns7.example.com", + "ns8.example.com", + "ns9.example.com", + "ns10.example.com", + "ns11.example.com", + "ns12.example.com", + ], + ) + + infoDomainThirteenHosts = fakedEppObject( + "thirteennameserversdomain.gov", + cr_date=make_aware(datetime(2023, 5, 25, 19, 45, 35)), + contacts=[], + hosts=[ + "ns1.my-nameserver-1.com", + "ns1.my-nameserver-2.com", + "ns1.cats-are-superior3.com", + "ns1.explosive-chicken-nuggets.com", + "ns5.example.com", + "ns6.example.com", + "ns7.example.com", + "ns8.example.com", + "ns9.example.com", + "ns10.example.com", + "ns11.example.com", + "ns12.example.com", + "ns13.example.com", + ], + ) + infoDomainNoHost = fakedEppObject( "my-nameserver.gov", cr_date=make_aware(datetime(2023, 5, 25, 19, 45, 35)), @@ -1821,6 +1862,8 @@ class MockEppLib(TestCase): "freeman.gov": (self.InfoDomainWithContacts, None), "threenameserversdomain.gov": (self.infoDomainThreeHosts, None), "fournameserversdomain.gov": (self.infoDomainFourHosts, None), + "twelvenameserversdomain.gov": (self.infoDomainTwelveHosts, None), + "thirteennameserversdomain.gov": (self.infoDomainThirteenHosts, None), "defaultsecurity.gov": (self.InfoDomainWithDefaultSecurityContact, None), "adomain2.gov": (self.InfoDomainWithVerisignSecurityContact, None), "defaulttechnical.gov": (self.InfoDomainWithDefaultTechnicalContact, None), diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index 97013a4de..c2120b58f 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -87,12 +87,16 @@ class TestWithDomainPermissions(TestWithUser): self.domain_dnssec_none, _ = Domain.objects.get_or_create(name="dnssec-none.gov") self.domain_with_three_nameservers, _ = Domain.objects.get_or_create(name="threenameserversdomain.gov") self.domain_with_four_nameservers, _ = Domain.objects.get_or_create(name="fournameserversdomain.gov") + self.domain_with_twelve_nameservers, _ = Domain.objects.get_or_create(name="twelvenameserversdomain.gov") + self.domain_with_thirteen_nameservers, _ = Domain.objects.get_or_create(name="thirteennameserversdomain.gov") self.domain_information, _ = DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_dsdata) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_multdsdata) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_dnssec_none) + DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_with_thirteen_nameservers) + DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_with_twelve_nameservers) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_with_four_nameservers) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_with_three_nameservers) DomainInformation.objects.get_or_create(creator=self.user, domain=self.domain_with_ip) @@ -132,6 +136,16 @@ class TestWithDomainPermissions(TestWithUser): domain=self.domain_with_four_nameservers, role=UserDomainRole.Roles.MANAGER, ) + UserDomainRole.objects.get_or_create( + user=self.user, + domain=self.domain_with_twelve_nameservers, + role=UserDomainRole.Roles.MANAGER, + ) + UserDomainRole.objects.get_or_create( + user=self.user, + domain=self.domain_with_thirteen_nameservers, + role=UserDomainRole.Roles.MANAGER, + ) UserDomainRole.objects.get_or_create( user=self.user, domain=self.domain_with_ip, @@ -1890,6 +1904,34 @@ class TestDomainNameservers(TestDomainOverview, MockEppLib): nameservers_page = result.follow() self.assertContains(nameservers_page, "The name servers for this domain have been updated") + @less_console_noise_decorator + def test_domain_nameservers_12_entries(self): + """Nameserver form does not present info alert when 12 enrties.""" + + nameservers_page = self.app.get( + reverse("domain-dns-nameservers", kwargs={"domain_pk": self.domain_with_twelve_nameservers.id}) + ) + + session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + + self.assertNotContains( + nameservers_page, "You’ve reached the maximum amount of allowed name server records (13)." + ) + + @less_console_noise_decorator + def test_domain_nameservers_13_entries(self): + """Nameserver form present3 info alert when 13 enrties.""" + + nameservers_page = self.app.get( + reverse("domain-dns-nameservers", kwargs={"domain_pk": self.domain_with_thirteen_nameservers.id}) + ) + + session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + + self.assertContains(nameservers_page, "You’ve reached the maximum amount of allowed name server records (13).") + @less_console_noise_decorator def test_domain_nameservers_form_invalid(self): """Nameserver form does not submit with invalid data.