-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add promo code discovery with usePromoCode hook #141
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
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
8ae7c73
feat: add promo code discovery with usePromoCode hook
gcutrini faac5ad
test: add unit tests for usePromoCode hook
gcutrini acd1cea
test: add e2e tests with Playwright route interception
gcutrini d29c5e8
fix: use i18n keys for promo discovery labels
gcutrini 2da0a76
fix: re-validate manual promo codes on Next with final quantity
gcutrini 48d7659
fix: add error handling for discovered code re-validation
gcutrini fdc7253
fix: dismiss suggestion when input is cleared
gcutrini d857037
fix: return null on discovery error
gcutrini f31c629
test: add tests for error handling in onTicketSelected and input clea…
gcutrini b8005dc
fix: extract canApply guard for Enter key and Apply button
gcutrini a0088af
fix: clamp quantity when maxQuantity is zero
gcutrini 6e040a0
fix: use nullish coalescing in getTicketMaxQuantity
gcutrini ce82d27
fix: use i18n for validation error messages and add fallback
gcutrini 32f145a
test: add assertions to empty test and init i18n in test setup
gcutrini 946f177
chore(ci): add e2e integration (#142)
smarcet 2c11e71
fix: suppress auto-apply when multiple codes are returned
gcutrini a28f322
merge: resolve conflict with main in personal-information tests
gcutrini 8a5cf81
fix: await page.route() calls in e2e tests
gcutrini e382b7f
fix: allow ticket dropdown to clear when ticket types become empty
gcutrini ce73e2d
feat: early auto-apply for WithPromoCode-only ticket types
gcutrini 033c1aa
feat: hide ticket selector when no tickets, show notice instead
gcutrini 521e7bd
fix: promo code input shows checkmark when applied, fix disabled text…
gcutrini bb5c05b
fix: fallback background for applied promo input on host sites withou…
gcutrini 0d4c567
style: use PromoCodeNotice for no-tickets-available to match other no…
gcutrini b59a026
fix: !important on applied promo input styles to beat host global inp…
gcutrini 8a38e6e
fix: detect invalid promo code applied without a ticket selected
gcutrini 8c7aed7
fix: hide empty ticket dropdown when applied code yields zero tickets
gcutrini 71e2eeb
fix: show spinner during APPLYING and use 'Applying promo code...' label
gcutrini 4beda6d
refactor: consolidate promo code error state into a single computed v…
gcutrini 72eb58c
refactor: extract tryAutoApply helper used by both auto-apply call sites
gcutrini d22673c
refactor: move unapplied-code warning out of the promo hook
gcutrini 2ab17d8
fix: don't clear form errors on promo code change
gcutrini 6f743a3
feat: make 'no tickets available' message configurable via prop
gcutrini b28c4b2
fix: align CI Node version with .nvmrc, stop widgetLoading on revalid…
gcutrini a0e9675
fix: address CodeRabbit nitpicks on cap symmetry, error coercion, i18…
gcutrini cddf6bc
fix: include quantity in clamp effect deps and default promo to {}
gcutrini 22dd46b
test(e2e): fix no-tickets selector to match actual i18n wording
gcutrini b4b1baa
refactor: surface auto-apply errors, rename isApplied->isLocked, expa…
gcutrini f4342a7
refactor: reshape usePromoCode contract for clarity
gcutrini 7f4d781
feat: TicketNotice with stacked messages + per-order limit line
gcutrini 7882a01
style: hide 'Have multiple promo codes?' link on mobile (<=540px)
gcutrini dc424e3
fix(usePromoCode): surface manual onApply errors consistently with au…
gcutrini e6b2886
fix(ticket-type): clamp quantity to 0 when cap is below minQuantity
gcutrini 4819073
refactor(ticket-step): centralize ticket selection validity
gcutrini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| unit-tests: | ||
| name: Unit Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: yarn | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Run unit tests | ||
| run: yarn test:ci | ||
|
|
||
| e2e-tests: | ||
| name: E2E Tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: yarn | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Install Playwright Chromium | ||
| run: npx playwright install chromium | ||
|
|
||
| - name: Run E2E tests | ||
| run: yarn test:e2e | ||
|
|
||
| - name: Upload Playwright report | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 14 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Mock API response factories for e2e tests. | ||
| * Each factory returns a response body matching the API contract. | ||
| */ | ||
|
|
||
| const ticketType = (overrides = {}) => ({ | ||
| id: 188, | ||
| name: 'Early Bird Ticket', | ||
| cost: 700, | ||
| currency: 'USD', | ||
| currency_symbol: '$', | ||
| quantity_2_sell: 1000, | ||
| quantity_sold: 0, | ||
| max_quantity_per_order: 10, | ||
| sales_start_date: null, | ||
| sales_end_date: null, | ||
| sub_type: 'Regular', | ||
| audience: 'All', | ||
| badge_type: { id: 1, name: 'General', access_levels: [], badge_features: [] }, | ||
| ...overrides, | ||
| }); | ||
|
|
||
| const discoveredCode = (overrides = {}) => ({ | ||
| id: 100, | ||
| code: 'EARLYBIRD', | ||
| auto_apply: true, | ||
| allows_to_reassign: true, | ||
| quantity_per_account: 3, | ||
| remaining_quantity_per_account: 3, | ||
| quantity_available: 100, | ||
| quantity_used: 0, | ||
| class_name: 'DOMAIN_AUTHORIZED_DISCOUNT_CODE', | ||
| amount: 50, | ||
| rate: 0, | ||
| allowed_ticket_types: [188], | ||
| badge_features: [], | ||
| tags: [], | ||
| ...overrides, | ||
| }); | ||
|
|
||
| const discoveryResponse = (codes = []) => ({ | ||
| total: codes.length, | ||
| per_page: codes.length, | ||
| current_page: 1, | ||
| last_page: 1, | ||
| data: codes, | ||
| }); | ||
|
|
||
| const ticketTypesResponse = (tickets = []) => ({ | ||
| total: tickets.length, | ||
| per_page: tickets.length, | ||
| current_page: 1, | ||
| last_page: 1, | ||
| data: tickets, | ||
| }); | ||
|
|
||
| const taxTypesResponse = (taxes = []) => ({ | ||
| total: taxes.length, | ||
| per_page: taxes.length, | ||
| current_page: 1, | ||
| last_page: 1, | ||
| data: taxes, | ||
| }); | ||
|
|
||
| const validationResponse = (overrides = {}) => ({ | ||
| allows_to_reassign: true, | ||
| ...overrides, | ||
| }); | ||
|
|
||
| const validationError = (message) => ({ | ||
| message: 'Validation Failed', | ||
| errors: [message], | ||
| code: 0, | ||
| }); | ||
|
|
||
| module.exports = { | ||
| ticketType, | ||
| discoveredCode, | ||
| discoveryResponse, | ||
| ticketTypesResponse, | ||
| taxTypesResponse, | ||
| validationResponse, | ||
| validationError, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.