diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py index d0f91aca4..a33562972 100644 --- a/app/main/views/sign_in.py +++ b/app/main/views/sign_in.py @@ -139,13 +139,21 @@ def verify_email(user, redirect_url): def _handle_e2e_tests(redirect_url): - current_app.logger.warning("E2E TESTS ARE ENABLED.") - current_app.logger.warning( - "If you are getting a 404 on signin, comment out E2E vars in .env file!" - ) - user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL")) - activate_user(user["id"]) - return redirect(url_for("main.show_accounts_or_dashboard", next=os.getenv("NOTIFY_E2E_TEST_EMAIL"))) + try: + current_app.logger.warning("E2E TESTS ARE ENABLED.") + current_app.logger.warning( + "If you are getting a 404 on signin, comment out E2E vars in .env file!" + ) + user = user_api_client.get_user_by_email(os.getenv("NOTIFY_E2E_TEST_EMAIL")) + activate_user(user["id"]) + return redirect( + url_for( + "main.show_accounts_or_dashboard", + next=os.getenv("NOTIFY_E2E_TEST_EMAIL"), + ) + ) + except Exception as e: + return redirect(url_for("main.show_accounts_or_dashboard", next=f"{e}")) # return redirect(url_for("main.show_accounts_or_dashboard", next=redirect_url)) @@ -159,7 +167,7 @@ def sign_in(): # and don't proceed further with login redirect_url = request.args.get("next") - #if os.getenv("NOTIFY_E2E_TEST_EMAIL"): + # if os.getenv("NOTIFY_E2E_TEST_EMAIL"): return _handle_e2e_tests(None) email_verify_template = _do_login_dot_gov() @@ -170,7 +178,6 @@ def sign_in(): ): return email_verify_template - if current_user and current_user.is_authenticated: if redirect_url and is_safe_redirect_url(redirect_url): return redirect(redirect_url) diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index e5ba4e884..ea667e430 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -12,10 +12,10 @@ def login_for_end_to_end_testing(browser): page = context.new_page() page.goto(f"{E2E_TEST_URI}/sign-in") - #sign_in_button = page.get_by_role("link", name="Sign in") + # sign_in_button = page.get_by_role("link", name="Sign in") # Test trying to sign in. - #sign_in_button.click() + # sign_in_button.click() # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") @@ -63,7 +63,6 @@ def authenticated_page(end_to_end_context): page = end_to_end_context.new_page() page.goto(f"{E2E_TEST_URI}/sign-in") - # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") diff --git a/tests/end_to_end/test_create_new_template.py b/tests/end_to_end/test_create_new_template.py index 0035903ef..48b5ee154 100644 --- a/tests/end_to_end/test_create_new_template.py +++ b/tests/end_to_end/test_create_new_template.py @@ -9,7 +9,6 @@ from playwright.sync_api import expect E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") - def create_new_template(page): current_service_link = page.get_by_text("Current service") @@ -96,8 +95,7 @@ def test_create_new_template(end_to_end_context): x = page.goto(f"{E2E_TEST_URI}/sign-in") # Wait for the next page to fully load. page.wait_for_load_state("domcontentloaded") - print(f"WTF is x? {x}") - print(f"PAGE ON ENTER TEST_CREATE_NEW_TEMPLATE AFTER SIGNING IN IS {page.content()}") + print(f"PAGE ON ENTER TEST_CREATE_NEW_TEMPLATE AFTER SIGNING IN IS {page}") current_date_time = datetime.datetime.now() new_service_name = "E2E Federal Test Service {now} - {browser_type}".format( @@ -108,7 +106,6 @@ def test_create_new_template(end_to_end_context): print(f"GOING TO {E2E_TEST_URI}/accounts") page.goto(f"{E2E_TEST_URI}/accounts") - # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") print(page)