Files
intercept/tests/test_nav_state.py
James Smith f1a029262b feat: persist nav group open/closed state to localStorage
Adds initNavGroupState() and saveNavGroupState() functions so the
open/closed state of each .mode-nav-dropdown survives page reloads.
Active groups are never force-closed even if localStorage says closed.
Adds test_nav_state.py with two tests verifying presence of the
functions and data-group attributes on all five nav groups.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 21:08:27 +01:00

26 lines
956 B
Python

"""Tests for nav group localStorage persistence (JS logic verified via structure check)."""
def _logged_in_get(client, path):
"""Make a GET request with a pre-seeded logged-in session."""
with client.session_transaction() as sess:
sess["logged_in"] = True
return client.get(path)
def test_index_page_includes_nav_state_init(client):
"""nav group init function must be present in the index page."""
resp = _logged_in_get(client, "/")
assert resp.status_code == 200
html = resp.data.decode()
assert "initNavGroupState" in html
assert "localStorage" in html
def test_nav_groups_have_data_group_attributes(client):
"""Each nav group must have a data-group attribute for state keying."""
resp = _logged_in_get(client, "/")
html = resp.data.decode()
for group in ["signals", "tracking", "space", "wireless", "intel"]:
assert f'data-group="{group}"' in html, f"Missing data-group={group}"