From 5192aa52bfc394d0873df23066d720135975914c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:58:07 +0000 Subject: [PATCH 1/2] Add translation checks for repair flows --- tests/components/conftest.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/components/conftest.py b/tests/components/conftest.py index 363d39a2e63..dcbf589982c 100644 --- a/tests/components/conftest.py +++ b/tests/components/conftest.py @@ -18,6 +18,7 @@ from aiohasupervisor.models import ( ) import pytest +from homeassistant.components import repairs from homeassistant.config_entries import ( DISCOVERY_SOURCES, ConfigEntriesFlowManager, @@ -32,6 +33,7 @@ from homeassistant.data_entry_flow import ( FlowManager, FlowResultType, ) +from homeassistant.helpers import issue_registry as ir from homeassistant.helpers.translation import async_get_translations if TYPE_CHECKING: @@ -615,12 +617,23 @@ async def _check_config_flow_result_translations( result: FlowResult[FlowContext, str], ignore_translations: dict[str, str], ) -> None: + if result["type"] is FlowResultType.CREATE_ENTRY: + # No need to check translations for a completed flow + return + + key_prefix = "" if isinstance(manager, ConfigEntriesFlowManager): category = "config" integration = flow.handler elif isinstance(manager, OptionsFlowManager): category = "options" integration = flow.hass.config_entries.async_get_entry(flow.handler).domain + elif isinstance(manager, repairs.RepairsFlowManager): + category = "issues" + integration = flow.handler + issue_id = flow.issue_id + issue = ir.async_get(flow.hass).async_get_issue(integration, issue_id) + key_prefix = f"{issue.translation_key}.fix_flow." else: return @@ -639,7 +652,7 @@ async def _check_config_flow_result_translations( ignore_translations, category, integration, - f"step.{step_id}.{header}", + f"{key_prefix}step.{step_id}.{header}", result["description_placeholders"], translation_required=False, ) @@ -650,7 +663,7 @@ async def _check_config_flow_result_translations( ignore_translations, category, integration, - f"error.{error}", + f"{key_prefix}error.{error}", result["description_placeholders"], ) return @@ -665,7 +678,7 @@ async def _check_config_flow_result_translations( ignore_translations, category, integration, - f"abort.{result["reason"]}", + f"{key_prefix}abort.{result["reason"]}", result["description_placeholders"], ) From bf207f6135be2fcd6f084aa4a4d5e73dd477f9f6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:55:23 +0000 Subject: [PATCH 2/2] Ignore fake_integration in repairs --- tests/components/repairs/test_websocket_api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/components/repairs/test_websocket_api.py b/tests/components/repairs/test_websocket_api.py index bb3d50f9eb5..b23977842c6 100644 --- a/tests/components/repairs/test_websocket_api.py +++ b/tests/components/repairs/test_websocket_api.py @@ -533,6 +533,10 @@ async def test_list_issues( } +@pytest.mark.parametrize( + "ignore_translations", + ["component.fake_integration.issues.abc_123.fix_flow.abort.not_given"], +) async def test_fix_issue_aborted( hass: HomeAssistant, hass_client: ClientSessionGenerator,