From 224fe120af6abacc1c3d1b49789a73c8df933239 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 14 Nov 2024 06:10:01 -0500 Subject: [PATCH] added unit test --- src/registrar/tests/test_views_domain.py | 30 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index a375493be..6f732bede 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -370,6 +370,17 @@ def setUpClass(cls): ] AllowedEmail.objects.bulk_create(allowed_emails) + def setUp(self): + super().setUp() + # Add portfolio in order to test portfolio view + self.portfolio = Portfolio.objects.create(creator=self.user, organization_name="Ice Cream") + # Add the portfolio to the domain_information object + self.domain_information.portfolio = self.portfolio + # Add portfolio perms to the user object + self.portfolio_permission, _ = UserPortfolioPermission.objects.get_or_create( + user=self.user, portfolio=self.portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] + ) + @classmethod def tearDownClass(cls): super().tearDownClass() @@ -383,13 +394,22 @@ def tearDown(self): def test_domain_managers(self): response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) self.assertContains(response, "Domain managers") + self.assertContains(response, "Add a domain manager") + # assert that the non-portfolio view contains Role column and doesn't contain Admin + self.assertContains(response, "Role") + self.assertNotContains(response, "Admin") + self.assertContains(response, "This domain has one manager. Adding more can prevent issues.") @less_console_noise_decorator - def test_domain_managers_add_link(self): - """Button to get to user add page works.""" - management_page = self.app.get(reverse("domain-users", kwargs={"pk": self.domain.id})) - add_page = management_page.click("Add a domain manager") - self.assertContains(add_page, "Add a domain manager") + @override_flag("organization_feature", active=True) + def test_domain_managers_portfolio_view(self): + response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) + self.assertContains(response, "Domain managers") + self.assertContains(response, "Add a domain manager") + # assert that the non-portfolio view contains Role column and doesn't contain Admin + self.assertNotContains(response, "Role") + self.assertContains(response, "Admin") + self.assertContains(response, "This domain has one manager. Adding more can prevent issues.") @less_console_noise_decorator def test_domain_user_add(self):