added some additional test code to boost coverage, fixed is_portfolio_admin, and formatting

This commit is contained in:
David Kennedy 2024-11-26 19:56:46 -05:00
parent bcd4e57b4c
commit 9c0a7e15e8
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
3 changed files with 10 additions and 2 deletions

View file

@ -259,7 +259,7 @@ class User(AbstractUser):
return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION)
def is_portfolio_admin(self, portfolio):
return self.has_edit_suborganization_portfolio_permission(portfolio)
return "Admin" in self.portfolio_role_summary(portfolio)
def get_first_portfolio(self):
permission = self.portfolio_permissions.first()

View file

@ -20,7 +20,6 @@
{% endblock breadcrumb %}
{{ block.super }}
<div class="margin-top-4 tablet:grid-col-10">
<h2 class="text-bold text-primary-dark domain-name-wrap">{{ domain.name }}</h2>
<div
@ -78,6 +77,7 @@
{% endif %}
{% endif %}
{% url 'domain-dns-nameservers' pk=domain.id as url %}
{% if domain.nameservers|length > 0 %}
{% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %}

View file

@ -142,6 +142,7 @@ class TestWithDomainPermissions(TestWithUser):
def tearDown(self):
try:
UserDomainRole.objects.all().delete()
DomainInvitation.objects.all().delete()
if hasattr(self.domain, "contacts"):
self.domain.contacts.all().delete()
DomainRequest.objects.all().delete()
@ -382,6 +383,8 @@ class TestDomainDetail(TestDomainOverview):
)
# Check that user does not have option to Edit domain
self.assertNotContains(detail_page, "Edit")
# Check that invited domain manager section not displayed when no invited domain managers
self.assertNotContains(detail_page, "Invited domain managers")
@less_console_noise_decorator
@override_flag("organization_feature", active=True)
@ -404,6 +407,8 @@ class TestDomainDetail(TestDomainOverview):
UserPortfolioPermission.objects.get_or_create(
user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN]
)
# add a domain invitation
DomainInvitation.objects.get_or_create(email="invited@example.com", domain=domain)
user.refresh_from_db()
self.client.force_login(user)
detail_page = self.client.get(f"/domain/{domain.id}")
@ -414,6 +419,9 @@ class TestDomainDetail(TestDomainOverview):
)
# Check that user does not have option to Edit domain
self.assertNotContains(detail_page, "Edit")
# Check that invited domain manager is displayed
self.assertContains(detail_page, "Invited domain managers")
self.assertContains(detail_page, "invited@example.com")
class TestDomainManagers(TestDomainOverview):