refactor(ssr): remove the EDN snapshot round-trip; transaction edit is a plain form (heuristic 2)
The wizard serialized the whole accumulating form state into a `snapshot` hidden field (pr-str EDN + custom readers), decoded it every request, and merged step-params back in. For this single-step modal the snapshot is pure redundancy: every value is either in the entity or the live posted form. Remove it: - render: EditWizard.render-wizard renders a plain form -- no snapshot / edit-path / current-step hidden fields; a single `db/id` hidden rides in the form instead. - middleware: wrap-derive-state rebuilds :multi-form-state per request from the entity (loaded by the db/id hidden) overlaid with the live step-params, replacing wrap-init-multi-form-state + wrap-entity. The ~34 :snapshot reads are unchanged -- :snapshot is now a derived map, not a round-tripped blob. - editable fields (accounts, vendor, memo, approval, action, mode, amount-mode) come ONLY from the posted form (absent = cleared) so removing all account rows doesn't resurrect the entity's persisted accounts; only entity-only fields (db/id, client, amount, ...) come from the entity. - delete the dead initial-edit-wizard-state and render-account-grid-body. - e2e: make removeAllAccounts re-query each iteration (whole-form swaps stale a captured row index) and restore the percentage test to type-then-add ordering. Scorecard: snapshot EDN round-trip + custom readers + merge-multi-form-state -> gone (snapshot-field renders 0). Verified on a fresh server: full suite 38 pass / 1 unrelated fail, swap 6/6, transaction-edit 8/8 -- same green as before, snapshot removed.
This commit is contained in:
@@ -124,14 +124,13 @@ async function getAccountLocation(page: any, rowIndex: number): Promise<string>
|
||||
}
|
||||
|
||||
async function removeAllAccounts(page: any) {
|
||||
const accountRows = page.locator('#account-grid-body tbody tr.account-row');
|
||||
const rowCount = await accountRows.count();
|
||||
|
||||
for (let i = rowCount - 1; i >= 0; i--) {
|
||||
const row = accountRows.nth(i);
|
||||
const removeButton = row.locator('.account-remove-action');
|
||||
await removeButton.click();
|
||||
// Wait for the Alpine.js removal animation (500ms + buffer)
|
||||
// Re-query each iteration: every remove is a whole-form swap that re-renders the rows,
|
||||
// so a row index captured up front goes stale. Click the last remove button until none
|
||||
// remain.
|
||||
for (let guard = 0; guard < 20; guard++) {
|
||||
const removeButtons = page.locator('#account-grid-body .account-remove-action');
|
||||
if (await removeButtons.count() === 0) break;
|
||||
await removeButtons.last().click();
|
||||
await page.waitForTimeout(700);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user