-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix the Fraud tests #3171
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
Fix the Fraud tests #3171
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughRemoved E2E/test identity header override from identity-hash middleware; updated tests and test utilities to stop relying on that header and changed the E2E fraud partner test data shape to use a Changes
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touchesβ Failed checks (1 inconclusive)
β Passed checks (2 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
π Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro π Files selected for processing (2)
π§ Files skipped from review as they are similar to previous changes (1)
π§° Additional context usedπ§ Learnings (3)π Learning: 2025-11-24T09:10:12.536ZApplied to files:
π Learning: 2025-08-21T03:03:39.879ZApplied to files:
π Learning: 2025-05-29T04:45:18.504ZApplied to files:
β° Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
π Additional comments (1)
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: 0
π§Ή Nitpick comments (1)
apps/web/tests/utils/resource.ts (1)
210-231:E2E_FRAUD_PARTNER.linksshape matches test usage; consider a keyed map for resilienceThe new
linksarray and its four entries match exactly how the fraud tests consume them (links[0..3]for the four rule scenarios), so this change is consistent and self-contained.If you ever expand or reorder these fixtures, you might consider switching
linksto an object keyed by rule name (e.g.,links: { customerEmailMatch: {...}, customerEmailSuspiciousDomain: {...}, ... }) so tests can referenceE2E_FRAUD_PARTNER.links.customerEmailMatchinstead of relying on array order. Not necessary for this PR, just a small robustness win for later.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (3)
apps/web/lib/middleware/utils/get-identity-hash.ts(0 hunks)apps/web/tests/fraud/index.test.ts(5 hunks)apps/web/tests/utils/resource.ts(1 hunks)
π€ Files with no reviewable changes (1)
- apps/web/lib/middleware/utils/get-identity-hash.ts
π§° Additional context used
π§ Learnings (5)
π Learning: 2025-11-24T09:10:12.536Z
Learnt from: devkiran
Repo: dubinc/dub PR: 3089
File: apps/web/lib/api/fraud/fraud-rules-registry.ts:17-25
Timestamp: 2025-11-24T09:10:12.536Z
Learning: In apps/web/lib/api/fraud/fraud-rules-registry.ts, the fraud rules `partnerCrossProgramBan` and `partnerDuplicatePayoutMethod` intentionally have stub implementations that return `{ triggered: false }` because they are partner-scoped rules handled separately during partner application/onboarding flows (e.g., in detect-record-fraud-application.ts), rather than being evaluated per conversion event like other rules in the registry. The stubs exist only to satisfy the `Record<FraudRuleType, ...>` type constraint.
Applied to files:
apps/web/tests/fraud/index.test.tsapps/web/tests/utils/resource.ts
π Learning: 2025-11-24T08:55:31.332Z
Learnt from: devkiran
Repo: dubinc/dub PR: 3089
File: apps/web/app/(ee)/api/fraud-rules/route.ts:71-87
Timestamp: 2025-11-24T08:55:31.332Z
Learning: In apps/web/app/(ee)/api/fraud-rules/route.ts, fraud rules cannot be created in a disabled state. When using prisma.fraudRule.upsert, the create branch intentionally omits the disabledAt field (defaulting to null, meaning enabled), while the update branch allows toggling enabled/disabled state via the disabledAt field. This is a business logic constraint.
Applied to files:
apps/web/tests/fraud/index.test.ts
π Learning: 2025-08-21T03:03:39.879Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2737
File: apps/web/lib/api/cors.ts:1-5
Timestamp: 2025-08-21T03:03:39.879Z
Learning: Dub publishable keys are sent via Authorization header using Bearer token format, not via custom X-Dub-Publishable-Key header. The publishable key middleware extracts keys using req.headers.get("Authorization")?.replace("Bearer ", "") and validates they start with "dub_pk_".
Applied to files:
apps/web/tests/utils/resource.ts
π Learning: 2025-06-06T07:59:03.120Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2177
File: apps/web/lib/api/links/bulk-create-links.ts:66-84
Timestamp: 2025-06-06T07:59:03.120Z
Learning: In apps/web/lib/api/links/bulk-create-links.ts, the team accepts the risk of potential undefined results from links.find() operations when building invalidLinks arrays, because existing links are fetched from the database based on the input links, so matches are expected to always exist.
Applied to files:
apps/web/tests/utils/resource.ts
π Learning: 2025-05-29T04:45:18.504Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2448
File: packages/email/src/templates/partner-program-summary.tsx:0-0
Timestamp: 2025-05-29T04:45:18.504Z
Learning: In the PartnerProgramSummary email template (packages/email/src/templates/partner-program-summary.tsx), the stat titles are hardcoded constants ("Clicks", "Leads", "Sales", "Earnings") that will always match the ICONS object keys after toLowerCase() conversion, so icon lookup failures are not possible.
Applied to files:
apps/web/tests/utils/resource.ts
𧬠Code graph analysis (1)
apps/web/tests/fraud/index.test.ts (1)
apps/web/tests/utils/resource.ts (1)
E2E_FRAUD_PARTNER(210-231)
π Additional comments (1)
apps/web/tests/fraud/index.test.ts (1)
3-3: Fraud tests correctly mapped toE2E_FRAUD_PARTNER.linksentriesThe updated tests cleanly switch to
E2E_FRAUD_PARTNER.links[index], and the indices line up with the link keys defined in the test resources (fraud-customer-match,fraud-customer-suspicious,fraud-referral-source-banned,fraud-paid-traffic). The sharedE2E_TRACK_CLICK_HEADERSplus per-test link selection should behave identically across runs given the new identity-hash behavior.No issues spotted in the mapping or in the
retry/randomCustomerusage here.Also applies to: 18-18, 60-60, 99-99, 139-139
Summary by CodeRabbit
Refactor
Tests
βοΈ Tip: You can customize this high-level summary in your review settings.