From 66846b2f825564ef522aa36cd04e1e8116858a6f Mon Sep 17 00:00:00 2001 From: James Mackay Date: Mon, 12 Oct 2026 13:00:24 +0100 Subject: [PATCH] test(intents): the button's uninstalled-app press, with the device's own words (t17) Acceptance item 3 named this case explicitly: a registered intent whose app is gone must fail the press HONESTLY. The device's sentence is what the error carries ('does not exist', naming the component), the press is attempted exactly once, and it raises rather than doing nothing. --- tests/test_intents_registration.py | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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.