Why This Matters
integrations/spook_inverse/config_flow.py is materially more complex than the main flow: it uses SchemaConfigFlowHandler with menu + per-platform form steps (Platform.BINARY_SENSOR, Platform.SWITCH), an options flow, and two registry-mutating callbacks async_config_flow_finished / async_options_flow_finished that flip hidden_by=RegistryEntryHider.INTEGRATION on the source entity. The unhide-on-remove logic in __init__.py:40-54 only fires when hidden_by is exactly INTEGRATION — a regression where some other component changed hidden_by first would silently leak a hidden entity. This is the second config flow the user implicitly cares about and the one where untested behavior has user-visible side-effects.
Approach
Add tests/integrations/spook_inverse/test_config_flow.py. Pre-register a fake source entity via PHACC's entity_registry fixture. Drive the menu → form → finished sequence for both binary_sensor and switch branches; assert the created entry has options["inverse_type"] set correctly by the set_inverse_type wrapper (config_flow.py:62-77). Then drive the options flow via hass.config_entries.options.async_init, toggling CONF_HIDE_SOURCE true→false and asserting the source entity's hidden_by transitions through INTEGRATION and back to None. Add a test_async_remove_entry_unhides_source that exercises the guard in __init__.py:51 — a source entity hidden by something other than INTEGRATION must NOT be unhidden.
Acceptance Criteria
Risks & Caveats
The entity_selector_without_own_entities import comes from homeassistant.helpers.schema_config_entry_flow — this is an internal HA helper whose signature can shift between releases. The test will be the first place that breaks on an HA bump, which is good (early warning) but means you'll need a clear failure mode. The InverseBinarySensor/Switch entities themselves are not covered by this issue — leave platform tests for a follow-up.
Scores
- Impact: ███████░░░ 7/10
- Difficulty: █████░░░░░ 5/10
- Short-Term ROI: ███████░░░ 7/10
- Long-Term Value: ████████░░ 8/10
Priority
Immediate
Dependencies
#1257, #1258
Why This Matters
integrations/spook_inverse/config_flow.pyis materially more complex than the main flow: it usesSchemaConfigFlowHandlerwith menu + per-platform form steps (Platform.BINARY_SENSOR,Platform.SWITCH), an options flow, and two registry-mutating callbacksasync_config_flow_finished/async_options_flow_finishedthat fliphidden_by=RegistryEntryHider.INTEGRATIONon the source entity. The unhide-on-remove logic in__init__.py:40-54only fires whenhidden_byis exactlyINTEGRATION— a regression where some other component changedhidden_byfirst would silently leak a hidden entity. This is the second config flow the user implicitly cares about and the one where untested behavior has user-visible side-effects.Approach
Add
tests/integrations/spook_inverse/test_config_flow.py. Pre-register a fake source entity via PHACC'sentity_registryfixture. Drive the menu → form → finished sequence for bothbinary_sensorandswitchbranches; assert the created entry hasoptions["inverse_type"]set correctly by theset_inverse_typewrapper (config_flow.py:62-77). Then drive the options flow viahass.config_entries.options.async_init, togglingCONF_HIDE_SOURCEtrue→false and asserting the source entity'shidden_bytransitions throughINTEGRATIONand back toNone. Add atest_async_remove_entry_unhides_sourcethat exercises the guard in__init__.py:51— a source entity hidden by something other thanINTEGRATIONmust NOT be unhidden.Acceptance Criteria
binary_sensorandswitchconfig paths produce a valid entryCONF_HIDE_SOURCEand updates the registryasync_remove_entryunhides onlyRegistryEntryHider.INTEGRATIONentitiesentity_selector_without_own_entitiesdoes not include the spook_inverse entity in its choices (covers a known footgun)Risks & Caveats
The
entity_selector_without_own_entitiesimport comes fromhomeassistant.helpers.schema_config_entry_flow— this is an internal HA helper whose signature can shift between releases. The test will be the first place that breaks on an HA bump, which is good (early warning) but means you'll need a clear failure mode. The InverseBinarySensor/Switch entities themselves are not covered by this issue — leave platform tests for a follow-up.Scores
Priority
Immediate
Dependencies
#1257, #1258