mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
added test case
This commit is contained in:
parent
d3a3565336
commit
b84fdedc40
3 changed files with 66 additions and 41 deletions
|
@ -16,49 +16,60 @@
|
|||
</div>
|
||||
<div class="grid-row grid-gap">
|
||||
<div class="tablet:grid-col-3">
|
||||
{% include 'domain_sidebar.html' %}
|
||||
{% if domain.domain_info %}
|
||||
{% include 'domain_sidebar.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="tablet:grid-col-9">
|
||||
<main id="main-content" class="grid-container">
|
||||
|
||||
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
|
||||
<div class="usa-alert usa-alert--warning margin-bottom-2">
|
||||
<div class="usa-alert__body">
|
||||
<h4 class="usa-alert__heading larger-font-sizing">Attention!</h4>
|
||||
<p class="usa-alert__text ">
|
||||
You are making changes to a registrant’s domain. When finished making changes, close this tab and inform the registrant of your updates.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||
</svg>
|
||||
|
||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||
Back to manage your domains
|
||||
</p>
|
||||
</a>
|
||||
{% endif %}
|
||||
{# messages block is under the back breadcrumb link #}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
|
||||
{% if not domain.domain_info %}
|
||||
<div class="usa-alert usa-alert--error margin-bottom-2">
|
||||
<div class="usa-alert__body">
|
||||
{{ message }}
|
||||
<h4 class="usa-alert__heading larger-font-sizing">Error!</h4>
|
||||
<p class="usa-alert__text ">
|
||||
You are attempting to manage a domain, {{ domain.name }}, which does not have a Domain Information object. Please correct this in the admin.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if is_analyst_or_superuser and analyst_action == 'edit' and analyst_action_location == domain.pk %}
|
||||
<div class="usa-alert usa-alert--warning margin-bottom-2">
|
||||
<div class="usa-alert__body">
|
||||
<h4 class="usa-alert__heading larger-font-sizing">Attention!</h4>
|
||||
<p class="usa-alert__text ">
|
||||
You are making changes to a registrant’s domain. When finished making changes, close this tab and inform the registrant of your updates.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||
</svg>
|
||||
|
||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||
Back to manage your domains
|
||||
</p>
|
||||
</a>
|
||||
{% endif %}
|
||||
{# messages block is under the back breadcrumb link #}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
|
||||
<div class="usa-alert__body">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% block domain_content %}
|
||||
|
||||
<h1 class="break-word">{{ domain.name }}</h1>
|
||||
|
||||
{% endblock %} {# domain_content #}
|
||||
{% endif %}
|
||||
|
||||
{% block domain_content %}
|
||||
|
||||
<h1 class="break-word">{{ domain.name }}</h1>
|
||||
|
||||
{% endblock %} {# domain_content #}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -453,7 +453,7 @@ def create_user():
|
|||
p = "userpass"
|
||||
user = User.objects.create_user(
|
||||
username="staffuser",
|
||||
email="user@example.com",
|
||||
email="staff@example.com",
|
||||
is_staff=True,
|
||||
password=p,
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.conf import settings
|
|||
from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth import get_user_model
|
||||
from .common import MockEppLib, completed_application # type: ignore
|
||||
from .common import MockEppLib, completed_application, create_user # type: ignore
|
||||
|
||||
from django_webtest import WebTest # type: ignore
|
||||
import boto3_mocking # type: ignore
|
||||
|
@ -1282,13 +1282,27 @@ class TestDomainOverview(TestWithDomainPermissions, WebTest):
|
|||
self.assertContains(detail_page, "2.3.4.5)")
|
||||
|
||||
def test_domain_with_no_information_or_application(self):
|
||||
"""Test that domain management page returns 200 when no
|
||||
domain information or domain application exist"""
|
||||
detail_page = self.app.get(
|
||||
"""Test that domain management page returns 200 and displays error
|
||||
when no domain information or domain application exist"""
|
||||
# have to use staff user for this test
|
||||
staff_user = create_user()
|
||||
# staff_user.save()
|
||||
self.client.force_login(staff_user)
|
||||
|
||||
# need to set the analyst_action and analyst_action_location
|
||||
# in the session to emulate user clicking Manage Domain
|
||||
# in the admin interface
|
||||
session = self.client.session
|
||||
session['analyst_action'] = 'foo'
|
||||
session['analyst_action_location'] = self.domain_no_information.id
|
||||
session.save()
|
||||
|
||||
detail_page = self.client.get(
|
||||
reverse("domain", kwargs={"pk": self.domain_no_information.id})
|
||||
)
|
||||
|
||||
self.assertContains(detail_page, "noinformation.gov")
|
||||
self.assertContains(detail_page, "Error")
|
||||
|
||||
|
||||
class TestDomainManagers(TestDomainOverview):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue