Add direct tests for payment pricing - #1900
Merged
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesPayment pricing behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Added a standalone test file for payment pricing (
test/features/api/payment-processing/pricing.test.ts) that calls the real production code directly — no server, no Stripe, no database.The production file
src/features/api/payment-processing/pricing.tsgot one small change:checkoutIntentForSessionnow reuses the existingcontactFieldshelper (fromsrc/shared/db/attendees/pii.ts) instead of copying the contact fields by hand. This is the same helper the final split branch uses, and it stays behaviour-preserving because:address,email,name,phone,special_instructions) the old inline copy did;contactFieldsalready has current production callers (committed-entries.ts,attendees/create.ts,attendees/pii.ts);orderLineTotal, or staged-checkout types were touched.Why
The pricing module is the last gate before a signed order is honoured: it re-prices the order and decides whether today's prices still match what the buyer was charged. That logic (contact fields, signed totals, item totals, deposits, modifiers, pay-more bounds, and the failure paths that refund when a price drifted mid-checkout) deserves a fast, focused unit suite instead of only being exercised through full webhook integration tests.
What the tests cover
k: "p"line becomes apackageGroupId, ak: "g"line does not.orderLineTotal): split deposit lines are summed, modifier extras are excluded.paidByItem): split lines for the same item add up; two booking paths for one listing stay separate.paidPricingRefund): an unchanged fixed-price order passes; a deposit is accepted while the full item price is still checked; an unchanged modifier total passes; a changed re-derived total refunds with the exact detail string.?? → ||fallback recorded as a proven equivalent).Verification
deno task test:files test/features/api/payment-processing/pricing.test.ts— 21 tests passdeno task test:quality-audit— no findings in the new filedeno task mutation src/features/api/payment-processing/pricing.ts test/features/api/payment-processing/pricing.test.ts— 100% (34 killed, 1 suppressed equivalent)deno task precommit— greenNotes
pricing.ts), behaviour-preserving.orderLineTotal, or staged types were changed.Summary by CodeRabbit
Improvements
Tests