From 5177d022e8c01986b95f116a0c0900298d6d53f3 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" <nick@koston.org>
Date: Fri, 26 Jan 2024 17:55:26 -1000
Subject: [PATCH] Switch imap to use async_update_reload_and_abort helper
 (#108935)

---
 homeassistant/components/imap/config_flow.py | 4 +---
 tests/components/imap/test_config_flow.py    | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/homeassistant/components/imap/config_flow.py b/homeassistant/components/imap/config_flow.py
index 70594d5fd7c..dea7a0e2e71 100644
--- a/homeassistant/components/imap/config_flow.py
+++ b/homeassistant/components/imap/config_flow.py
@@ -169,11 +169,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
         if user_input is not None:
             user_input = {**self._reauth_entry.data, **user_input}
             if not (errors := await validate_input(self.hass, user_input)):
-                self.hass.config_entries.async_update_entry(
+                return self.async_update_reload_and_abort(
                     self._reauth_entry, data=user_input
                 )
-                await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
-                return self.async_abort(reason="reauth_successful")
 
         return self.async_show_form(
             description_placeholders={
diff --git a/tests/components/imap/test_config_flow.py b/tests/components/imap/test_config_flow.py
index d36cffbce06..8c91797ae92 100644
--- a/tests/components/imap/test_config_flow.py
+++ b/tests/components/imap/test_config_flow.py
@@ -239,6 +239,7 @@ async def test_reauth_success(hass: HomeAssistant, mock_setup_entry: AsyncMock)
                 CONF_PASSWORD: "test-password",
             },
         )
+        await hass.async_block_till_done()
 
     assert result2["type"] == FlowResultType.ABORT
     assert result2["reason"] == "reauth_successful"
-- 
GitLab