Add user_input as suggested value in imap config flow (#89982)
Add user_input as suggested value to config_schema
This commit is contained in:
parent
e4275a053c
commit
51b12cbf96
2 changed files with 8 additions and 3 deletions
|
@ -91,9 +91,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
return self.async_create_entry(title=title, data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||
)
|
||||
schema = self.add_suggested_values_to_schema(STEP_USER_DATA_SCHEMA, user_input)
|
||||
return self.async_show_form(step_id="user", data_schema=schema, errors=errors)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
"""Perform reauth upon an API authentication error."""
|
||||
|
|
|
@ -129,6 +129,12 @@ async def test_form_cannot_connect(hass: HomeAssistant, exc: Exception) -> None:
|
|||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
# make sure we do not lose the user input if somethings gets wrong
|
||||
assert {
|
||||
key: key.description.get("suggested_value")
|
||||
for key in result2["data_schema"].schema
|
||||
} == MOCK_CONFIG
|
||||
|
||||
|
||||
async def test_form_invalid_charset(hass: HomeAssistant) -> None:
|
||||
"""Test we handle invalid charset."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue