Repository navigation
fix(frontend): prevent checkout render loops when discounts are disabled - #987
Conversation
…e path The pre-v104 upgrade assertion pinned schema v104, which #986 made stale by adding migrations v105 and v106. Full Cross-Platform Matrix runs `npm test`, whose pretest chain includes this suite, so main went red on Linux and macOS while the shard-based PR CI never executed it.
Mode `none` forbids every discount type, so the render-phase normalization in PaymentModal, PrepaidCheckoutModal, and the Orders discount dialog kept rescheduling an update that could never be satisfied. React aborted after 25 renders and checkout showed the recovery boundary instead of a payment screen. Entering `none` now clears the draft once against the tracked previous mode, so the render phase stays finite, while enabled modes keep normalizing an incompatible draft type.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. WalkthroughCheckout components now reconcile discount drafts when discount mode changes, with end-to-end coverage for disabled-discount payment flows. Migration documentation and an upgrade test now derive version references from the migration registry. ChangesDiscount-disabled checkout
Migration registry references
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No confirmed issue currently prevents merge; the Orders draft reopening behavior remains unverified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
frontend/e2e/checkout-discounts-disabled.spec.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. frontend/src/app/(dashboard)/orders/page.tsxESLint skipped: the matched ESLint configuration already failed (missing-dependency). frontend/src/components/pos/PaymentModal.tsxESLint skipped: the matched ESLint configuration already failed (missing-dependency).
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Intent
Fix full-build schema test failure and prevent infinite render loop at checkout when discounts are disabled
What Changed
noneacross Orders, payment, and prepaid checkout so checkout stays usable.MIGRATIONSregistry instead of a pinned version or count.Risk Assessment
✅ Low: The changes are scoped to discount-mode reconciliation across checkout surfaces, the latest-schema assertion, and behavioral E2E coverage; I found no remaining reachable defect.
Testing
Installed locked dependencies locally, built the backend and frontend, drove all six focused browser scenarios and the database migration integration test, and captured the live checkout UI; temporary build and browser files were removed and the worktree is clean.
npm run test:addon-inventory-dbPipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
frontend/e2e/checkout-discounts-disabled.spec.ts:146-expect.poll(...).toBe('')succeeds on its first check while the error list is empty, so it does not observe the advertised 3-second window. The calls at lines 229, 285, 337, 382, 423, and 478 can therefore miss later errors. The waiter at line 221 can resolve on the Orders page’s settings request before the payment modal’s request, and the flat-mode apply path at lines 431-442 submits without waiting for the modal’s settings response, allowing it to use the initial percentage type. Wait for the modal’s settings response before assertions or submission, and use a real bounded observation if retaining the error-log check.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:addon-inventory-dbnpm ciin the repository root andfrontend/npm run build && npm run build:frontendPLAYWRIGHT_BROWSERS_PATH=<worktree>/.cache/playwright npx playwright install chromiumPLAYWRIGHT_BROWSERS_PATH=<worktree>/.cache/playwright npx playwright test --config=playwright.config.ts --project=chromium e2e/checkout-discounts-disabled.spec.tsfromfrontend/npm run test:addon-inventory-dbManual Playwright checkout on the isolated E2E server: selected Cash, confirmedPay ฿64.20and no discount control, and captured the screenshot.git diff --checkfor the target commit range✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
Bug Fixes
Tests
Documentation