Skip to content

Trim promo-code discover response to fields the widget uses - #150

Open
gcutrini wants to merge 1 commit into
mainfrom
feature/trim-promo-code-discover-response
Open

Trim promo-code discover response to fields the widget uses#150
gcutrini wants to merge 1 commit into
mainfrom
feature/trim-promo-code-discover-response

Conversation

@gcutrini

@gcutrini gcutrini commented Jul 20, 2026

Copy link
Copy Markdown
Member

ref: https://app.clickup.com/t/86bb0tmq5

Summary

  • discoverPromoCodes now sends a fields + relations whitelist so the server returns only what usePromoCode reads on the response.
  • A runtime Proxy audit in usePromoCode.test.js observes every field the hook accesses across its full lifecycle (auto-apply, ticket qualification, quantity caps, manual entry, removal) and asserts each is on the whitelist. Catches drift from spread, destructuring, or computed access that a grep cant find.
  • An integration test drives the real thunk, reducer, and hook against a payload filtered exactly the way the server filters it. If a field the hook reads is missing from the request, a derived value comes back wrong and the test fails.

Summary by CodeRabbit

  • Bug Fixes

    • Promo code discovery requests now retrieve the specific information needed for promo code application and validation.
    • Promo code data is filtered to prevent unrelated fields from being stored or used.
    • Improved consistency between discovered promo code data and hook-based calculations.
  • Tests

    • Added coverage for promo code discovery, validation, quantity limits, auto-application, and ticket eligibility flows.

discoverPromoCodes now sends a fields + relations whitelist listing only
what usePromoCode reads.

Guards against drift: a runtime Proxy audit in usePromoCode.test.js
observes every field the hook reads across its full lifecycle, and an
integration test drives the real thunk/reducer/hook against a filtered
payload.
@gcutrini
gcutrini requested a review from smarcet July 20, 2026 20:06
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1377ce8-0b67-4fe3-840a-14a47cc2b747

📥 Commits

Reviewing files that changed from the base of the PR and between bf121e9 and 4502244.

📒 Files selected for processing (3)
  • src/__tests__/discoverPromoCodes.integration.test.js
  • src/actions.js
  • src/hooks/__tests__/usePromoCode.test.js

📝 Walkthrough

Walkthrough

Changes

Promo code projection validation

Layer / File(s) Summary
Request projection and integration validation
src/actions.js, src/__tests__/discoverPromoCodes.integration.test.js
discoverPromoCodes now sends explicit scalar fields and relations. Integration tests simulate the trimmed response and verify reducer contents and hook-derived promo-code state.
Hook field-access audit
src/hooks/__tests__/usePromoCode.test.js
A proxy-based audit exercises major hook flows and verifies that all accessed promo-code fields belong to the request whitelist.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: limiting the promo-code discover response to fields used by the widget.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/trim-promo-code-discover-response

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant