show sync button for admin
This commit is contained in:
@@ -10,8 +10,10 @@ Pinned design (PLAN §7.4 note / phase 14):
|
||||
* save points: user message on send, brain message on ``done``;
|
||||
* every ``localStorage`` access wrapped in try/catch (failure-safe);
|
||||
* size budget ~700k chars, oldest dropped first;
|
||||
* ``#new-chat-btn`` in the shared header bar (chat, sources, viewer —
|
||||
phase 19, owner permission 2026-08-23), ≥44px, ghost pill.
|
||||
* ``#new-chat-btn`` chat-page only — phase 19 shipped it in the shared
|
||||
bar (chat, sources, viewer, owner permission 2026-08-23); it moved
|
||||
from the navbar to index.html's .chat-shell at owner request
|
||||
(2026-08-28). ≥44px, solid brand pill.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -22,7 +24,10 @@ FRONTEND = Path(__file__).resolve().parents[2] / "frontend"
|
||||
APP_JS = FRONTEND / "assets" / "app.js"
|
||||
INDEX_HTML = FRONTEND / "index.html"
|
||||
SOURCES_HTML = FRONTEND / "sources.html"
|
||||
GIT_SOURCES_HTML = FRONTEND / "git-sources.html"
|
||||
DOCUMENT_HTML = FRONTEND / "document.html"
|
||||
LOGIN_HTML = FRONTEND / "login.html"
|
||||
TUNING_HTML = FRONTEND / "tuning.html"
|
||||
STYLES_CSS = FRONTEND / "assets" / "styles.css"
|
||||
|
||||
|
||||
@@ -151,53 +156,58 @@ def test_new_chat_clears_key_and_ui() -> None:
|
||||
assert "removeItem(STORAGE_KEY)" in js
|
||||
|
||||
|
||||
def test_new_chat_button_in_the_shared_header_bar() -> None:
|
||||
"""#new-chat-btn is a real type=button with an accessible name in the
|
||||
chat header (index.html). Phase 19 (owner permission 2026-08-23): it
|
||||
is part of the SHARED bar — it also appears in sources.html and the
|
||||
document viewer, where it means "go to the chat, fresh" (the
|
||||
clear-storage + navigate binding is pinned in test_shared_header.py)."""
|
||||
for html in (INDEX_HTML, SOURCES_HTML, DOCUMENT_HTML):
|
||||
text = html.read_text(encoding="utf-8")
|
||||
btn = re.search(r'<button[^>]*id="new-chat-btn"[^>]*>', text)
|
||||
assert btn, f"{html.name} must contain #new-chat-btn"
|
||||
tag = btn.group(0)
|
||||
assert 'type="button"' in tag
|
||||
assert 'aria-label="New chat"' in tag
|
||||
# Chat page specifics: the button sits after the nav, inside the header.
|
||||
def test_new_chat_button_lives_only_on_the_chat_page() -> None:
|
||||
"""#new-chat-btn is a real type=button with an accessible name. Moved
|
||||
from the shared header bar to the chat page at owner request
|
||||
(2026-08-28): it lives ONLY in index.html — inside <main>, in
|
||||
.chat-shell, above the #messages section (the single module binding
|
||||
+ the no-op guard are pinned in test_shared_header.py)."""
|
||||
html = _index()
|
||||
btn = re.search(r'<button[^>]*id="new-chat-btn"[^>]*>', html)
|
||||
assert btn, "index.html must contain #new-chat-btn"
|
||||
nav_idx = html.find('<nav class="app-nav"')
|
||||
assert nav_idx != -1 and btn.start() > nav_idx, (
|
||||
"the button belongs after the nav, inside .header-inner"
|
||||
)
|
||||
tag = btn.group(0)
|
||||
assert 'type="button"' in tag
|
||||
assert 'aria-label="New chat"' in tag
|
||||
main_idx = html.find('main id="main"')
|
||||
assert main_idx != -1 and btn.start() < main_idx, "the button belongs in the header"
|
||||
assert main_idx != -1 and btn.start() > main_idx, "the button belongs inside <main>"
|
||||
shell_idx = html.find('class="container chat-shell"')
|
||||
assert shell_idx != -1 and shell_idx < btn.start(), "the button belongs in .chat-shell"
|
||||
messages_idx = html.find('id="messages"')
|
||||
assert messages_idx != -1 and btn.start() < messages_idx, (
|
||||
"the button sits above the #messages section"
|
||||
)
|
||||
# No other page carries the button anymore (owner request 2026-08-28).
|
||||
for other in (SOURCES_HTML, GIT_SOURCES_HTML, DOCUMENT_HTML, LOGIN_HTML, TUNING_HTML):
|
||||
assert 'id="new-chat-btn"' not in other.read_text(encoding="utf-8"), (
|
||||
f"{other.name}: the New chat button is chat-page only"
|
||||
)
|
||||
|
||||
|
||||
def test_new_chat_button_style_contract() -> None:
|
||||
"""Ghost pill like a nav link: Phase-08 tokens, ≥44px target, hover like
|
||||
.nav-link, focus-visible via the global rule; icon-only on phones with
|
||||
the label hidden (aria-label keeps the accessible name)."""
|
||||
"""Solid brand pill (the 2026-08-28 rebrand; it was a ghost): --bg
|
||||
text on --brand (5.2:1 per the token note — WCAG AA), borderless,
|
||||
≥44px target; hover lightens the brand fill; focus-visible via the
|
||||
global rule. On the chat page the label stays visible even ≤640px
|
||||
(the button is in .chat-shell, not the navbar) with the plus icon
|
||||
hidden (aria-label keeps the accessible name either way)."""
|
||||
css = _css()
|
||||
block = re.search(r"\.new-chat-btn \{([\s\S]*?)\n\}", css)
|
||||
assert block, "styles.css must style .new-chat-btn"
|
||||
body = block.group(1)
|
||||
assert "min-height: 44px" in body
|
||||
assert "border-radius: 999px" in body
|
||||
assert "var(--line)" in body, "ghost: 1px line border, transparent background"
|
||||
assert "background: transparent" in body
|
||||
assert "var(--ink-soft)" in body
|
||||
assert "border: 0" in body
|
||||
assert "background: var(--brand)" in body, "solid brand fill (the rebrand)"
|
||||
assert "color: var(--bg)" in body, "--bg text on --brand = 5.2:1 (AA)"
|
||||
hover = re.search(r"\.new-chat-btn:hover \{([\s\S]*?)\n\}", css)
|
||||
assert hover and "--brand-soft" in hover.group(1) and "--brand-ink" in hover.group(1), (
|
||||
"hover must match the nav-link brand pair"
|
||||
)
|
||||
# Mobile (≤640px): label hidden, icon shown — the pill stays ≥44px via
|
||||
# min-height and never breaks the fixed-height header bar.
|
||||
assert hover and "#f55a72" in hover.group(1), "hover lightens the brand fill"
|
||||
# Mobile (≤640px): the button sits in .chat-shell, not the navbar —
|
||||
# the label stays visible and the plus icon is hidden (room in the
|
||||
# body); the pill stays ≥44px via min-height.
|
||||
mobile = re.search(r"@media \(max-width: 640px\) \{([\s\S]*?)\n\}", css)
|
||||
assert mobile, "mobile media query missing"
|
||||
assert ".new-chat-label { display: none; }" in mobile.group(1)
|
||||
assert ".chat-shell .new-chat-label { display: inline; }" in mobile.group(1)
|
||||
assert ".chat-shell .new-chat-btn svg { display: none; }" in mobile.group(1)
|
||||
assert ".new-chat-btn svg { display: block; }" in mobile.group(1)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user