Sometimes test hang up and time out due to network errors (#2853)

* Fixed disable button, formated time to include time zone

* Fixed bandit

* Fix hanging test
This commit is contained in:
Alex Janousek
2025-08-21 17:23:30 -04:00
committed by GitHub
parent 7cbd0602e6
commit b2f86e045f
5 changed files with 14 additions and 5 deletions

View File

@@ -629,10 +629,10 @@
"filename": "tests/conftest.py",
"hashed_secret": "f8377c90fcfd699f0ddbdcb30c2c9183d2d933ea",
"is_verified": false,
"line_number": 3279,
"line_number": 3287,
"is_secret": false
}
]
},
"generated_at": "2025-08-07T18:05:06Z"
"generated_at": "2025-08-21T16:06:57Z"
}

View File

@@ -20,13 +20,14 @@ def test_non_logged_in_user_can_see_homepage(
assert heading in [
"Reach people where they are with government-powered text messages",
"There's currently a technical issue.",
"Sunsetting Notify.gov",
]
button = page.select_one(
"a.usa-button.login-button.login-button--primary.margin-right-2"
)
if heading == "There's currently a technical issue.":
if heading in ["There's currently a technical issue.", "Sunsetting Notify.gov"]:
assert button is None
else:
assert button is not None

View File

@@ -12,6 +12,7 @@ from bs4 import BeautifulSoup
from dotenv import load_dotenv
from flask import Flask, url_for
import app.utils.api_health
from app import create_app
from app.enums import AuthType, ServicePermission
from notifications_python_client.errors import HTTPError
@@ -35,6 +36,13 @@ from . import (
user_json,
)
# Mock is_api_down to prevent network calls during unit tests
# Set API_HOST_NAME to localhost to avoid network timeouts (sometimes they slow down in cicd)
os.environ["API_HOST_NAME"] = "http://localhost:6011"
# Also mock the function itself as a backup
app.utils.api_health.is_api_down = lambda: False
load_dotenv()

View File

@@ -52,7 +52,7 @@ def create_new_template(page):
page.wait_for_load_state("domcontentloaded")
check_axe_report(page)
template_name_input = page.get_by_text("Template name")
template_name_input = page.get_by_label("Template name")
expect(template_name_input).to_be_visible()
template_name = str(uuid.uuid4())
template_name_input.fill(template_name)

View File

@@ -126,7 +126,7 @@ def handle_no_existing_template_case(page):
page.wait_for_load_state("domcontentloaded")
check_axe_report(page)
template_name_input = page.get_by_text("Template name")
template_name_input = page.get_by_label("Template name")
expect(template_name_input).to_be_visible()
template_name = str(uuid.uuid4())
template_name_input.fill(template_name)