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>
This commit is contained in:
Serreau Jovann
2026-03-23 11:14:06 +01:00
parent 61200adc74
commit 04927ec988
68 changed files with 3317 additions and 141 deletions

View File

@@ -48,10 +48,44 @@ install_prod: ## Install les dependances et build les assets pour la prod
bun run build
## —— Tests ————————————————————————————————————————
test_db_create: ## Cree la base de donnees de test
docker compose -f docker-compose-dev.yml exec database psql -U app -d e_ticket -tc "SELECT 1 FROM pg_database WHERE datname = 'e_ticket_test'" | grep -q 1 || \
docker compose -f docker-compose-dev.yml exec database psql -U app -d e_ticket -c "CREATE DATABASE e_ticket_test"
test_db_schema: ## Cree/met a jour le schema de la base de test
docker compose -f docker-compose-dev.yml exec php php bin/console doctrine:schema:update --force --env=test
test_db_migrate: ## Execute les migrations sur la base de test
docker compose -f docker-compose-dev.yml exec php php bin/console doctrine:migrations:migrate --no-interaction --env=test
test_db_reset: ## Supprime et recree la base de test depuis zero
docker compose -f docker-compose-dev.yml exec database psql -U app -d e_ticket -c "DROP DATABASE IF EXISTS e_ticket_test"
docker compose -f docker-compose-dev.yml exec database psql -U app -d e_ticket -c "CREATE DATABASE e_ticket_test"
$(MAKE) test_db_schema
test_db_setup: ## Setup complet de la base de test (cree si besoin + schema)
$(MAKE) test_db_create
$(MAKE) test_db_schema
run_test: ## Lance les tests PHP et JS via Docker dev
docker compose -f docker-compose-dev.yml exec php php bin/phpunit
docker compose -f docker-compose-dev.yml exec bun bun run test
run_test_php: ## Lance uniquement les tests PHP via Docker dev
docker compose -f docker-compose-dev.yml exec php php bin/phpunit
run_test_js: ## Lance uniquement les tests JS via Docker dev
docker compose -f docker-compose-dev.yml exec bun bun run test
run_test_coverage_php: ## Lance les tests PHP avec couverture via Docker dev
docker compose -f docker-compose-dev.yml exec php php bin/phpunit --coverage-text --coverage-html=coverage/php
run_test_coverage_js: ## Lance les tests JS avec couverture via Docker dev
docker compose -f docker-compose-dev.yml exec bun bun run test -- --coverage
run_test_file: ## Lance un fichier de test PHP specifique (usage: make run_test_file FILE=tests/Service/AuditServiceTest.php)
docker compose -f docker-compose-dev.yml exec php php bin/phpunit $(FILE)
## —— PWA —————————————————————————————————————————
pwa_dev: ## Compile les assets PWA en dev via Docker
docker compose -f docker-compose-dev.yml exec php php bin/console pwa:compile