Files
bvandeusenandClaude Opus 5.5 4dcf958022
CI / lint (push) Successful in 4s
CI / integration (push) Successful in 55s
CI / unit (push) Successful in 1m18s
CI / publish (push) Successful in 1m28s
feat(dashboard): widgets fit their content; wide screens get more grid columns (#5249)
Each widget is as tall as its content, never taller than its saved height
(where it scrolls). The dashboard is capped at 2400px instead of 1400px.
Past 12 columns' worth of width it adds columns (one per 110px, up to 24)
and places widgets again in reading order at their saved widths, so more sit
side by side instead of stretching. Edit mode shows and saves the
12-column layout, so a layout doesn't depend on the screen it was edited on.

The share view uses the same layout code (static/dash-layout.js).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:10:42 -04:00

41 lines
2.0 KiB
Python

"""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 <wall>"),
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 &lt;wall&gt;" in page and "<title>Ops &lt;wall&gt; — Steward</title>" in page
assert '<div class="empty-state">This dashboard has no widgets.</div>' 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
async def test_the_share_view_fits_and_widens_like_the_dashboard(app):
"""#5249: each cell carries its saved place for static/dash-layout.js, which
fits it to its content and adds columns on a wide screen."""
gw = SimpleNamespace(id=7, grid_x=6, grid_y=2, grid_w=6, grid_h=3)
item = SimpleNamespace(db=gw, title="Hosts", hx_url="/w/hosts?id=7", defn=SimpleNamespace(poll=False))
page = await _share_view(app, [item])
assert 'data-id="7"' in page and 'data-x="6" data-y="2" data-w="6" data-h="3"' in page
assert "/static/dash-layout.js" in page and "StewardDashLayout" in page