Files
FabledSteward/tests/test_share_view.py
T
bvandeusenandClaude Opus 5.5 e864cd4b6c feat(ui): share view on steward.css; breadcrumbs everywhere they belong; focus ring; tables scroll in their card (#5095)
#5095 "Share view on the shared stylesheet; breadcrumbs, focus-visible and
wide tables".

- dashboard/share_view.html loads theme.css and steward.css; its own copy of
  the old purple palette is gone. Only the read-only frame and the x/y/w/h
  grid stay inline, written in tokens. HEX_CEILING 75 -> 58.
- Breadcrumbs on settings/general, settings/thresholds, the dashboard share
  page and share-link-created. tests/test_breadcrumbs.py fails on any page
  extending base.html without a crumbs() trail, unless it is on the named
  list of section top pages, logged-out and error pages (rule 134).
- :focus-visible draws --fs-focus-ring on links, buttons, summaries, inputs
  and anything with tabindex.
- Any card holding a .table scrolls sideways (card:has(table.table)), so a
  wide table no longer widens the page at phone width; .card-flush scrolls
  too, main gets min-width:0, and .table-wrap covers a table outside a card.
- tests/test_share_view.py renders the share view: shared sheets, no hex
  colour, escaped name, widgets loading through the share token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 14:37:39 -04:00

31 lines
1.4 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