From 8bb3497c481deff6a0ebda7a18d76884ee1cb047 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Mon, 1 Apr 2024 20:13:06 -0400 Subject: [PATCH] revise unit tests --- src/registrar/assets/sass/_theme/_admin.scss | 3 ++ .../admin/domain_request_change_form.html | 1 + src/registrar/tests/test_admin.py | 37 +++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index ddcc6acd6..f44ae2bc0 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -422,6 +422,8 @@ address.dja-address-contact-list { border: 1px solid var(--error-fg) !important; } +// Let's define this block of code once and use it for analysts over a certain screen size, +// superusers over another screen size. @mixin submit-row-wrapper--collapsed-one-line(){ &.submit-row-wrapper--collapsed { transform: translate3d(0, 42px, 0); @@ -475,6 +477,7 @@ address.dja-address-contact-list { } @media screen and (min-width:935px) { + // Analyst only class .submit-row-wrapper--analyst-view { @include submit-row-wrapper--collapsed-one-line(); } diff --git a/src/registrar/templates/django/admin/domain_request_change_form.html b/src/registrar/templates/django/admin/domain_request_change_form.html index 17d4fdef9..be66c7c81 100644 --- a/src/registrar/templates/django/admin/domain_request_change_form.html +++ b/src/registrar/templates/django/admin/domain_request_change_form.html @@ -104,6 +104,7 @@ +{# submit-row-wrapper--analyst-view is a class that manages layout on certain screens for analysts only #}
diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 37361375a..d6625081d 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1213,9 +1213,11 @@ class TestDomainRequestAdmin(MockEppLib): self.assertEqual(domain_request.requested_domain.name, domain_request.approved_domain.name) @less_console_noise_decorator - def test_sticky_submit_row_shows_requested_domain(self): - """Test that the change_form template contains a string indicative of the customization - of the sticky submit bar.""" + def test_sticky_submit_row(self): + """Test that the change_form template contains strings indicative of the customization + of the sticky submit bar. + + Also test that it does NOT contain a CSS class meant for analysts only when logged in as superuser.""" # make sure there is no user with this email EMAIL = "mayor@igorville.gov" @@ -1233,6 +1235,35 @@ class TestDomainRequestAdmin(MockEppLib): expected_content = "Requested domain:" expected_content2 = '' expected_content3 = '
' + not_expected_content = "submit-row-wrapper--analyst-view>" + self.assertContains(request, expected_content) + self.assertContains(request, expected_content2) + self.assertContains(request, expected_content3) + self.assertNotContains(request, not_expected_content) + + @less_console_noise_decorator + def test_sticky_submit_row_has_extra_class_for_analysts(self): + """Test that the change_form template contains strings indicative of the customization + of the sticky submit bar. + + Also test that it DOES contain a CSS class meant for analysts only when logged in as analyst.""" + + # make sure there is no user with this email + EMAIL = "mayor@igorville.gov" + User.objects.filter(email=EMAIL).delete() + self.client.force_login(self.staffuser) + + # Create a sample domain request + domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW) + + # Create a mock request + request = self.client.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk)) + + # Since we're using client to mock the request, we can only test against + # non-interpolated values + expected_content = "Requested domain:" + expected_content2 = '' + expected_content3 = '
' self.assertContains(request, expected_content) self.assertContains(request, expected_content2) self.assertContains(request, expected_content3)