From 002cdf312b6ef45864d89d9bdbf3030ef18e3ba6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 15:18:53 +0000 Subject: [PATCH] fix(billing): address code review - remove duplicate mode logic, accessibility improvements, robust test assertions Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- app/api/billing.py | 2 -- frontend/templates/admin_stripe_wizard.html | 6 ++++-- tests/test_billing.py | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/api/billing.py b/app/api/billing.py index b3d437c2..b8db5454 100644 --- a/app/api/billing.py +++ b/app/api/billing.py @@ -306,8 +306,6 @@ async def stripe_status(request: Request, db: Session = Depends(get_db)) -> dict connection_status = "ok" try: account = client.accounts.retrieve("me") # type: ignore[arg-type] - mode = "live" if getattr(account, "livemode", True) is not False else "test" - # stripe returns livemode=False in test mode livemode = getattr(account, "livemode", None) if livemode is True: mode = "live" diff --git a/frontend/templates/admin_stripe_wizard.html b/frontend/templates/admin_stripe_wizard.html index 099f812d..83fe0180 100644 --- a/frontend/templates/admin_stripe_wizard.html +++ b/frontend/templates/admin_stripe_wizard.html @@ -40,6 +40,7 @@ @click="currentStep = i" class="flex items-center focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-indigo-400 rounded" :aria-current="currentStep === i ? 'step' : null" + :aria-label="'Step ' + (i + 1) + ': ' + step.title" >
- +
+ @@ -300,7 +302,7 @@
- + Local testing with Stripe CLI
diff --git a/tests/test_billing.py b/tests/test_billing.py index 2e40c34f..b3b7a304 100644 --- a/tests/test_billing.py +++ b/tests/test_billing.py @@ -664,12 +664,11 @@ def test_stripe_sync_plans_creates_prices(bill_client, bill_session): assert db_plan.stripe_price_id_monthly == "price_monthly_pro_new" assert db_plan.stripe_price_id_yearly == "price_yearly_pro_new" - # Verify correct amounts were passed to Stripe + # Verify correct amounts were passed to Stripe, matching by interval (order-independent) price_calls = mock_client.prices.create.call_args_list - assert price_calls[0][1]["params"]["unit_amount"] == 1900 # $19.00 → 1900 cents - assert price_calls[1][1]["params"]["unit_amount"] == 19000 # $190.00 → 19000 cents - assert price_calls[0][1]["params"]["recurring"]["interval"] == "month" - assert price_calls[1][1]["params"]["recurring"]["interval"] == "year" + by_interval = {call[1]["params"]["recurring"]["interval"]: call[1]["params"] for call in price_calls} + assert by_interval["month"]["unit_amount"] == 1900 # $19.00 → 1900 cents + assert by_interval["year"]["unit_amount"] == 19000 # $190.00 → 19000 cents @pytest.mark.integration
Plan sync status
Plan