Files
hermes-webui/tests/test_issue3227_help_tab.py
T
55738a50ea Release v0.51.581 — full-screen PWA mobile sidebar drawer (#4660) (#4683)
* stage #4660 v2 (franksong2702): full-screen PWA mobile sidebar drawer — REBUILT on current master

REBUILD: the prior stage was cut before tonight's #4597/#4584/#4583 ships, so its 3-dot
diff falsely appeared to revert them (Codex CORE/SILENT flags). Rebuilt on current master
(authoritative head a035b1343): clean apply, tonight's fixes confirmed INTACT (_apply_sidebar_
state_db_overrides, bottomDistance, overflow-x:hidden all present). #4660's own change is
additive — full-screen drawer width, edge-guard, mobile close button, overlay->display:none;
does NOT touch the scroll/perf/mobile-pan lines. Nathan concept-greenlit + visual signed off.
71 mobile-layout+swipe tests pass.

Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>

* fix #4660 edge-guard regression: defer preventDefault until horizontal intent + touch-action:pan-y; update 2 tests to assert corrected behavior

* fix #4660 edge-guard hit-test interception (Codex CORE): pointer-events:none + drop guard listener

Deeper fix than the prior preventDefault change: the #pwaSidebarEdgeGuard was a fixed
interactive element (z-index 198, no pointer-events:none) that intercepted hit-testing for
taps/vertical-scrolls starting in the left 24px strip (since .messages is the real scroller
under body:overflow:hidden). Now guard is pointer-events:none with NO dedicated touch
listener; the existing window-level CAPTURE handlers still catch the edge-swipe-to-open.
Removed the orphaned _onPwaSidebarEdgeGuardStart fn. Updated 2 tests to assert the new
non-interactive design. 71 mobile tests pass.

---------

Co-authored-by: nesquena-hermes <agent@nesquena-hermes>
Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>
2026-06-22 01:10:42 -07:00

74 lines
3.0 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
INDEX_HTML = (ROOT / "static" / "index.html").read_text(encoding="utf-8")
PANELS_JS = (ROOT / "static" / "panels.js").read_text(encoding="utf-8")
I18N_JS = (ROOT / "static" / "i18n.js").read_text(encoding="utf-8")
STYLE_CSS = (ROOT / "static" / "style.css").read_text(encoding="utf-8")
LOCALE_COUNT = 13 # en, it, ja, ru, es, de, zh, zh-TW, pt, ko, fr, tr, pl
def test_help_nav_button_present():
assert 'data-settings-section="help"' in INDEX_HTML
assert "switchSettingsSection('help',{fromSidebarItem:true})" in INDEX_HTML
assert 'data-i18n="settings_tab_help"' in INDEX_HTML
def test_help_pane_present():
assert 'id="settingsPaneHelp"' in INDEX_HTML
assert 'href="https://get-hermes.ai/"' in INDEX_HTML
assert 'href="https://github.com/nesquena/hermes-webui/issues"' in INDEX_HTML
def test_help_pane_links_are_outbound():
assert 'target="_blank"' in INDEX_HTML
assert 'rel="noopener noreferrer"' in INDEX_HTML
def test_panels_js_allowlist_includes_help():
assert "name==='help'" in PANELS_JS
def test_panels_js_map_includes_help():
assert "help:'Help'" in PANELS_JS
def test_panels_js_foreach_includes_help():
assert "'help'" in PANELS_JS
assert "settingsPaneHelp" not in PANELS_JS or 'settingsPane'+'{map[key]}' not in PANELS_JS
# Simpler: confirm the forEach array string contains help
assert ",'help'," in PANELS_JS or ",'help']" in PANELS_JS
def test_i18n_help_keys_present_in_all_locales():
assert I18N_JS.count("settings_tab_help") == LOCALE_COUNT
assert I18N_JS.count("settings_help_docs_label") == LOCALE_COUNT
assert I18N_JS.count("settings_help_issue_label") == LOCALE_COUNT
assert I18N_JS.count("settings_help_docs_link") == LOCALE_COUNT
assert I18N_JS.count("settings_help_issue_link") == LOCALE_COUNT
def test_help_card_link_hover_is_contrast_safe():
"""The hover fill is var(--accent); the text color must NOT be var(--accent-text).
In most themes --accent-text equals (or nearly equals) --accent — it is an
accent-on-background link color, not a contrasting color for text sitting ON
an accent fill. Using it on the accent-filled hover state produced same-color
text on the fill (invisible) across nearly every theme (slate/gold/ares/mono/
sisyphus/catppuccin dark all had accent == accent-text). The fix uses
var(--bg) — the page background — which --accent is designed to contrast
against, so the text stays readable in every theme.
"""
import re
m = re.search(r"\.help-card-link:hover\s*\{([^}]*)\}", STYLE_CSS)
assert m, "expected a .help-card-link:hover rule in style.css"
rule = m.group(1)
assert "background:var(--accent)" in rule.replace(" ", "")
# The bug: accent-text on accent fill. Must not reappear.
assert "--accent-text" not in rule, (
"hover text uses var(--accent-text) on an accent fill — invisible in most "
"themes; use var(--bg) for theme-agnostic contrast"
)
assert "color:var(--bg)" in rule.replace(" ", "")