Fix ended session when there isn't any response from the user (#72218)

* Fix end session when there isn't any response

This PR fixes #72153

* Added test case as requested

https://github.com/home-assistant/core/pull/72218#discussion_r881584812
This commit is contained in:
w35l3y 2022-06-03 10:32:22 -03:00 committed by GitHub
parent 88129dbe91
commit beab6e2e5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 12 deletions

View file

@ -38,6 +38,8 @@ async def test_intent_script(hass):
assert response.speech["plain"]["speech"] == "Good morning Paulus"
assert not (response.reprompt)
assert response.card["simple"]["title"] == "Hello Paulus"
assert response.card["simple"]["content"] == "Content for Paulus"
@ -85,3 +87,49 @@ async def test_intent_script_wait_response(hass):
assert response.card["simple"]["title"] == "Hello Paulus"
assert response.card["simple"]["content"] == "Content for Paulus"
async def test_intent_script_falsy_reprompt(hass):
"""Test intent scripts work."""
calls = async_mock_service(hass, "test", "service")
await async_setup_component(
hass,
"intent_script",
{
"intent_script": {
"HelloWorld": {
"action": {
"service": "test.service",
"data_template": {"hello": "{{ name }}"},
},
"card": {
"title": "Hello {{ name }}",
"content": "Content for {{ name }}",
},
"speech": {
"type": "ssml",
"text": '<speak><amazon:effect name="whispered">Good morning {{ name }}</amazon:effect></speak>',
},
"reprompt": {"text": "{{ null }}"},
}
}
},
)
response = await intent.async_handle(
hass, "test", "HelloWorld", {"name": {"value": "Paulus"}}
)
assert len(calls) == 1
assert calls[0].data["hello"] == "Paulus"
assert (
response.speech["ssml"]["speech"]
== '<speak><amazon:effect name="whispered">Good morning Paulus</amazon:effect></speak>'
)
assert not (response.reprompt)
assert response.card["simple"]["title"] == "Hello Paulus"
assert response.card["simple"]["content"] == "Content for Paulus"