feat(compte): coquille account_shell (sidebar + offcanvas + garde d'accès) (#73)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-06-24 18:43:53 +02:00
parent f301a0a336
commit 4602b45f30
2 changed files with 149 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
from src.pages import _compte_shell as shell
def test_visible_sections_hides_gated_without_subscription():
keys = {s["key"] for s in shell.visible_sections(has_subscription=False)}
assert "admin" in keys
assert "abonnement" in keys
assert "archives" not in keys
def test_visible_sections_shows_all_with_subscription():
keys = {s["key"] for s in shell.visible_sections(has_subscription=True)}
assert "archives" in keys
def test_guard_redirect_anonymous_goes_to_login():
href = shell.guard_redirect(
is_authenticated=False,
has_subscription=False,
require_subscription=False,
path="/compte/admin",
)
assert href == "/connexion?next=/compte/admin"
def test_guard_redirect_unsubscribed_on_gated_goes_to_abonnement():
href = shell.guard_redirect(
is_authenticated=True,
has_subscription=False,
require_subscription=True,
path="/compte/archives",
)
assert href == "/compte/abonnement"
def test_guard_redirect_allowed_returns_none():
href = shell.guard_redirect(
is_authenticated=True,
has_subscription=False,
require_subscription=False,
path="/compte/admin",
)
assert href is None