fix(ssr): operation handlers read live step-params, not the stale snapshot (rewrite stage 1)

apply-new-account / apply-remove-account / apply-toggle-amount-mode rebuilt the account
rows from the decoded :snapshot, dropping any value the user typed but that had not yet
round-tripped into the snapshot (type 50%, click "New account" -> first row reverts,
giving a 66.67/33.33 split instead of 50/50). Read the live :step-params rows instead
(already schema-decoded by mm/wrap-wizard, so typed), falling back to snapshot only when
absent. First stage of removing the snapshot round-trip; fixes a real user-facing bug
(typed amounts lost on add/remove/$%-toggle).

Restore the percentage-split e2e to the realistic type-then-add ordering as a regression
guard. Modal stays green: swap 6/6, transaction-edit 8/8.
This commit is contained in:
2026-06-03 08:18:58 -07:00
parent 38ad665726
commit 0b5bfd9c84
3 changed files with 32 additions and 25 deletions

View File

@@ -214,25 +214,20 @@ test.describe('Transaction Edit Full Workflow', () => {
// Transaction 0 is $100. Code it 50% / 50% across two accounts in percentage mode and
// verify the save-time %->$ conversion stores/displays $50 + $50 on reopen.
//
// Ordering matters with the current snapshot machinery: a whole-form operation
// (add/remove row, mode toggle) rebuilds the rows from the server snapshot and drops
// any value only present in the live form. So we add the rows and toggle to % FIRST,
// then pick accounts and type the percentages, with no operation between typing and
// the save -- those values ride straight through. (The underlying snapshot-vs-form
// gap is the heuristic-2 work tracked in the ssr-form-migration skill.)
// This intentionally types a percentage and THEN adds another row -- a whole-form
// operation. The operation handlers now rebuild from the live posted form, not the
// stale snapshot, so the first row's typed 50% survives (it used to revert, yielding a
// 66.67/33.33 split).
await openEditModal(page, 0);
await removeAllAccounts(page);
// Two empty rows, then switch to percentage mode (both are whole-form operations).
await addNewAccount(page);
await addNewAccount(page);
await toggleToPercentMode(page);
// Now pick the accounts (targeted location swap) and set 50% / 50% (targeted totals
// swap). Neither re-renders the rows from the snapshot, so the form keeps these.
await addNewAccount(page);
await selectAccountFromTypeahead(page, 0, 'Test');
await selectAccountFromTypeahead(page, 1, 'Second');
await setAccountAmount(page, 0, '50');
await addNewAccount(page);
await selectAccountFromTypeahead(page, 1, 'Second');
await setAccountAmount(page, 1, '50');
await saveTransaction(page);