Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
2026-03-21 13:46:06 +01:00
|
|
|
import { initCart } from '../../assets/modules/cart.js'
|
|
|
|
|
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
function createBilletterie(billets, stockUrl = '') {
|
|
|
|
|
let html = `<div id="billetterie"${stockUrl ? ` data-stock-url="${stockUrl}"` : ''}>`
|
2026-03-21 13:46:06 +01:00
|
|
|
|
|
|
|
|
for (const b of billets) {
|
|
|
|
|
html += `
|
|
|
|
|
<div data-cart-item data-billet-id="${b.id}" data-price="${b.price}" data-max="${b.max}">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="${b.max || 99}" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
<p data-stock-label></p>
|
2026-03-21 13:46:06 +01:00
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
html += '<div id="cart-error" class="hidden"><p id="cart-error-text"></p></div>'
|
Add reservation flow: BilletBuyer, guest checkout, Stripe payment
- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:54:17 +01:00
|
|
|
html += '<span id="cart-total"></span><span id="cart-count"></span><button id="cart-checkout" disabled data-order-url="/order"></button></div>'
|
2026-03-21 13:46:06 +01:00
|
|
|
document.body.innerHTML = html
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('initCart', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
document.body.innerHTML = ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does nothing without billetterie element', () => {
|
|
|
|
|
expect(() => initCart()).not.toThrow()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does nothing without total element', () => {
|
|
|
|
|
document.body.innerHTML = '<div id="billetterie"></div>'
|
|
|
|
|
expect(() => initCart()).not.toThrow()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('initializes with zero totals', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('0,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-count').textContent).toBe('0')
|
|
|
|
|
expect(document.getElementById('cart-checkout').disabled).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('increments quantity on plus click', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '15.00', max: 10 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('1')
|
|
|
|
|
expect(document.querySelector('[data-cart-line-total]').textContent).toBe('15,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('15,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-count').textContent).toBe('1')
|
|
|
|
|
expect(document.getElementById('cart-checkout').disabled).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('decrements quantity on minus click', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.querySelector('[data-cart-minus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('1')
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('10,00 \u20AC')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does not decrement below zero', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-minus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('0')
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('0,00 \u20AC')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('respects max quantity', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 2 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('2')
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('20,00 \u20AC')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('allows unlimited when max is 0', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '5.00', max: 0 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 50; i++) {
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('50')
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('250,00 \u20AC')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('calculates total for multiple billets', () => {
|
|
|
|
|
createBilletterie([
|
|
|
|
|
{ id: 1, price: '10.00', max: 5 },
|
|
|
|
|
{ id: 2, price: '25.00', max: 3 },
|
|
|
|
|
])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
const plusBtns = document.querySelectorAll('[data-cart-plus]')
|
|
|
|
|
plusBtns[0].click()
|
|
|
|
|
plusBtns[0].click()
|
|
|
|
|
plusBtns[1].click()
|
|
|
|
|
|
|
|
|
|
// 2 * 10 + 1 * 25 = 45
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('45,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-count').textContent).toBe('3')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('disables checkout when cart is empty again', () => {
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
expect(document.getElementById('cart-checkout').disabled).toBe(false)
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-minus]').click()
|
|
|
|
|
expect(document.getElementById('cart-checkout').disabled).toBe(true)
|
|
|
|
|
})
|
Add reservation flow: BilletBuyer, guest checkout, Stripe payment
- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:54:17 +01:00
|
|
|
|
|
|
|
|
it('posts cart data on checkout click', () => {
|
|
|
|
|
const fetchMock = vi.fn().mockResolvedValue({
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
ok: true,
|
Add reservation flow: BilletBuyer, guest checkout, Stripe payment
- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:54:17 +01:00
|
|
|
json: () => Promise.resolve({ redirect: '/commande/1/informations' }),
|
|
|
|
|
})
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
createBilletterie([
|
|
|
|
|
{ id: 1, price: '10.00', max: 5 },
|
|
|
|
|
{ id: 2, price: '20.00', max: 3 },
|
|
|
|
|
])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
const plusBtns = document.querySelectorAll('[data-cart-plus]')
|
|
|
|
|
plusBtns[0].click()
|
|
|
|
|
plusBtns[0].click()
|
|
|
|
|
plusBtns[1].click()
|
|
|
|
|
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
expect(fetchMock).toHaveBeenCalledWith('/order', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
|
body: JSON.stringify([
|
|
|
|
|
{ billetId: '1', qty: 2 },
|
|
|
|
|
{ billetId: '2', qty: 1 },
|
|
|
|
|
]),
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-21 16:03:17 +01:00
|
|
|
it('redirects after successful checkout', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockResolvedValue({
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
ok: true,
|
2026-03-21 16:03:17 +01:00
|
|
|
json: () => Promise.resolve({ redirect: '/commande/1/paiement' }),
|
|
|
|
|
})
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
globalThis.location = { href: '' }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 10))
|
|
|
|
|
|
|
|
|
|
expect(globalThis.location.href).toBe('/commande/1/paiement')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does not redirect when response has no redirect', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockResolvedValue({
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
ok: true,
|
2026-03-21 16:03:17 +01:00
|
|
|
json: () => Promise.resolve({}),
|
|
|
|
|
})
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
globalThis.location = { href: '/original' }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 10))
|
|
|
|
|
|
|
|
|
|
expect(globalThis.location.href).toBe('/original')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('re-enables button on fetch error', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockRejectedValue(new Error('Network error'))
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 10))
|
|
|
|
|
|
|
|
|
|
const btn = document.getElementById('cart-checkout')
|
|
|
|
|
expect(btn.disabled).toBe(false)
|
|
|
|
|
expect(btn.textContent).toBe('Commander')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('handles invalid price gracefully', () => {
|
|
|
|
|
document.body.innerHTML = `
|
|
|
|
|
<div id="billetterie">
|
|
|
|
|
<div data-cart-item data-billet-id="1" data-price="invalid" data-max="5">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="5" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
|
|
|
|
</div>
|
|
|
|
|
<span id="cart-total"></span><span id="cart-count"></span>
|
|
|
|
|
<button id="cart-checkout" disabled data-order-url="/order"></button>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('0,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-count').textContent).toBe('1')
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-21 17:43:43 +01:00
|
|
|
it('works without checkout button', () => {
|
|
|
|
|
document.body.innerHTML = `
|
|
|
|
|
<div id="billetterie">
|
|
|
|
|
<div data-cart-item data-billet-id="1" data-price="10" data-max="5">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="5" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
|
|
|
|
</div>
|
|
|
|
|
<span id="cart-total"></span><span id="cart-count"></span>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
|
|
|
|
|
expect(document.getElementById('cart-total').textContent).toBe('10,00 \u20AC')
|
|
|
|
|
expect(document.getElementById('cart-count').textContent).toBe('1')
|
|
|
|
|
})
|
|
|
|
|
|
Add reservation flow: BilletBuyer, guest checkout, Stripe payment
- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:54:17 +01:00
|
|
|
it('does not post when cart is empty on checkout', () => {
|
|
|
|
|
const fetchMock = vi.fn()
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.getElementById('cart-checkout').disabled = false
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
expect(fetchMock).not.toHaveBeenCalled()
|
|
|
|
|
})
|
|
|
|
|
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
it('shows error message on HTTP error', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockResolvedValue({ ok: false, status: 400 })
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 10))
|
|
|
|
|
|
|
|
|
|
const errorEl = document.getElementById('cart-error')
|
|
|
|
|
expect(errorEl.classList.contains('hidden')).toBe(false)
|
|
|
|
|
expect(document.getElementById('cart-error-text').textContent).toContain('erreur')
|
|
|
|
|
})
|
|
|
|
|
|
Add LibreTranslate auto-translation, improve test coverage, fix code duplication
Translation system:
- Add LibreTranslate container (dev + prod), CPU-only, no port exposed, FR/EN/ES/DE/IT
- Create app:translate command: reads *.fr.yaml, translates incrementally, preserves placeholders
- Makefile: make trans / make trans_prod (stops container after translation)
- Ansible: start libretranslate -> translate -> stop during deploy
- Prod container restart: "no" (only runs during deploy)
- .gitignore: ignore generated *.en/es/de/it.yaml files
- 11 tests for TranslateCommand (API unreachable, empty, incremental, obsolete keys, placeholders, fallback)
Test coverage improvements:
- OrderController: event ended (400), invalid cart JSON, invalid email, stock zero (4 new tests)
- AccountController: finance stats all statuses (paid/pending/refunded/cancelled), soldCounts (2 new tests)
- JS cart: checkout without error elements, hide error on retry, stock polling edge cases (singular, no label, qty zero, unknown billet) (8 new tests)
- JS editor: comment node sanitization (1 new test)
- JS tabs: missing panel, generated id, parent null, click no-panel (5 new tests)
Code duplication fixes:
- MeilisearchConsistencyCommand: extract diffAndReport() method (was duplicated 3x)
- Email templates: extract _order_items_table.html.twig partial (shared by notification + cancelled)
- SonarQube: exclude src/Entity/** from CPD (getters/setters duplication)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:44:13 +01:00
|
|
|
it('handles checkout without error elements', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockRejectedValue(new Error('fail'))
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
document.body.innerHTML = `
|
|
|
|
|
<div id="billetterie">
|
|
|
|
|
<div data-cart-item data-billet-id="1" data-price="10" data-max="5">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="5" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
|
|
|
|
</div>
|
|
|
|
|
<span id="cart-total"></span><span id="cart-count"></span>
|
|
|
|
|
<button id="cart-checkout" disabled data-order-url="/order"></button>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 10))
|
|
|
|
|
|
|
|
|
|
expect(document.getElementById('cart-checkout').disabled).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('hides error on new checkout attempt', async () => {
|
|
|
|
|
const fetchMock = vi.fn().mockResolvedValue({
|
|
|
|
|
ok: true,
|
|
|
|
|
json: () => Promise.resolve({ redirect: '/ok' }),
|
|
|
|
|
})
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
globalThis.location = { href: '' }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
const errorEl = document.getElementById('cart-error')
|
|
|
|
|
errorEl.classList.remove('hidden')
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
expect(errorEl.classList.contains('hidden')).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
Add reservation flow: BilletBuyer, guest checkout, Stripe payment
- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:54:17 +01:00
|
|
|
it('does not post without order url', () => {
|
|
|
|
|
const fetchMock = vi.fn()
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
|
|
|
|
|
document.body.innerHTML = `
|
|
|
|
|
<div id="billetterie">
|
|
|
|
|
<div data-cart-item data-billet-id="1" data-price="10" data-max="5">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="5" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
|
|
|
|
</div>
|
|
|
|
|
<span id="cart-total"></span><span id="cart-count"></span>
|
|
|
|
|
<button id="cart-checkout" disabled></button>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.getElementById('cart-checkout').click()
|
|
|
|
|
|
|
|
|
|
expect(fetchMock).not.toHaveBeenCalled()
|
|
|
|
|
})
|
2026-03-21 13:46:06 +01:00
|
|
|
})
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
|
|
|
|
|
describe('stock polling', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
document.body.innerHTML = ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function mockStock(stock) {
|
|
|
|
|
return vi.fn().mockResolvedValue({
|
|
|
|
|
json: () => Promise.resolve(stock),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it('polls stock URL and updates labels for out of stock', async () => {
|
|
|
|
|
const fetchMock = mockStock({ 1: 0 })
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
expect(fetchMock).toHaveBeenCalledWith('/stock')
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toContain('Rupture')
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('0')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('polls stock URL and shows low stock warning', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 5 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 20 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toContain('Plus que')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('polls stock URL and shows normal stock', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 50 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 100 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toContain('disponible')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('clamps qty when stock decreases below current selection', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 2 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 10 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
|
|
|
document.querySelector('[data-cart-plus]').click()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('2')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does not poll without stock URL', () => {
|
|
|
|
|
const fetchMock = vi.fn()
|
|
|
|
|
globalThis.fetch = fetchMock
|
|
|
|
|
const origSetInterval = globalThis.setInterval
|
|
|
|
|
const intervalSpy = vi.fn()
|
|
|
|
|
globalThis.setInterval = intervalSpy
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }])
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
expect(intervalSpy).not.toHaveBeenCalled()
|
|
|
|
|
globalThis.setInterval = origSetInterval
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('handles stock poll fetch error gracefully', async () => {
|
|
|
|
|
globalThis.fetch = vi.fn().mockRejectedValue(new Error('Network'))
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
// No crash, label unchanged
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toBe('')
|
|
|
|
|
})
|
Add LibreTranslate auto-translation, improve test coverage, fix code duplication
Translation system:
- Add LibreTranslate container (dev + prod), CPU-only, no port exposed, FR/EN/ES/DE/IT
- Create app:translate command: reads *.fr.yaml, translates incrementally, preserves placeholders
- Makefile: make trans / make trans_prod (stops container after translation)
- Ansible: start libretranslate -> translate -> stop during deploy
- Prod container restart: "no" (only runs during deploy)
- .gitignore: ignore generated *.en/es/de/it.yaml files
- 11 tests for TranslateCommand (API unreachable, empty, incremental, obsolete keys, placeholders, fallback)
Test coverage improvements:
- OrderController: event ended (400), invalid cart JSON, invalid email, stock zero (4 new tests)
- AccountController: finance stats all statuses (paid/pending/refunded/cancelled), soldCounts (2 new tests)
- JS cart: checkout without error elements, hide error on retry, stock polling edge cases (singular, no label, qty zero, unknown billet) (8 new tests)
- JS editor: comment node sanitization (1 new test)
- JS tabs: missing panel, generated id, parent null, click no-panel (5 new tests)
Code duplication fixes:
- MeilisearchConsistencyCommand: extract diffAndReport() method (was duplicated 3x)
- Email templates: extract _order_items_table.html.twig partial (shared by notification + cancelled)
- SonarQube: exclude src/Entity/** from CPD (getters/setters duplication)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:44:13 +01:00
|
|
|
|
|
|
|
|
it('skips billet not in stock response', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 999: 10 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
// Label unchanged — billet 1 not in response
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toBe('')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('handles out of stock when qty already zero', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 0 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
// Don't click +, qty stays at 0
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
expect(document.querySelector('[data-stock-label]').innerHTML).toContain('Rupture')
|
|
|
|
|
expect(document.querySelector('[data-cart-qty]').value).toBe('0')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('shows singular place for stock of 1', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 1 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 5 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
const label = document.querySelector('[data-stock-label]')
|
|
|
|
|
expect(label.innerHTML).toContain('Plus que 1 place !')
|
|
|
|
|
expect(label.innerHTML).not.toContain('places')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('shows singular for stock of exactly 1 in normal range', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 50 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
createBilletterie([{ id: 1, price: '10.00', max: 100 }], '/stock')
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
const label = document.querySelector('[data-stock-label]')
|
|
|
|
|
expect(label.innerHTML).toContain('50 places disponibles')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('handles item without stock-label element', async () => {
|
|
|
|
|
globalThis.fetch = mockStock({ 1: 5 })
|
|
|
|
|
globalThis.setInterval = (fn) => { fn(); return 1 }
|
|
|
|
|
|
|
|
|
|
// Create billetterie without data-stock-label
|
|
|
|
|
document.body.innerHTML = `
|
|
|
|
|
<div id="billetterie" data-stock-url="/stock">
|
|
|
|
|
<div data-cart-item data-billet-id="1" data-price="10.00" data-max="20">
|
|
|
|
|
<button data-cart-minus></button>
|
|
|
|
|
<input data-cart-qty type="number" min="0" max="20" value="0" readonly>
|
|
|
|
|
<button data-cart-plus></button>
|
|
|
|
|
<span data-cart-line-total></span>
|
|
|
|
|
</div>
|
|
|
|
|
<span id="cart-total"></span><span id="cart-count"></span>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
initCart()
|
|
|
|
|
|
|
|
|
|
await new Promise(r => setTimeout(r, 20))
|
|
|
|
|
|
|
|
|
|
// No crash, max updated
|
|
|
|
|
expect(document.querySelector('[data-cart-item]').dataset.max).toBe('5')
|
|
|
|
|
})
|
Complete TASK_CHECKUP: security, UX, tests, coverage, accessibility, config externalization
Billetterie:
- Partial refund support (STATUS_PARTIALLY_REFUNDED, refundedAmount field, migration)
- Race condition fix: PESSIMISTIC_WRITE lock on stock decrement in transaction
- Idempotency key on PaymentIntent::create, reuse existing PI if stripeSessionId set
- Disable checkout when event ended (server 400 + template hide)
- Webhook deduplication via cache (24h TTL on stripe event.id)
- Email validation (filter_var) in OrderController guest flow
- JSON cart validation (structure check before processing)
- Invitation expiration after 7 days (isExpired method + landing page message)
- Stripe Checkout fallback when JS fails to load (noscript + redirect)
Config externalization:
- Move Stripe fees (STRIPE_FEE_RATE, STRIPE_FEE_FIXED) and admin email (ADMIN_EMAIL) to .env/services.yaml
- Replace all hardcoded contact@e-cosplay.fr across 13 files
- MailerService: getAdminEmail()/getAdminFrom(), default $from=null resolves to admin
UX & Accessibility:
- ARIA tabs: role=tablist/tab/tabpanel, aria-selected, keyboard nav (arrows, Home, End)
- aria-label on cart +/- buttons and editor toolbar buttons
- tabindex=0 on editor toolbar buttons for keyboard access
- data-confirm handler in app.js (was only in admin.js)
- Cart error feedback on checkout failure
- Billet designer save feedback (loading/success/error states)
- Stock polling every 30s with rupture/low stock badges
- Back to event link on payment page
Security:
- HTML sanitizer: BLOCKED_TAGS list (script, style, iframe, svg, etc.) - content fully removed
- Stripe polling timeout (15s max) with fallback redirect
- Rate limiting on public order access (20/5min)
- .catch() on all fetch() calls (sortable, billet-designer)
Tests (92% PHP, 100% JS lines):
- PCOV added to dev Dockerfile
- Test DB setup: .env.test with DATABASE_URL, Redis auth, Meilisearch key
- Rate limiter disabled in test env
- Makefile: test_db_setup, test_db_reset, run_test_php, run_test_coverage_php/js
- New tests: InvitationFlowTest (21), AuditServiceTest (4), ExportServiceTest (9), InvoiceServiceTest (4)
- New tests: SuspendedUserSubscriberTest, RateLimiterSubscriberTest, MeilisearchServiceTest
- New tests: Stripe webhook payment_failed (6) + charge.refunded (6)
- New tests: BilletBuyer refund, User suspended, OrganizerInvitation expiration
- JS tests: stock polling (6), data-confirm (2), copy-url restore (1), editor ARIA (2), XSS (9), tabs keyboard (9)
- ESLint + PHP CS Fixer: 0 errors
- SonarQube exclusions aligned with vitest coverage config
Infra:
- Meilisearch consistency command (app:meilisearch:check-consistency --fix) + cron daily 3am
- MeilisearchService: getAllDocumentIds(), listIndexes()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:14:06 +01:00
|
|
|
})
|