mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Fix HEOS user initiated setup when discovery is waiting confirmation (#140119)
This commit is contained in:
parent
fd2dee3c11
commit
323bc54efc
@ -205,7 +205,7 @@ class HeosFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Obtain host and validate connection."""
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
await self.async_set_unique_id(DOMAIN, raise_on_progress=False)
|
||||
self._abort_if_unique_id_configured(error="single_instance_allowed")
|
||||
# Try connecting to host if provided
|
||||
errors: dict[str, str] = {}
|
||||
|
@ -88,6 +88,35 @@ async def test_create_entry_when_host_valid(
|
||||
assert controller.disconnect.call_count == 1
|
||||
|
||||
|
||||
async def test_manual_setup_with_discovery_in_progress(
|
||||
hass: HomeAssistant,
|
||||
discovery_data: SsdpServiceInfo,
|
||||
controller: MockHeos,
|
||||
system: HeosSystem,
|
||||
) -> None:
|
||||
"""Test user can manually set up when discovery is in progress."""
|
||||
# Single discovered, selects preferred host, shows confirm
|
||||
controller.get_system_info.return_value = system
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_data
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm_discovery"
|
||||
|
||||
# Setup manually
|
||||
user_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
assert user_result["type"] is FlowResultType.FORM
|
||||
user_result = await hass.config_entries.flow.async_configure(
|
||||
user_result["flow_id"], user_input={CONF_HOST: "127.0.0.1"}
|
||||
)
|
||||
assert user_result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
# Discovery flow is removed
|
||||
assert not hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
|
||||
|
||||
async def test_discovery(
|
||||
hass: HomeAssistant,
|
||||
discovery_data: SsdpServiceInfo,
|
||||
|
Loading…
x
Reference in New Issue
Block a user