diff --git a/.github/workflows/board_tests.yml b/.github/workflows/board_tests.yml new file mode 100644 index 0000000000..a9fd644b25 --- /dev/null +++ b/.github/workflows/board_tests.yml @@ -0,0 +1,21 @@ +name: Board tests +on: + pull_request: + push: + branches: [main] +permissions: + contents: read +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: PyAutoLabs/PyAutoBrain + path: PyAutoBrain + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: python -m pip install pytest pyyaml + - run: python -m pytest tests -q diff --git a/scripts/board.py b/scripts/board.py index 738638abef..ead86749d3 100644 --- a/scripts/board.py +++ b/scripts/board.py @@ -651,7 +651,7 @@ def _row_html(key: str, r: dict) -> str: def _section_html(key: str, rows: list, snap: dict) -> str: if not rows: return "" - head = (f"

{_esc(_TITLES[key])} ({len(rows)})" + head = (f"

{_esc(_TITLES[key])} ({len(rows)})" "

") extra = "" # "Void all due" covers the Gut and sibling repos alike: it sits on the @@ -681,14 +681,16 @@ def _boards_nav(snap: dict) -> str: def _render_html(snap: dict) -> str: t_ = theme() - c = counts(snap) st = status(snap) tone = {"green": "ok", "yellow": "warn", "grey": "muted"}[st] - stats = t_.stats((c["due"], "due"), (c["transit"], "in transit"), - (c["held"], "held"), (c["orphans"], "orphans"), - (c["dangling"] + c["voided_pending"], "dangling"), - (c["history"], "history-only")) \ - if hasattr(t_, "stats") else "" + navigation = [{"href": "#inventory", "label": "Inventory"}] + navigation.extend( + {"href": "#bucket-" + key, "label": _TITLES[key], "count": len(rows)} + for key in BUCKETS + if (rows := (snap.get("buckets") or {}).get(key)) + ) + if snap.get("voided"): + navigation.append({"href": "#voided", "label": "Recently voided", "count": len(snap["voided"])}) sections = "".join(_section_html(k, (snap.get("buckets") or {}).get(k) or [], snap) for k in BUCKETS) if not snap.get("refs_listed"): @@ -699,7 +701,7 @@ def _render_html(snap: dict) -> str: sections = "

The Gut is empty.

" voided = "" if snap.get("voided"): - voided = "

Recently voided

" + "".join( + voided = "

Recently voided

" + "".join( f"

#{v['number']}" f" {_esc(v['title'])} " f"{_esc(str(v.get('closed_at'))[:10])}

" @@ -719,14 +721,13 @@ def _render_html(snap: dict) -> str: -{t_.hero(BOARD_KEY, "Dashboard", _LEDE)} +{t_.hero(BOARD_KEY, "Dashboard", _LEDE, navigation=navigation)}

{st.upper()} {_esc(_summary(snap))}

-{stats}

{snap.get('ref_count', 0)} refs on the remote · {snap.get('entry_count', 0)} ledger entries · as of {_esc(snap.get('today'))} · markdown version{gh_link}

-{sections} +
{sections}
{voided} {errors} {_boards_nav(snap)} diff --git a/tests/fixtures/brain/board/_theme.py b/tests/fixtures/brain/board/_theme.py index 87f3879be5..2c1a8f5e6c 100644 --- a/tests/fixtures/brain/board/_theme.py +++ b/tests/fixtures/brain/board/_theme.py @@ -8,7 +8,7 @@ def css(key): return f":root{{--accent:#000}} /* theme:{key} */" -def hero(key, kind, lede_html=""): +def hero(key, kind, lede_html="", *, navigation=()): return f'
PyAuto{key} {kind}
{lede_html}'