From 8718635b94e6b044b9da60d3cc7bdd13f4302b34 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 15 Dec 2023 11:36:32 -0500 Subject: [PATCH] Update unit tests to look for the dynamic header passed in context to the modal --- src/registrar/tests/test_views.py | 28 ++++++++++++++++++++-------- src/registrar/views/application.py | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index b5574c8e2..57fa03f52 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -164,6 +164,9 @@ class DomainApplicationTests(TestWithUser, WebTest): this test work. This test also looks for the long organization name on the summary page. + + This also tests for the presence of a modal trigger and the dynamic test + in the modal header on the submit page. """ num_pages_tested = 0 # elections, type_of_work, tribal_government, no_other_contacts @@ -472,6 +475,14 @@ class DomainApplicationTests(TestWithUser, WebTest): self.assertContains(review_page, "(201) 555-5557") self.assertContains(review_page, "Nothing else.") + # We can't test the modal itself as it relies on JS for init and triggering, + # but we can test for the existence of its trigger: + self.assertContains(review_page, "toggle-submit-domain-request") + # And the existence of the modal's data parked and ready for the js init. + # The next assert also tests for the passed requested domain context from + # the view > application_form > modal + self.assertContains(review_page, "You are about to submit a domain request for city.gov") + # final submission results in a redirect to the "finished" URL self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) with less_console_noise(): @@ -1086,16 +1097,17 @@ class DomainApplicationTests(TestWithUser, WebTest): detail_page = home_page.click("Manage", index=0) self.assertContains(detail_page, "Federal: an agency of the U.S. government") - def test_submit_modal(self): - """When user clicks on submit your domain request, a modal pops up.""" - # completed_application(name="cats.gov") + def test_submit_modal_no_domain_text_fallback(self): + """When user clicks on submit your domain request and the requested domain + is null (possible through url direct access to the review page), present + fallback copy in the modal's header. + + NOTE: This may be a moot point if we implement a more solid pattern in the + future, like not a submit action at all on the review page.""" + review_page = self.app.get(reverse("application:review")) - # We can't test the modal itself as it relies on JS for init and triggering, - # but we can test for the existence of its trigger: self.assertContains(review_page, "toggle-submit-domain-request") - # And the existence of the modal's data parked and ready for the js init: - print(review_page) - self.assertContains(review_page, "You are about to submit") + self.assertContains(review_page, "You are about to submit an incomplete request") class TestWithDomainPermissions(TestWithUser): diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index 4e76f55fe..ba716c117 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -331,9 +331,9 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): # by tyoing in review in the URL. The submit button still shows, hence # the if/else. if self.application.requested_domain: - modal_heading = 'You are about to submit a domain request for ' + str(self.application.requested_domain) + modal_heading = "You are about to submit a domain request for " + str(self.application.requested_domain) else: - modal_heading = 'You are about to submit an incomplete request' + modal_heading = "You are about to submit an incomplete request" return { "form_titles": self.TITLES, "steps": self.steps,