Fetch the Marketplace README again after an install or uninstall (#191129)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexander Hass
2026-11-08 14:44:13 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent e6efc39302
commit ee918c6136
2 changed files with 54 additions and 0 deletions
@@ -1015,6 +1015,7 @@ class Repository:
self.data.installed_version = None
self.data.installed_commit = None
self._clear_readme_cache()
self.async_dispatch_changed("uninstall")
await self.async_remove_entity_device()
@@ -1179,8 +1180,19 @@ class Repository:
"""Forget the version picked for the install and end its progress."""
self.data.selected_tag = None
self.force_branch = False
# Clear it first, the panel asks for the page right after it hears of the end
self._clear_readme_cache()
self._async_dispatch_install_progress(False)
def _clear_readme_cache(self) -> None:
"""Clear the cached README, so the next info request fetches it again.
The cached README is of the version installed before, whose addresses
can point at files the version installed now no longer has.
"""
self.additional_info = ""
self.updated_info = False
async def async_post_installation(self) -> None:
"""Run post install steps."""
@@ -2751,6 +2751,48 @@ async def test_install_from_the_catalog(
assert_api_usage(aioclient_mock, snapshot)
@pytest.mark.parametrize("github_token", [None])
async def test_repository_page_shows_the_readme_of_the_installed_version(
hass: HomeAssistant,
marketplace: MarketplaceManager,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test the README follows an update and an uninstall, as the page asks for it."""
repository = marketplace.repositories.get_by_full_name(REPOSITORY_INTEGRATION)
client = await hass_ws_client(hass)
async def readme() -> str:
await client.send_json_auto_id(
{"type": "marketplace/repository/info", "repository_id": repository.data.id}
)
response = await client.receive_json()
assert response["success"]
return response["result"]["additional_info"]
# The catalog names 1.0.0
assert (await _install(hass, hass_ws_client, repository.data.id))["success"]
assert "(1.0.0)" in await readme()
# 2.0.0 is not the version of the catalog, it comes through the GitHub API
await client.send_json_auto_id(
{
"type": "marketplace/repository/install",
"repository": repository.data.id,
"version": "2.0.0",
}
)
assert (await client.receive_json())["success"]
assert repository.data.installed_version == "2.0.0"
assert "(2.0.0)" in await readme()
await client.send_json_auto_id(
{"type": "marketplace/repository/uninstall", "repository": repository.data.id}
)
assert (await client.receive_json())["success"]
# Not installed, the page shows the README of the version the catalog names
assert "(1.0.0)" in await readme()
@pytest.mark.parametrize("github_token", [None])
@pytest.mark.parametrize("category_test_data", category_test_data_parametrized())
async def test_install_custom_repository(