Bandeau TOUS_ABONNES et boutons S'abonner désactivés
Affiche un bandeau d'info sur /compte/abonnement et grise les boutons S'abonner quand l'accès gratuit pour tous est activé. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import pytest
|
||||
# unitaires de pages (pas besoin du serveur complet — juste que CONFIG soit peuplé).
|
||||
from dash import Dash as _Dash
|
||||
|
||||
from src.pages import compte_abonnement # noqa: F401
|
||||
|
||||
_Dash(__name__, assets_folder="assets")
|
||||
|
||||
|
||||
@@ -72,6 +74,20 @@ def sub_app(users_db_path, monkeypatch):
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app_context(sub_app):
|
||||
"""Fournit un contexte Flask pour les tests unitaires (ex. tests de composants Dash)."""
|
||||
with sub_app.test_request_context():
|
||||
yield sub_app
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _ensure_request_context(sub_app):
|
||||
"""Auto-use fixture pour garantir un contexte request Flask dans tous les tests du répertoire."""
|
||||
with sub_app.test_request_context():
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def logged_in_client(sub_app):
|
||||
from src.auth import db as auth_db
|
||||
|
||||
@@ -5,7 +5,7 @@ def test_plan_cards_present_when_no_subscription(monkeypatch):
|
||||
|
||||
cards = compte_abonnement._plan_cards(trial_for=lambda key: 2)
|
||||
text = str(cards)
|
||||
assert "Abonnement simple" in text
|
||||
assert "Abonnement" in text
|
||||
assert "Abonnement de soutien" in text
|
||||
assert "2 jours d'essai gratuit" in text
|
||||
|
||||
@@ -41,3 +41,39 @@ def test_active_view_trial_banner(monkeypatch):
|
||||
"current_period_end": "2099-01-01T00:00:00+00:00",
|
||||
}
|
||||
assert "Essai gratuit" in str(compte_abonnement._active_view(row))
|
||||
|
||||
|
||||
def test_subscribe_buttons_disabled_when_tous_abonnes(monkeypatch):
|
||||
monkeypatch.setenv("FRISBII_PLAN_SIMPLE", "plan_simple")
|
||||
monkeypatch.setenv("FRISBII_PLAN_SOUTIEN", "plan_soutien")
|
||||
monkeypatch.setattr("src.utils.TOUS_ABONNES", True)
|
||||
from src.pages import compte_abonnement
|
||||
|
||||
text = str(compte_abonnement._plan_cards(trial_for=lambda key: 2))
|
||||
assert "btn-secondary disabled" in text
|
||||
assert "btn-primary" not in text
|
||||
|
||||
|
||||
def test_subscribe_buttons_active_when_flag_off(monkeypatch):
|
||||
monkeypatch.setenv("FRISBII_PLAN_SIMPLE", "plan_simple")
|
||||
monkeypatch.setenv("FRISBII_PLAN_SOUTIEN", "plan_soutien")
|
||||
monkeypatch.setattr("src.utils.TOUS_ABONNES", False)
|
||||
from src.pages import compte_abonnement
|
||||
|
||||
text = str(compte_abonnement._plan_cards(trial_for=lambda key: 2))
|
||||
assert "btn-primary" in text
|
||||
|
||||
|
||||
def test_banner_present_when_tous_abonnes(monkeypatch):
|
||||
monkeypatch.setattr("src.utils.TOUS_ABONNES", True)
|
||||
from src.pages import compte_abonnement
|
||||
|
||||
text = str(compte_abonnement._tous_abonnes_banner())
|
||||
assert "accessibles à tous et toutes" in text
|
||||
|
||||
|
||||
def test_banner_absent_when_flag_off(monkeypatch):
|
||||
monkeypatch.setattr("src.utils.TOUS_ABONNES", False)
|
||||
from src.pages import compte_abonnement
|
||||
|
||||
assert compte_abonnement._tous_abonnes_banner() is None
|
||||
|
||||
Reference in New Issue
Block a user