feat: phases 77–80 — navbar view refresh, static background, API tokens, history suggestion chips
Single consolidated commit for four completed, validated phases (77, 78, 79, 80). The pipeline run left all work uncommitted because the harness commits only with PHASE_COMMIT=1 while child executors are forbidden from committing; the phases themselves all passed validation and moved to .agents/phases/complete/. Phase 77 — navbar view refresh - router.js dispatches bor:view-refresh on re-show / active re-click / popstate (gated on wasMounted; first show and boot exempt) - History / RAG / Sources / Tuning re-fetch on refresh (admin branch); Chat deliberately excluded (stream survival) - History "Refresh" button (admin-only, in-flight disable + status line) - New story suite tests/e2e/test_navbar_refresh.py (7 tests) Phase 78 — static background - Removed the animated glow layers; static 44px grid over the flat --bg canvas; default and reduced-motion renders byte-identical - Updated background/theme E2E suites; removed bg-glow test pins Phase 79 — API tokens - api_tokens model + migration 0012; hash-only token service - Admin tokens API + Tokens admin view; POST /api/token-auth; live-revoking require_user on chat / suggestions / document content - Frontend token gate with localStorage cache; anonymous E2E suites migrated to token login - New story suite tests/e2e/test_api_tokens.py (9 tests) Phase 80 — history suggestion chips - last_questions() endpoint with SEED fallback; startNewChat() refetch - Seed-semantics docs (config.py, .env.example, README) - Integration state matrix + E2E suite rewritten to the 4 chip states Also included: phase-76 report artifacts and the repo restore-test-db skill (previously untracked), scripts/* ruff fixes from phase 77. Final gate state (phase 80 final pass, covers everything above): - uv run pytest --cov=app → 1637 passed, 0 failed, app/ coverage 99% - uv run ruff check . && uv run pyright → clean, 0 errors - Per-phase story E2E suites green in isolation
This commit is contained in:
@@ -113,6 +113,20 @@ def _open_menu(page: Page) -> None:
|
||||
expect(page.locator("#app-nav")).to_have_css("opacity", "1")
|
||||
|
||||
|
||||
def _js_open_menu(page: Page) -> None:
|
||||
"""Phase 79 (task 05): the in-app token gate is a full-viewport
|
||||
overlay for ANONYMOUS visitors — it physically covers the header,
|
||||
so a real click on #nav-toggle is intercepted by the gate (the gate
|
||||
is the only interactive surface; the header is locked out with the
|
||||
rest of the page). The binding is identical, so the menu contract
|
||||
is driven programmatically: a JS-dispatched click runs the exact
|
||||
same listener a real click would."""
|
||||
page.evaluate("() => document.querySelector('#nav-toggle').click()")
|
||||
expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "true")
|
||||
expect(page.locator("#app-nav")).to_have_class(re.compile(r"\bis-open\b"))
|
||||
expect(page.locator("#app-nav")).to_have_css("opacity", "1")
|
||||
|
||||
|
||||
def _assert_menu_closed(page: Page) -> None:
|
||||
expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "false")
|
||||
assert "is-open" not in (page.locator("#app-nav").get_attribute("class") or ""), (
|
||||
@@ -189,14 +203,19 @@ def test_anonymous_menu_contents(
|
||||
visible link — "Chat". The three admin-only links keep their
|
||||
ship-hidden state INSIDE the menu (the phase-19/35 contract is
|
||||
preserved by reusing the same <nav> element); opening flips
|
||||
aria-expanded true."""
|
||||
aria-expanded true.
|
||||
|
||||
Phase 79 (task 05): the anonymous visitor meets the token gate — a
|
||||
full-viewport overlay that covers the header — so the toggle is
|
||||
driven programmatically (the binding is identical; see
|
||||
_js_open_menu)."""
|
||||
page = _mobile_page(browser)
|
||||
try:
|
||||
page.goto(app_url)
|
||||
_wait_settled_anonymous(page)
|
||||
_assert_menu_closed(page)
|
||||
|
||||
_open_menu(page)
|
||||
_js_open_menu(page)
|
||||
assert _visible_nav_links(page) == ["Chat"], (
|
||||
"anonymous: the menu must show exactly one visible link (Chat)"
|
||||
)
|
||||
@@ -204,7 +223,7 @@ def test_anonymous_menu_contents(
|
||||
expect(page.locator(sel)).to_be_hidden()
|
||||
|
||||
# A second click closes it again — aria-expanded round-trips.
|
||||
page.click("#nav-toggle")
|
||||
page.evaluate("() => document.querySelector('#nav-toggle').click()")
|
||||
_assert_menu_closed(page)
|
||||
finally:
|
||||
page.close()
|
||||
@@ -284,8 +303,11 @@ def test_esc_and_outside_close(
|
||||
page.goto(app_url)
|
||||
_wait_settled_anonymous(page)
|
||||
|
||||
# Phase 79 (task 05): the anonymous visitor's toggle click is
|
||||
# intercepted by the gate overlay — drive the identical binding
|
||||
# programmatically (see _js_open_menu).
|
||||
# Esc closes + refocuses the opener.
|
||||
_open_menu(page)
|
||||
_js_open_menu(page)
|
||||
page.keyboard.press("Escape")
|
||||
_assert_menu_closed(page)
|
||||
assert page.evaluate("() => document.activeElement.id") == "nav-toggle", (
|
||||
@@ -294,8 +316,11 @@ def test_esc_and_outside_close(
|
||||
|
||||
# Outside click: the menu STAYS open (accepted behavior — the
|
||||
# locked close set is Esc + link + resize, not backdrop click).
|
||||
_open_menu(page)
|
||||
page.locator("footer span").first.click() # a neutral, non-link point
|
||||
# Phase 79 (task 05): for the anonymous visitor the "outside"
|
||||
# point is the gate overlay itself — a REAL mouse click below
|
||||
# the centered card (outside the nav, intercepted by the gate).
|
||||
_js_open_menu(page)
|
||||
page.mouse.click(10, 780) # the gate overlay — a neutral, non-nav point
|
||||
expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "true")
|
||||
assert "is-open" in (page.locator("#app-nav").get_attribute("class") or ""), (
|
||||
"accepted behavior: an outside click must NOT close the menu"
|
||||
@@ -339,8 +364,9 @@ def test_animation_and_reduced_motion(
|
||||
f"got {report['property']!r}"
|
||||
)
|
||||
# Opening flips class + aria together (the animated state).
|
||||
_open_menu(page)
|
||||
expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "true")
|
||||
# Phase 79 (task 05): the anonymous toggle click is intercepted
|
||||
# by the gate overlay — programmatic drive, same binding.
|
||||
_js_open_menu(page)
|
||||
page.keyboard.press("Escape")
|
||||
_assert_menu_closed(page)
|
||||
finally:
|
||||
@@ -363,7 +389,9 @@ def test_animation_and_reduced_motion(
|
||||
assert _stilled("#app-nav") == "0s", (
|
||||
f"reduced motion: closed state must not transition, got {_stilled('#app-nav')!r}"
|
||||
)
|
||||
rpage.click("#nav-toggle")
|
||||
# Phase 79 (task 05): programmatic drive (the gate overlay
|
||||
# intercepts the anonymous real click — same binding).
|
||||
_js_open_menu(rpage)
|
||||
expect(rpage.locator("#nav-toggle")).to_have_attribute("aria-expanded", "true")
|
||||
expect(rpage.locator("#app-nav")).to_have_class(re.compile(r"\bis-open\b"))
|
||||
assert _stilled("#app-nav") == "0s", (
|
||||
|
||||
Reference in New Issue
Block a user