"""The public share view draws with the same stylesheet as every other page (#5095): no palette of its own, so it can never drift from the tokens again.""" from types import SimpleNamespace from quart import render_template from tests.test_style_tokens import hex_colours async def _share_view(app, widgets) -> str: async with app.test_request_context("/share/t0ken"): return await render_template( "dashboard/share_view.html", dashboard=SimpleNamespace(name="Ops "), widgets=widgets, raw_token="t0ken", poll_interval=30) async def test_the_share_view_uses_the_shared_stylesheet(app): page = await _share_view(app, []) assert "/static/theme.css" in page and "/static/steward.css" in page assert not hex_colours(page), hex_colours(page) assert "Ops <wall>" in page and "Ops <wall> — Steward" in page assert '
This dashboard has no widgets.
' in page async def test_each_widget_loads_through_the_share_token(app): gw = SimpleNamespace(id=7, grid_x=0, grid_y=2, grid_w=6, grid_h=3) item = SimpleNamespace(db=gw, title="Hosts", hx_url="/w/hosts?id=7", defn=SimpleNamespace(poll=True)) page = await _share_view(app, [item]) assert 'hx-get="/w/hosts?id=7&s=t0ken"' in page assert "grid-column:1 / span 6;grid-row:3 / span 3;" in page and "every 30s" in page