-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Update rewards tests #3027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update rewards tests #3027
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughTest names were made descriptive and E2E_LEAD_REWARD fixture modifiers were reworked: modifier entities swapped between customer and partner, one modifier's maxDuration set to 0 and amountInCents reduced from 400 to 300, and test assertions updated to reference different modifier indices/values. Changes
Sequence Diagram(s)(omitted — changes are test/fixture updates only; no runtime control-flow modifications to diagram) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-07-30T15:29:54.131ZApplied to files:
🔇 Additional comments (2)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/tests/rewards/lead-reward.test.ts (1)
16-50: Customer country is never set in either the helper or API request.The test names claim "customer country is US", but
randomCustomer()returns only{ externalId, name, email, avatar }without acountryfield. Additionally, the/track/leadPOST request body never includescustomerCountry. Test 2 expectsmodifiers[0].amountInCents(200 cents), which requires the conditioncustomer.country equals_to "US"to apply, but this condition cannot be met since the country is never provided to the endpoint.The tests need either:
randomCustomer()to returncountry: "US", or- The track/lead request to include
customerCountry: customer.country(after updating the helper)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/tests/rewards/lead-reward.test.ts(3 hunks)apps/web/tests/utils/resource.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-30T15:29:54.131Z
Learnt from: TWilson023
PR: dubinc/dub#2673
File: apps/web/ui/partners/rewards/rewards-logic.tsx:268-275
Timestamp: 2025-07-30T15:29:54.131Z
Learning: In apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward condition, dependent fields (attribute, operator, value) should be reset rather than preserved because different entities (customer vs sale) have different available attributes. Maintaining existing fields when the entity changes would create invalid state combinations and confusing UX.
Applied to files:
apps/web/tests/utils/resource.ts
🧬 Code graph analysis (1)
apps/web/tests/rewards/lead-reward.test.ts (1)
apps/web/tests/utils/resource.ts (1)
E2E_LEAD_REWARD(106-141)
🔇 Additional comments (3)
apps/web/tests/utils/resource.ts (2)
118-118: Entity swap looks correct.The entity change from "partner" to "customer" aligns with the updated test scenarios and maintains correct condition semantics.
137-138: Verify themaxDurationchange fromnullto0.The
maxDurationfield semantics changed:
nulltypically means unlimited/indefinite duration0might mean no duration, one-time reward, or could be treated differently by the rewards enginePlease confirm this change is intentional and that
maxDuration: 0produces the desired behavior for this test scenario.apps/web/tests/rewards/lead-reward.test.ts (1)
54-88: Test expectations align with modifier logic.The expectation correctly uses
modifiers[0].amountInCents(200 cents) which triggers when customer country is US. Since the partner country is SG (not US),modifiers[1]won't trigger, making this the right assertion—assumingrandomCustomer()sets country to US (see previous comment).
Summary by CodeRabbit