@@ -2143,3 +2143,39 @@ async def test_ssdp_update_mac(hass: HomeAssistant) -> None:
21432143 # ensure mac was updated with new wifiMac value
21442144 assert entry .data [CONF_MAC ] == "aa:bb:cc:dd:ee:ff"
21452145 assert entry .unique_id == "123"
2146+
2147+
2148+ @pytest .mark .usefixtures ("remote_websocket" )
2149+ async def test_dhcp_while_user_flow_pending (hass : HomeAssistant ) -> None :
2150+ """Simulate pending user flow, then trigger DHCP before submit.
2151+
2152+ Covers https://github.com/home-assistant/core/issues/156591.
2153+ """
2154+ with patch (
2155+ "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info" ,
2156+ return_value = None , # Simulate device not connectable
2157+ ):
2158+ # Start user flow, which will show form (cannot connect)
2159+ result_user = await hass .config_entries .flow .async_init (
2160+ DOMAIN ,
2161+ context = {"source" : config_entries .SOURCE_USER },
2162+ )
2163+ assert result_user ["type" ] == FlowResultType .FORM
2164+ assert result_user ["step_id" ] == "user"
2165+
2166+ # While user flow is pending (form shown), trigger DHCP flow
2167+ dhcp_data = DhcpServiceInfo (
2168+ ip = "10.10.12.34" , macaddress = "aabbccddeeff" , hostname = "fake_hostname"
2169+ )
2170+ with patch (
2171+ "homeassistant.components.samsungtv.bridge.SamsungTVWSBridge.async_device_info" ,
2172+ return_value = {
2173+ "device" : {"modelName" : "fake_model" , "wifiMac" : "aa:bb:cc:dd:ee:ff" }
2174+ },
2175+ ):
2176+ result_dhcp = await hass .config_entries .flow .async_init (
2177+ DOMAIN ,
2178+ context = {"source" : config_entries .SOURCE_DHCP },
2179+ data = dhcp_data ,
2180+ )
2181+ assert result_dhcp ["type" ] == FlowResultType .ABORT
0 commit comments