Fixed more unit tests

This commit is contained in:
alexjanousekGSA
2025-07-31 08:14:58 -04:00
parent b1e5b8d110
commit ab7b262c01
3 changed files with 24 additions and 22 deletions

View File

@@ -16,7 +16,7 @@
<div class="grid-row">
{% call form_wrapper() %}
{{ radios(form.sender, legend_style='usa-legend--large') }}
{{ radios(form.sender, legend_style='usa-legend--large', option_hints=option_hints) }}
<div class="grid-col-9">
{{ page_footer('Continue') }}
</div>

View File

@@ -182,10 +182,12 @@ def test_should_show_create_api_key_page(
for index, option in enumerate(expected_options):
item = page.select(".usa-radio")[index]
if type(option) is tuple:
assert (
normalize_spaces(item.select_one(".usa-radio__label").text) == option[0]
)
assert normalize_spaces(item.select_one(".usa-hint").text) == option[1]
label = item.select_one(".usa-radio__label")
hint = label.select_one(".usa-hint")
# Get the label text without the hint text
label_text = label.text.replace(hint.text, "").strip() if hint else label.text
assert normalize_spaces(label_text) == option[0]
assert normalize_spaces(hint.text) == option[1]
else:
assert normalize_spaces(item.select_one(".usa-radio__label").text) == option

View File

@@ -144,11 +144,11 @@ def test_default_email_sender_is_checked_and_has_hint(
".set_sender", service_id=SERVICE_ONE_ID, template_id=fake_uuid
)
assert page.select(".usa-radios input")[0].has_attr("checked")
assert page.select(".usa-radio input")[0].has_attr("checked")
assert (
normalize_spaces(page.select_one(".usa-radios .usa-hint").text) == "(Default)"
normalize_spaces(page.select_one(".usa-radio .usa-hint").text) == "(Default)"
)
assert not page.select(".usa-radios input")[1].has_attr("checked")
assert not page.select(".usa-radio input")[1].has_attr("checked")
def test_default_sms_sender_is_checked_and_has_hint(
@@ -161,11 +161,11 @@ def test_default_sms_sender_is_checked_and_has_hint(
".set_sender", service_id=SERVICE_ONE_ID, template_id=fake_uuid
)
assert page.select(".usa-radios input")[0].has_attr("checked")
assert page.select(".usa-radio input")[0].has_attr("checked")
assert (
normalize_spaces(page.select_one(".usa-radios .usa-hint").text) == "(Default)"
normalize_spaces(page.select_one(".usa-radio .usa-hint").text) == "(Default)"
)
assert not page.select(".usa-radios input")[1].has_attr("checked")
assert not page.select(".usa-radio input")[1].has_attr("checked")
def test_default_sms_sender_is_checked_and_has_hint_when_there_are_no_inbound_numbers(
@@ -178,11 +178,11 @@ def test_default_sms_sender_is_checked_and_has_hint_when_there_are_no_inbound_nu
".set_sender", service_id=SERVICE_ONE_ID, template_id=fake_uuid
)
assert page.select(".usa-radios input")[0].has_attr("checked")
assert page.select(".usa-radio input")[0].has_attr("checked")
assert (
normalize_spaces(page.select_one(".usa-radios .usa-hint").text) == "(Default)"
normalize_spaces(page.select_one(".usa-radio .usa-hint").text) == "(Default)"
)
assert not page.select(".usa-radios input")[1].has_attr("checked")
assert not page.select(".usa-radio input")[1].has_attr("checked")
def test_default_inbound_sender_is_checked_and_has_hint_with_default_and_receives_text(
@@ -196,13 +196,13 @@ def test_default_inbound_sender_is_checked_and_has_hint_with_default_and_receive
".set_sender", service_id=service_one["id"], template_id=fake_uuid
)
assert page.select(".usa-radios input")[0].has_attr("checked")
assert page.select(".usa-radio input")[0].has_attr("checked")
assert (
normalize_spaces(page.select_one(".usa-radios .usa-hint").text)
normalize_spaces(page.select_one(".usa-radio .usa-hint").text)
== "(Default and receives replies)"
)
assert not page.select(".usa-radios input")[1].has_attr("checked")
assert not page.select(".usa-radios input")[2].has_attr("checked")
assert not page.select(".usa-radio input")[1].has_attr("checked")
assert not page.select(".usa-radio input")[2].has_attr("checked")
def test_sms_sender_has_receives_replies_hint(
@@ -216,13 +216,13 @@ def test_sms_sender_has_receives_replies_hint(
".set_sender", service_id=service_one["id"], template_id=fake_uuid
)
assert page.select(".usa-radios input")[0].has_attr("checked")
assert page.select(".usa-radio input")[0].has_attr("checked")
assert (
normalize_spaces(page.select_one(".usa-radios .usa-hint").text)
normalize_spaces(page.select_one(".usa-radio .usa-hint").text)
== "(Default and receives replies)"
)
assert not page.select(".usa-radios input")[1].has_attr("checked")
assert not page.select(".usa-radios input")[2].has_attr("checked")
assert not page.select(".usa-radio input")[1].has_attr("checked")
assert not page.select(".usa-radio input")[2].has_attr("checked")
@pytest.mark.parametrize(