feat: domain-authorized promo codes + WithPromoCode audience#914
feat: domain-authorized promo codes + WithPromoCode audience#914caseylocker wants to merge 30 commits intomasterfrom
Conversation
…/auto-apply fields
…toggle test
Direct wiring of onChange={handleChange} fails under React 16 event pooling
— target is nullified before test assertions read it. Both quantity and
auto_apply wrappers now synthesize plain objects through a single fireChange
helper (accepts `extra` spread for checkbox's `checked` field). Adds negated
auto_apply test to cover the false→true→false round-trip (6 tests total).
TagInput maps entries via .tag/.id internally; passing {value,label}
caused undefined.toLowerCase() crash on sort when editing an existing
code with pre-populated allowed_email_domains.
- domainsAsTags: { tag: d } instead of { value: d, label: d }
- normalizeTagValues: extract .tag first, then .value/.label fallback
- filter out empty strings (invalid domain guard)
- add regression test for non-empty initial domains
The RECEIVE_PROMOCODE reducer derives the UI-only apply_to_all_tix flag from ticket_types_rules.length for every class that DiscountBasePCForm can render, because summit-api's discount-code serializer never returns apply_to_all_tix. DOMAIN_AUTHORIZED_DISCOUNT_CODE was missing from the list, so reloading a saved per-ticket domain-authorized discount code inherited DEFAULT_ENTITY.apply_to_all_tix=true and rendered the all-ticket Amount/Rate inputs instead of the per-ticket rules table. Surfaced by Codex second-model review against sds/promo-codes-for-early-registration-access-summit-admin.md Truth #3 and #13 (discount variant composes DiscountBasePCForm; existing flows unchanged). Adds reducer tests covering rules populated, rules empty, and the access-only DOMAIN_AUTHORIZED_PROMO_CODE variant (which is not a discount class and must not participate in the derivation).
Symmetry with the text-default test above; reviewer suggestion.
Adds three integration tests observing the onSubmit mock to confirm validate()-driven save blocking for domain-authorized promo codes. Also polyfills scrollIntoView on HTMLElement.prototype (jsdom gap) and re-adds the screen import (used by the new getByRole calls).
Append two it.each blocks covering MEMBER/SPEAKER (assert #auto_apply present) and SPONSOR/SUMMIT/PRE_PAID/SPEAKERS (assert no #auto_apply), confirming none render the DomainAuthorized layout reflow fields. Also add speakers fixture to baseEntity so SPEAKERS_* classes mount without crashing on entity.speakers destructuring.
Sponsor branch ends at :478; SummitPCForm + PRE_PAID_PROMO_CODE branch is :494-505; SummitDiscountPCForm + PRE_PAID_DISCOUNT_CODE is :507-518. The original :480-504 range straddled two branches.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR adds domain-authorized promo code support with new form components ( ChangesDomain-Authorized Promo Code Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
Branch name violates CI rule (must start with |
ref: https://app.clickup.com/t/86b952pgc
Implements
sds/promo-codes-for-early-registration-access-summit-admin.md.Parent SDS (summit-api, merged in #525):
sds/promo-codes-for-early-registration-access.md.Companion SDS (registration-lite):
sds/promo-codes-for-early-registration-access-registration-lite.md— separate ticket.What changed
Domain-authorized promo codes + auto-apply
DomainAuthorizedPCFormandDomainAuthorizedDiscountPCFormcomposites (thin passthroughs overGenericBasePCForm/DiscountBasePCForm— per-class field rendering is handled by the orchestrator andBasePCFormvia class-name conditionals).src/components/forms/promocode-form/forms/domain-authorized/:AllowedEmailDomainsRow— TagInput with client-sidevalidateAllowedEmailDomainEntryvalidation, inline error, visible caption.AutoApplyCheckbox— third checkbox in the Description-row column for DA classes.MaxPerAccountInput— third column in the Quantity row for DA classes.domain-authorized/utils.jswithfireChangesynthesizer andisDomainAuthorizedClasshelper. The helper is the single source of truth for the boolean across three sync points:validate()andrender()in the orchestrator + the conditional inBasePCForm.auto_applycheckbox added to MEMBER_/SPEAKER_ fragments as a standalone row underneath the member/speaker selector. Asymmetric with domain-authorized rendering, but forced by the mockup — documented in the SDS.validateAllowedEmailDomainEntry()mirrors summit-api'sAllowedEmailDomainsArrayrule (three accepted formats:@domain.tld,.tld,user@example.com).getPromocode()expand string includesallowed_email_domains.DEFAULT_ENTITYextended with the three new fields.Ticket-type audience
WithPromoCodevalue in the ticket-typeaudience_ddl(form editor + list-page filter).Reducer fix (surfaced by Codex review during Task 13 Step 5)
DOMAIN_AUTHORIZED_DISCOUNT_CODEadded to thediscount_classeslist inpromocode-reducer.jssoapply_to_all_tixis derived fromticket_types_rules.lengthon load (matching every other discount-code subtype). Without this, reloading a saved per-ticket domain-authorized discount code would render the all-ticket UI.i18n
edit_promocode.captions.*keys (3 entries) parallel to the existinginfo.*tooltip tree. Documented as a coupled translation pair — captions are short inline helpers, tooltips are longer explanations.Testing
Automated
apply_to_all_tixderivation.utils(7 cases),AllowedEmailDomainsRow(6),AutoApplyCheckbox(4),MaxPerAccountInput(4).promocode-form.integration.test.js):auto_applyclasses.validate()drift between helper and domain enforcement (3 cases observingonSubmitmock).it.eachblocks (4 MEMBER/SPEAKER expecting fragment-owned#auto_apply; 8 SPONSOR/SUMMIT/PRE_PAID/SPEAKERS expecting no#auto_apply).Verification gates
yarn lint: 0 new errors over the 2536-error / 17869-warning baseline (+24 warnings on new files, all repo-style camelcase / prop-types / destructuring conventions).yarn build-dev: webpack 5.106.1 compiled successfully.discount_classesentry); follow-up items deferred as documented in spec.Manual QA
Verified on
https://localhost:8080againstapi.dev.fnopen.com+idp.dev.fnopen.comwith a logged-in admin session:DOMAIN_AUTHORIZED_PROMO_CODEandDOMAIN_AUTHORIZED_DISCOUNT_CODE): Allowed Email Domains row above Description, Auto-apply third checkbox in Description-row right column, Max Per Account third column in Quantity row, all three captions visible.auto_applystandalone row preserved.onCreatevalidation flow: malformedacme.com(no@) shows inline error + chip not added;@acme.com,.edu,user@example.comall accepted as chips.4b. Skipped —
validate()-path silent-block is observed by JSDOM tests; pre-existing UX gap (no DOM error display) is documented in spec as out-of-scope.Architecture notes
AutoApplyPromoCodeTrait):auto_applyis rendered only where the trait participates — domain-authorized classes (via the orchestrator's.checkboxes-divconditional) and member/speaker fragments. Not hoisted toGenericBasePCForm.isDomainAuthorizedClasscentralizes the BOOLEAN derivation across three sync points. Per-class render routing remains 12 explicit branches — adding a hypothetical thirdDOMAIN_AUTHORIZED_*variant in the future requires the helper + i18n keys + a new render branch.WithPromoCodeaudience: extends the existing ticket-type audience ENUM. Visibility (audience) and applicability (allowed_ticket_types) stay separate, per the parent SDS.abc-checkbox+ react-bootstrap idiom.Files
base-pc-form.js,index.js,forms/index.js,en.json,promocode-form.integration.test.js; deleteddomain-authorized-base-pc-form.js+ its test.Companion SDS update: separate
docs(sds)commits in thefn-skillsvault repo (record the layout-reflow approach addendum + new Deviations section). Not in this PR.Summary by CodeRabbit
New Features
Tests