add credit system and supplier webhook test suites, remove dead test

24 tests for credits.py (balance, spend, unlock, refill, ledger) and
10 integration tests for supplier webhook handlers (credit packs, sticky
boosts, subscription activation, business plan purchase). Removed
test_mobile_nav_no_overflow which never asserted its JS result.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-02-18 22:02:09 +01:00
parent 0fe5ab1259
commit df8a747463
4 changed files with 710 additions and 15 deletions

View File

@@ -6,6 +6,42 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]
### Added
- **Credit system test suite** (`tests/test_credits.py` — 24 tests) — covers
`get_balance`, `add_credits`, `spend_credits`, `compute_credit_cost`,
`already_unlocked`, `unlock_lead`, `monthly_credit_refill`, `get_ledger`;
tests run against real in-memory SQLite with no mocking
- **Supplier webhook test suite** (`tests/test_supplier_webhooks.py` — 10 tests)
— integration tests POSTing signed payloads to `/billing/webhook/paddle` and
verifying DB state for credit pack purchases, sticky boosts, supplier
subscription activation (growth/pro tiers, boost items, noop on missing
supplier_id), and business plan PDF export
### Removed
- **Dead test** `test_mobile_nav_no_overflow` from `test_visual.py` — evaluated
JS but never asserted the result; always passed regardless of overflow state
### Fixed
- **Supplier logo missing on public directory** — directory cards and supplier
detail page only checked `logo_url` (external URL); now checks `logo_file`
first (uploaded via dashboard), falling back to `logo_url`
- **Admin forward history links to wrong page** — supplier name in lead forward
history linked to `/directory/` (public index) instead of
`/admin/suppliers/<id>` (admin detail page)
- **Dashboard lead country filter drops heat/timeline state** — hidden inputs
used mismatched names (`heat_hidden`/`timeline_hidden` vs `heat`/`timeline`),
silently resetting other filters when country changed
- **Directory pagination drops region filter** — paginating after filtering by
region lost the `region` parameter; added to all pagination link templates
- **`boost_card_color` missing from webhook handler** — `BOOST_PRICE_KEYS`
omitted `boost_card_color`, so purchasing the card color boost via Paddle
would silently fail to create the `supplier_boosts` record; also removed
stale `boost_newsletter` entry (replaced by card color boost)
- **Sticky boost DB operations not atomic** — `boost_sticky_week` and
`boost_sticky_month` handlers issued two bare `execute()` calls (INSERT +
UPDATE) without a transaction; wrapped in `db_transaction()` to prevent
partial writes
### Added
- **Clickable admin list rows** — entire row is clickable on leads, suppliers,
and users admin list pages (`data-href` + JS click handler that skips