feat(abonnement): page /compte/abonnement + accès premium réel (#90)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRGb8NAMwaTZxUszSbaj4N
This commit is contained in:
Colin Maudry
2026-06-25 19:08:22 +02:00
parent 3d1cb69463
commit d3025e323b
4 changed files with 212 additions and 10 deletions
+6
View File
@@ -2,6 +2,12 @@ import json as _json
import pytest
# Initialise un Dash minimal pour que register_page() fonctionne dans les tests
# unitaires de pages (pas besoin du serveur complet — juste que CONFIG soit peuplé).
from dash import Dash as _Dash
_Dash(__name__, assets_folder="assets")
class FakeResponse:
def __init__(self, status_code: int, payload=None):
@@ -0,0 +1,43 @@
def test_plan_cards_present_when_no_subscription(monkeypatch):
monkeypatch.setenv("FRISBII_PLAN_SIMPLE", "plan_simple")
monkeypatch.setenv("FRISBII_PLAN_SOUTIEN", "plan_soutien")
from src.pages import compte_abonnement
cards = compte_abonnement._plan_cards(trial_for=lambda key: 2)
text = str(cards)
assert "Abonnement simple" in text
assert "Abonnement de soutien" in text
assert "2 jours d'essai gratuit" in text
def test_plan_cards_no_trial_when_trial_used(monkeypatch):
monkeypatch.setenv("FRISBII_PLAN_SIMPLE", "plan_simple")
monkeypatch.setenv("FRISBII_PLAN_SOUTIEN", "plan_soutien")
from src.pages import compte_abonnement
text = str(compte_abonnement._plan_cards(trial_used=True, trial_for=lambda key: 2))
assert "Sans période d'essai" in text
assert "2 jours d'essai gratuit" not in text
def test_active_view_shows_cancel(monkeypatch):
from src.pages import compte_abonnement
row = {
"plan": "simple",
"status": "active",
"current_period_end": "2099-01-01T00:00:00+00:00",
}
view = compte_abonnement._active_view(row)
assert "Résilier" in str(view)
def test_active_view_trial_banner(monkeypatch):
from src.pages import compte_abonnement
row = {
"plan": "simple",
"status": "trial",
"current_period_end": "2099-01-01T00:00:00+00:00",
}
assert "Essai gratuit" in str(compte_abonnement._active_view(row))