From 01f1175e526e157aaf63cc7e6ed7c329cb56effb Mon Sep 17 00:00:00 2001 From: alexjanousekGSA Date: Fri, 25 Oct 2024 10:57:34 -0400 Subject: [PATCH] Added back removed tests --- tests/app/main/views/test_index.py | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index cedc2e348..d1db4e006 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -2,7 +2,64 @@ import os from functools import partial import pytest +from bs4 import BeautifulSoup from flask import url_for +from freezegun import freeze_time + +from tests.conftest import SERVICE_ONE_ID, normalize_spaces + +def test_non_logged_in_user_can_see_homepage( + client_request, mock_get_service_and_organization_counts, mocker +): + + mocker.patch("app.notify_client.user_api_client.UserApiClient.deactivate_user") + client_request.logout() + page = client_request.get("main.index", _test_page_title=False) + + assert page.h1.text.strip() == ( + "Reach people where they are with government-powered text messages" + ) + + assert ( + page.select_one( + "a.usa-button.login-button.login-button--primary.margin-right-2" + ).text + == "Sign in with \n" + ) + assert page.select_one("meta[name=description]") is not None + # This area is hidden for the pilot + # assert normalize_spaces(page.select_one('#whos-using-notify').text) == ( + # 'Who’s using Notify.gov ' # Hiding this next area for the pilot + # # Hiding this next area for the pilot + # # 'See the list of services and organizations. ' + # 'There are 111 Organizations and 9,999 Services using Notify.' + # ) + + assert page.select_one("#whos-using-notify a") is None + + +def test_logged_in_user_redirects_to_choose_account( + client_request, + api_user_active, + mock_get_user, + mock_get_user_by_email, + mock_login, +): + client_request.get( + "main.index", + _expected_status=302, + ) + + # Modify expected URL to include the query parameter + client_request.get( + "main.sign_in", + _expected_status=302, + _expected_redirect=url_for("main.show_accounts_or_dashboard") + "?next=EMAIL_IS_OK", + ) + + +def test_robots(client_request): + client_request.get_url("/robots.txt", _expected_status=404) @pytest.mark.parametrize(