updated tests

This commit is contained in:
David Kennedy 2024-06-19 16:02:57 -04:00
parent 2ced462f94
commit e0df3ed453
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 15 additions and 5 deletions

View file

@ -530,8 +530,11 @@ class FinishUserProfileTests(TestWithUser, WebTest):
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
def _submit_form_webtest(self, form, follow=False): def _submit_form_webtest(self, form, follow=False, name=None):
page = form.submit() if name:
page = form.submit(name=name)
else:
page = form.submit()
self._set_session_cookie() self._set_session_cookie()
return page.follow() if follow else page return page.follow() if follow else page
@ -605,6 +608,13 @@ class FinishUserProfileTests(TestWithUser, WebTest):
self.assertEqual(completed_setup_page.status_code, 200) self.assertEqual(completed_setup_page.status_code, 200)
finish_setup_form = completed_setup_page.form
# Submit the form using the specific submit button to execute the redirect
completed_setup_page = self._submit_form_webtest(finish_setup_form, follow=True, name="contact_setup_submit_button")
self.assertEqual(completed_setup_page.status_code, 200)
# Assert that we are still on the
# Assert that we're on the domain request page # Assert that we're on the domain request page
self.assertNotContains(completed_setup_page, "Finish setting up your profile") self.assertNotContains(completed_setup_page, "Finish setting up your profile")
self.assertNotContains(completed_setup_page, "What contact information should we use to reach you?") self.assertNotContains(completed_setup_page, "What contact information should we use to reach you?")
@ -822,7 +832,7 @@ class UserProfileTests(TestWithUser, WebTest):
"""tests user profile when profile_feature is on, """tests user profile when profile_feature is on,
and when they are redirected from the domain request page""" and when they are redirected from the domain request page"""
with override_flag("profile_feature", active=True): with override_flag("profile_feature", active=True):
response = self.client.get("/user-profile?return_to_request=True") response = self.client.get("/user-profile?redirect=domain-request:")
self.assertContains(response, "Your profile") self.assertContains(response, "Your profile")
self.assertContains(response, "Go back to your domain request") self.assertContains(response, "Go back to your domain request")
self.assertNotContains(response, "Back to manage your domains") self.assertNotContains(response, "Back to manage your domains")

View file

@ -62,7 +62,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
# Set the profile_back_button_text based on the redirect parameter # Set the profile_back_button_text based on the redirect parameter
if kwargs.get("redirect") == "domain-request:": if kwargs.get("redirect") == "domain-request:":
context["profile_back_button_text"] = "Go back to your request" context["profile_back_button_text"] = "Go back to your domain request"
else: else:
context["profile_back_button_text"] = "Go to manage your domains" context["profile_back_button_text"] = "Go to manage your domains"
@ -159,7 +159,7 @@ class FinishProfileSetupView(UserProfileView):
# Get the current form and validate it # Get the current form and validate it
if form.is_valid(): if form.is_valid():
self.redirect_page = True self.redirect_page = False
if "contact_setup_save_button" in request.POST: if "contact_setup_save_button" in request.POST:
# Logic for when the 'Save' button is clicked, which indicates # Logic for when the 'Save' button is clicked, which indicates
# user should stay on this page # user should stay on this page