diff --git a/tests/test_intents_registration.py b/tests/test_intents_registration.py index ad593ac..be310ad 100644 --- a/tests/test_intents_registration.py +++ b/tests/test_intents_registration.py @@ -1044,6 +1044,38 @@ class TestTheButtons: modules.media.intent_am_start_command(intent, {"id": "7"}) ] + async def test_an_uninstalled_app_fails_the_press_honestly(self, modules): + """The plan's acceptance: a package that is gone must not press silently. + + The device is the authority here — its own sentence is what the error + carries, so the user learns WHICH component vanished instead of seeing a + button that did nothing. + """ + import homeassistant.exceptions as ha_exceptions + + intent = { + **NETFLIX_INTENT, + "fields": [{"key": "id", "type": "string", "default": "7"}], + } + entry, added = await self._setup( + modules, {CONF_REGISTERED_INTENTS: [intent]} + ) + poller = _RecordingPoller( + "Starting: Intent { act=android.intent.action.VIEW }\n" + "Error: Activity class {com.netflix.ninja/.MainActivity} does not exist." + ) + entry.runtime_data = _manager(poller) + added[0]._manager = _manager(poller) + added[0].entity_id = "button.shield_netflix_open_a_title" + + with pytest.raises(ha_exceptions.ServiceValidationError) as caught: + await added[0].async_press() + + assert caught.value.translation_key == "intent_failed" + assert "does not exist" in str(caught.value) + assert "com.netflix.ninja/.MainActivity" in str(caught.value) + assert len(poller.commands) == 1, "attempted once, never retried" + async def test_a_button_with_no_manager_fails_loudly(self, modules): """A press that cannot reach the Shield RAISES — it never no-ops.