"""Opening ESP Screens. App 0.2.58: the page asks for the full inventory and opens the live stream at the same time. An add-on that is building firmware answers the stream first, whose light payload has screens but no entities, so a screen opened then had an empty catalogue: the entity list said "No entities found" and the tiles showed entity ids until a filter chip was pressed. The first full inventory now draws those parts again. App 0.2.65: the page no longer opens the first screen by itself; the owner picks one. Until then a card asks for that, or offers the install when there are no screens yet. A screen picked before the full inventory arrives still gets its entity names from the redraw above. """ import re import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] SCRIPT = (ROOT / 'screen_manager/app/static/app.js').read_text() PAGE = (ROOT / 'screen_manager/app/static/index.html').read_text() def function(name): start = SCRIPT.index(f'function {name}(') return SCRIPT[start:SCRIPT.index('\n}\n', start)] class Startup(unittest.TestCase): def test_no_screen_opens_by_itself(self): self.assertNotIn('inventory.screens[0]', SCRIPT) # The one way into a screen is its button in the list. self.assertEqual(re.findall(r'(?(.*?)', PAGE, re.S) self.assertTrue(choose, 'hidden until the first inventory') self.assertIn('

Choose a screen

', choose[1]) self.assertNotIn('