From 759503f8633adb6a6f601ee2d6964a7e6923eb75 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 8 Aug 2022 16:46:48 -0600 Subject: [PATCH] Ensure ConfirmRepairFlow can make use of translation placeholders (#76336) * Ensure ConfirmRepairFlow can make use of translation placeholders * Automatically determine the issue * Fix tests * Update homeassistant/components/repairs/issue_handler.py Co-authored-by: Franck Nijhof Co-authored-by: Franck Nijhof --- homeassistant/components/repairs/issue_handler.py | 12 ++++++++++-- tests/components/repairs/test_websocket_api.py | 15 ++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/repairs/issue_handler.py b/homeassistant/components/repairs/issue_handler.py index 5695e99998b..b37d4c10e06 100644 --- a/homeassistant/components/repairs/issue_handler.py +++ b/homeassistant/components/repairs/issue_handler.py @@ -27,7 +27,6 @@ class ConfirmRepairFlow(RepairsFlow): self, user_input: dict[str, str] | None = None ) -> data_entry_flow.FlowResult: """Handle the first step of a fix flow.""" - return await (self.async_step_confirm()) async def async_step_confirm( @@ -37,7 +36,16 @@ class ConfirmRepairFlow(RepairsFlow): if user_input is not None: return self.async_create_entry(title="", data={}) - return self.async_show_form(step_id="confirm", data_schema=vol.Schema({})) + issue_registry = async_get_issue_registry(self.hass) + description_placeholders = None + if issue := issue_registry.async_get_issue(self.handler, self.issue_id): + description_placeholders = issue.translation_placeholders + + return self.async_show_form( + step_id="confirm", + data_schema=vol.Schema({}), + description_placeholders=description_placeholders, + ) class RepairsFlowManager(data_entry_flow.FlowManager): diff --git a/tests/components/repairs/test_websocket_api.py b/tests/components/repairs/test_websocket_api.py index 1cb83d81b06..2a506c7a248 100644 --- a/tests/components/repairs/test_websocket_api.py +++ b/tests/components/repairs/test_websocket_api.py @@ -253,14 +253,19 @@ async def test_fix_non_existing_issue( @pytest.mark.parametrize( - "domain, step", + "domain, step, description_placeholders", ( - ("fake_integration", "custom_step"), - ("fake_integration_default_handler", "confirm"), + ("fake_integration", "custom_step", None), + ("fake_integration_default_handler", "confirm", {"abc": "123"}), ), ) async def test_fix_issue( - hass: HomeAssistant, hass_client, hass_ws_client, domain, step + hass: HomeAssistant, + hass_client, + hass_ws_client, + domain, + step, + description_placeholders, ) -> None: """Test we can fix an issue.""" assert await async_setup_component(hass, "http", {}) @@ -288,7 +293,7 @@ async def test_fix_issue( flow_id = data["flow_id"] assert data == { "data_schema": [], - "description_placeholders": None, + "description_placeholders": description_placeholders, "errors": None, "flow_id": ANY, "handler": domain,