From d7c4f613ea7479250ab24a808f9a78bce401a212 Mon Sep 17 00:00:00 2001 From: Manu Date: Thu, 29 Oct 2026 23:06:46 +0100 Subject: [PATCH] Add missing test for 100% config flow coverage in `silvercrest_infrared` (#189498) --- .../silvercrest_infrared/test_config_flow.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/components/silvercrest_infrared/test_config_flow.py b/tests/components/silvercrest_infrared/test_config_flow.py index 6ab3d04fc08c..3eeee66b7a87 100644 --- a/tests/components/silvercrest_infrared/test_config_flow.py +++ b/tests/components/silvercrest_infrared/test_config_flow.py @@ -103,3 +103,30 @@ async def test_user_flow_no_emitters_receivers(hass: HomeAssistant) -> None: assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_infrared_entities" + + +@pytest.mark.usefixtures("mock_infrared_emitter_entity", "mock_setup_entry") +async def test_user_flow_requires_emitter( + hass: HomeAssistant, +) -> None: + """Test user flow requires an infrared emitter or receiver.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER} + ) + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + user_input={CONF_DEVICE_TYPE: SilverCrestIrDeviceType.STVD45A1}, + ) + + assert result["type"] is FlowResultType.FORM + assert result["errors"] == {"base": "missing_infrared_entity"} + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + user_input={ + CONF_DEVICE_TYPE: SilverCrestIrDeviceType.STVD45A1, + CONF_INFRARED_ENTITY_ID: EMITTER_ENTITY_ID, + }, + ) + assert result["type"] is FlowResultType.CREATE_ENTRY