Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjanousekGSA committed Dec 9, 2024
1 parent a3db2bd commit 9ba5c60
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
10 changes: 7 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ def create_app(application):

@application.context_processor
def inject_feature_flags():
feature_best_practices_enabled = application.config.get("FEATURE_BEST_PRACTICES_ENABLED", False)
feature_about_page_enabled = application.config.get("FEATURE_ABOUT_PAGE_ENABLED", False)
feature_best_practices_enabled = application.config.get(
"FEATURE_BEST_PRACTICES_ENABLED", False
)
feature_about_page_enabled = application.config.get(
"FEATURE_ABOUT_PAGE_ENABLED", False
)
return dict(
FEATURE_BEST_PRACTICES_ENABLED=feature_best_practices_enabled,
FEATURE_ABOUT_PAGE_ENABLED=feature_about_page_enabled,
Expand Down Expand Up @@ -205,7 +209,7 @@ def inject_initial_signin_url():
url = url.replace("NONCE", nonce)
url = url.replace("STATE", state)

return {'initial_signin_url': url}
return {"initial_signin_url": url}

notify_environment = os.environ["NOTIFY_ENVIRONMENT"]

Expand Down
2 changes: 1 addition & 1 deletion app/main/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def index():
return render_template(
"views/signedout.html",
sms_rate=CURRENT_SMS_RATE,
counts=status_api_client.get_count_of_live_services_and_organizations()
counts=status_api_client.get_count_of_live_services_and_organizations(),
)


Expand Down
23 changes: 7 additions & 16 deletions tests/app/main/views/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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
):
Expand All @@ -20,24 +19,16 @@ def test_non_logged_in_user_can_see_homepage(
"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 the entire HTML of the button to include the image
button = page.select_one(
"a.usa-button.login-button.login-button--primary.margin-right-2"
)
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 "Sign in with" in button.text.strip() # Assert button text
assert button.find("img")["alt"] == "Login.gov logo" # Assert image presence

assert page.select_one("meta[name=description]") is not None
assert page.select_one("#whos-using-notify a") is None


def test_logged_in_user_redirects_to_choose_account(
client_request,
api_user_active,
Expand Down Expand Up @@ -125,7 +116,7 @@ def is_feature_flagged(view):
"write_for_action",
"multiple_languages",
"benchmark_performance",
"guidance_index"
"guidance_index",
]
return (
not current_app.config["FEATURE_BEST_PRACTICES_ENABLED"]
Expand Down
8 changes: 6 additions & 2 deletions tests/app/main/views/test_template_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,13 @@ def test_should_show_templates_folder_page(
assert normalize_spaces(page.select_one("h1").text) == expected_title_tag

# remove this line if you don't want the breadcrumb on the first page
assert len(page.select("nav#breadcrumb-template-folders a")) == len(expected_parent_link_args)
assert len(page.select("nav#breadcrumb-template-folders a")) == len(
expected_parent_link_args
)

for index, parent_link in enumerate(page.select("nav#breadcrumb-template-folders a")):
for index, parent_link in enumerate(
page.select("nav#breadcrumb-template-folders a")
):
assert parent_link["href"] == url_for(
"main.choose_template",
service_id=SERVICE_ONE_ID,
Expand Down
8 changes: 6 additions & 2 deletions tests/app/main/views/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def test_should_show_empty_page_when_no_templates(
service_id=service_one["id"],
)

assert normalize_spaces(page.select_one("h1").text) == ("Select or create a template")
assert normalize_spaces(page.select_one("h1").text) == (
"Select or create a template"
)
assert normalize_spaces(page.select_one("main p").text) == (expected_message)
assert page.select_one("#add_new_folder_form")
assert page.select_one("#add_new_template_form")
Expand All @@ -87,7 +89,9 @@ def test_should_show_add_template_form_if_service_has_folder_permission(
service_id=service_one["id"],
)

assert normalize_spaces(page.select_one("h1").text) == ("Select or create a template")
assert normalize_spaces(page.select_one("h1").text) == (
"Select or create a template"
)
assert normalize_spaces(page.select_one("main p").text) == (
"Every message starts with a template. You can change it later. "
"You need a template before you can send messages."
Expand Down

0 comments on commit 9ba5c60

Please sign in to comment.