Add an option to serve ES6 JS to clients (#10474)

* Add an option to serve ES6 JS to clients

* Rename es6 to latest

* Fixes

* Serve JS vrsions from separate dirs

* Revert websocket API change

* Update frontend to 20171110.0

* websocket: move request to constructor
This commit is contained in:
Andrey authored and Paulus Schoutsen committed 2017-11-10 23:02:06 -08:00
1 parent 1c36e2f586
commit 5e92fa3404
10 files changed
+150 -65

No files matched your search

+5 -1
View File
@@ -52,7 +52,7 @@ def test_frontend_and_static(mock_http_client):
# Test we can retrieve frontend.js
frontendjs = re.search(
r'(?P<app>\/static\/frontend-[A-Za-z0-9]{32}.html)', text)
r'(?P<app>\/frontend_es5\/frontend-[A-Za-z0-9]{32}.html)', text)
assert frontendjs is not None
resp = yield from mock_http_client.get(frontendjs.groups(0)[0])
@@ -63,6 +63,10 @@ def test_frontend_and_static(mock_http_client):
@asyncio.coroutine
def test_dont_cache_service_worker(mock_http_client):
"""Test that we don't cache the service worker."""
resp = yield from mock_http_client.get('/service_worker_es5.js')
assert resp.status == 200
assert 'cache-control' not in resp.headers
resp = yield from mock_http_client.get('/service_worker.js')
assert resp.status == 200
assert 'cache-control' not in resp.headers
+5 -5
View File
@@ -33,7 +33,7 @@ class TestPanelIframe(unittest.TestCase):
'panel_iframe': conf
})
@patch.dict('hass_frontend.FINGERPRINTS',
@patch.dict('hass_frontend_es5.FINGERPRINTS',
{'panels/ha-panel-iframe.html': 'md5md5'})
def test_correct_config(self):
"""Test correct config."""
@@ -55,20 +55,20 @@ class TestPanelIframe(unittest.TestCase):
panels = self.hass.data[frontend.DATA_PANELS]
assert panels.get('router').as_dict() == {
assert panels.get('router').to_response(self.hass, None) == {
'component_name': 'iframe',
'config': {'url': 'http://192.168.1.1'},
'icon': 'mdi:network-wireless',
'title': 'Router',
'url': '/static/panels/ha-panel-iframe-md5md5.html',
'url': '/frontend_es5/panels/ha-panel-iframe-md5md5.html',
'url_path': 'router'
}
assert panels.get('weather').as_dict() == {
assert panels.get('weather').to_response(self.hass, None) == {
'component_name': 'iframe',
'config': {'url': 'https://www.wunderground.com/us/ca/san-diego'},
'icon': 'mdi:weather',
'title': 'Weather',
'url': '/static/panels/ha-panel-iframe-md5md5.html',
'url': '/frontend_es5/panels/ha-panel-iframe-md5md5.html',
'url_path': 'weather',
}
+9 -3
View File
@@ -290,7 +290,7 @@ def test_get_panels(hass, websocket_client):
"""Test get_panels command."""
yield from hass.components.frontend.async_register_built_in_panel(
'map', 'Map', 'mdi:account-location')
hass.data[frontend.DATA_JS_VERSION] = 'es5'
websocket_client.send_json({
'id': 5,
'type': wapi.TYPE_GET_PANELS,
@@ -300,8 +300,14 @@ def test_get_panels(hass, websocket_client):
assert msg['id'] == 5
assert msg['type'] == wapi.TYPE_RESULT
assert msg['success']
assert msg['result'] == {url: panel.as_dict() for url, panel
in hass.data[frontend.DATA_PANELS].items()}
assert msg['result'] == {'map': {
'component_name': 'map',
'url_path': 'map',
'config': None,
'url': None,
'icon': 'mdi:account-location',
'title': 'Map',
}}
@asyncio.coroutine