"""Every admin page links to every other admin page.
Two pages had drifted in opposite directions -- providers.html was missing
Proficiency and proficiency.html was missing Providers -- so you could not
navigate between them in either direction without editing the URL. Neither
gap was noticeable from the page you were on, which is why a test is worth
more here than care.
The page list is derived from the routes the router actually serves, so a
new admin page fails this until it is linked from the others, rather than
quietly launching unreachable.
The links render client-side now: navbar.js builds them from its
NAV_LINKS array into the empty
every page ships, so
statically parsing each page for anchors would report every link missing
on every page. The invariant the old parse guarded -- a complete list,
present everywhere -- moved with the list itself: it is defined exactly
once (in navbar.js, as complete as the route table) and every page carries
the mount that renders it. Hardcoded - entries are
how the pages drifted originally, so their return fails this too. The
active-page highlighting lives in tests/test_admin_js_units.py, which
runs navbar.js's real activeNavHref through node.
"""
from __future__ import annotations
import re
from pathlib import Path
import pytest
FRONTEND = Path(__file__).resolve().parent.parent / "admin" / "frontend"
NAVBAR_JS = FRONTEND / "navbar.js"
# href -> file that serves it. Kept explicit rather than globbed so that
# adding a page is a deliberate two-line edit here, not an accident.
PAGES = {
"/admin/": "index.html",
"/admin/models": "models.html",
"/admin/profiles": "profiles.html",
"/admin/proficiency": "proficiency.html",
"/admin/decisions": "decisions.html",
"/admin/quota": "quota.html",
"/admin/controls": "controls.html",
"/admin/providers": "providers.html",
}
# The nav renders every page except the landing page, which is reached by
# the logo -- a second door to the same place, in the row where width is
# scarcest. Order is the order the bar displays.
NAV_HREFS = list(PAGES)[1:]
NAV_LINKS_BEGIN = "/* NAV_LINKS:BEGIN */"
NAV_LINKS_END = "/* NAV_LINKS:END */"
NAV_RE = re.compile(r'