Files
orangecat/test-utils
e99115c3bd feat(money): amount entry people can use, and payment logic the tests actually constrain (#615)
* test(payments): constrain who gets paid and when money counts as settled

Mutation testing showed the payment tests executed this code without
checking it: 65% of mutants in wallet resolution and 60% in settlement
survived the whole suite. Two shapes of hole.

First, the query WAS the logic. Deciding who receives money is mostly
filters and orderings — is_active, profile_id, group_id, primary-first —
and the old doubles returned a fixed row for any query, so every filter
could be deleted with the suite still green. Tests now run against a fake
that applies the query (test-utils/fakeSupabase), with a deactivated
wallet and a stranger's wallet present in the fixtures so a missing
filter changes who gets paid.

Second, two exported functions had no tests at all: the address the owner
is SHOWN as their receiving address, and who gets credited when money
arrives. Same for the token-authenticated path a payer with no account
uses to poll and to report "I've paid" — so nothing checked that a wrong
token reveals nothing, or that a payer's word is refused on rails that
answer for themselves.

Also pins settlement dispatch: each method asks its own authority and no
other, no rail is asked without the field it needs, mempool is not money,
and expiry is only the truth after the rail has said nothing arrived.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* feat(money): enter the amount like a person, and know you can send before you type

Two problems, both found by using the screens rather than reading them.

The amount input had the priority backwards: a row of preset pills in BTC
decimals, with typing your own amount hidden behind a "Custom" button that
only committed on blur. Every money app people already use opens on an
amount you type first, in the currency you think in. AmountField does
that — big tap-to-type value in your display currency, the BTC figure
always visible underneath because Bitcoin is what actually moves, and
presets demoted to suggestions.

Three rules it will not break: a missing exchange rate switches to BTC
entry rather than silently converting your "20" into 0 BTC; an
out-of-range amount says so instead of being quietly clamped to
something you did not type; and `inputMode="decimal"` gives phones the
plain number pad and accepts the comma half of Europe types.

Driving the real page found two more. The suggestions were round in the
wrong unit — a CHF user saw "CHF 0.52 · CHF 2.59 · CHF 5.18", arithmetic
noise — so the ladder is now round in whichever unit is being typed. And
the field arrives pre-filled with a suggestion, so typing APPENDED to it:
"27.50" over a suggested "5.18" became "27.51850", an amount the payer
never chose. It now selects on focus.

Second problem: /send let you fill in a recipient, an amount and a note
before telling you, on the final tap, that you have no wallet to send
from — the worst moment to say it, and knowable before a keystroke. It
now asks the same resolution the payment runs (GET /api/send) and shows
the connect-wallet state instead of a form that ends in a refusal.
Requests got the matching fix: the payer is resolved while you type, so
asking someone who does not exist fails visibly rather than on submit.

Also: the committing button sticks to the bottom on phones, where these
forms are taller than the viewport.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(payments): pin which group wallet receives when several could

group_wallets has no is_primary, so creation order is the entire
tie-break — and nothing constrained it. Two equally capable treasury
wallets would receive in whatever order Postgres happened to return.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 10:05:30 +00:00
..