Skip to content

Commit

Permalink
Add static routes for frontend modern and legacy service workers (hom…
Browse files Browse the repository at this point in the history
…e-assistant#120488) (home-assistant#122174)

* Bump frontend to 20240719.0

* restore home-assistant#120488
  • Loading branch information
bramkragten authored Jul 19, 2024
1 parent f006716 commit 6788c43
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion homeassistant/components/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
static_paths_configs: list[StaticPathConfig] = []

for path, should_cache in (
("service_worker.js", False),
("sw-modern.js", False),
("sw-modern.js.map", False),
("sw-legacy.js", False),
("sw-legacy.js.map", False),
("robots.txt", False),
("onboarding.html", not is_dev),
("static", not is_dev),
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"documentation": "https://www.home-assistant.io/integrations/frontend",
"integration_type": "system",
"quality_scale": "internal",
"requirements": ["home-assistant-frontend==20240710.0"]
"requirements": ["home-assistant-frontend==20240719.0"]
}
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ habluetooth==3.1.3
hass-nabucasa==0.81.1
hassil==1.7.4
home-assistant-bluetooth==1.12.2
home-assistant-frontend==20240710.0
home-assistant-frontend==20240719.0
home-assistant-intents==2024.7.10
httpx==0.27.0
ifaddr==0.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ hole==0.8.0
holidays==0.53

# homeassistant.components.frontend
home-assistant-frontend==20240710.0
home-assistant-frontend==20240719.0

# homeassistant.components.conversation
home-assistant-intents==2024.7.10
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ hole==0.8.0
holidays==0.53

# homeassistant.components.frontend
home-assistant-frontend==20240710.0
home-assistant-frontend==20240719.0

# homeassistant.components.conversation
home-assistant-intents==2024.7.10
Expand Down
7 changes: 5 additions & 2 deletions tests/components/frontend/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ async def test_frontend_and_static(mock_http_client: TestClient) -> None:
assert "public" in resp.headers.get("cache-control")


async def test_dont_cache_service_worker(mock_http_client: TestClient) -> None:
@pytest.mark.parametrize("sw_url", ["/sw-modern.js", "/sw-legacy.js"])
async def test_dont_cache_service_worker(
mock_http_client: TestClient, sw_url: str
) -> None:
"""Test that we don't cache the service worker."""
resp = await mock_http_client.get("/service_worker.js")
resp = await mock_http_client.get(sw_url)
assert resp.status == 200
assert "cache-control" not in resp.headers

Expand Down

0 comments on commit 6788c43

Please sign in to comment.