diff --git a/src/pages/compte/abonnement.py b/src/pages/compte/abonnement.py index deab188..d2bf2d9 100644 --- a/src/pages/compte/abonnement.py +++ b/src/pages/compte/abonnement.py @@ -151,7 +151,7 @@ def _active_view(row): blocks.append( dbc.Alert(f"Abonnement résilié, actif jusqu'au {end}.", color="warning") ) - else: + elif row["status"] == "active": blocks.append(html.P(f"Prochaine facturation : {end}")) if row["status"] in ("pending", "trial", "active"): @@ -278,7 +278,7 @@ def _tous_abonnes_banner(): def _show_active_view(row) -> bool: - return row is not None and row["status"] != "failed" + return row is not None and row["status"] not in ("failed", "expired") def layout(**query): @@ -301,6 +301,12 @@ def layout(**query): body.append(_active_view(row)) body.append(_resiliation_modal(row["current_period_end"])) else: + if row is not None and row["status"] == "expired": + body.append( + dbc.Alert( + "Votre abonnement a expiré.", color="warning", className="mb-4" + ) + ) body.extend([_plan_cards(trial_used=trial_used), _explainer()]) body.append(_salaire_modal) diff --git a/tests/subscriptions/test_compte_abonnement.py b/tests/subscriptions/test_compte_abonnement.py index fc771dc..5794d51 100644 --- a/tests/subscriptions/test_compte_abonnement.py +++ b/tests/subscriptions/test_compte_abonnement.py @@ -82,12 +82,13 @@ def test_banner_absent_when_flag_off(monkeypatch): def test_show_active_view_true_for_live_statuses(monkeypatch): from src.pages.compte import abonnement as compte_abonnement - for status in ("pending", "trial", "active", "cancelled", "expired"): + for status in ("pending", "trial", "active", "cancelled"): assert compte_abonnement._show_active_view({"status": status}) is True -def test_show_active_view_false_for_failed_or_none(monkeypatch): +def test_show_active_view_false_for_failed_expired_or_none(monkeypatch): from src.pages.compte import abonnement as compte_abonnement assert compte_abonnement._show_active_view({"status": "failed"}) is False + assert compte_abonnement._show_active_view({"status": "expired"}) is False assert compte_abonnement._show_active_view(None) is False