diff --git a/tests/components/energenie_power_sockets/test_config_flow.py b/tests/components/energenie_power_sockets/test_config_flow.py index 1fddb60f987a..0339008dbbb2 100644 --- a/tests/components/energenie_power_sockets/test_config_flow.py +++ b/tests/components/energenie_power_sockets/test_config_flow.py @@ -44,15 +44,21 @@ async def test_user_flow_already_exists( mock_search_for_devices: MagicMock, ) -> None: """Test the flow when device has been already configured.""" - valid_config_entry.add_to_hass(hass) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, - data={CONF_DEVICE_API_ID: valid_config_entry.data[CONF_DEVICE_API_ID]}, ) + assert result["type"] is FlowResultType.FORM + assert not result["errors"] - await hass.async_block_till_done() + # Adding the entry before init would filter out the device and abort with no_device + valid_config_entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {CONF_DEVICE_API_ID: valid_config_entry.data[CONF_DEVICE_API_ID]}, + ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured"