fix(billing): address code review - remove duplicate mode logic, accessibility improvements, robust test assertions

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-08 15:18:53 +00:00
parent 223539bebb
commit 002cdf312b
3 changed files with 8 additions and 9 deletions
-2
View File
@@ -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"
+4 -2
View File
@@ -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"
>
<span
class="w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold border-2 transition"
@@ -139,7 +140,8 @@
<!-- Plan grid -->
<div x-show="status && status.plans && status.plans.length > 0">
<table class="min-w-full text-sm divide-y divide-gray-200" aria-label="Plan sync status">
<table class="min-w-full text-sm divide-y divide-gray-200">
<caption class="sr-only">Plan sync status</caption>
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-3 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Plan</th>
@@ -300,7 +302,7 @@
<!-- Local testing -->
<details class="border border-gray-200 rounded-md">
<summary class="px-4 py-3 text-sm font-medium text-gray-700 cursor-pointer hover:bg-gray-50">
<summary class="px-4 py-3 text-sm font-medium text-gray-700 cursor-pointer hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-indigo-400 rounded-md">
<i class="fas fa-terminal mr-1" aria-hidden="true"></i> Local testing with Stripe CLI
</summary>
<div class="px-4 pb-4 pt-2 bg-gray-50 rounded-b-md">
+4 -5
View File
@@ -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