feat: Sistema controllo accessi Focolari completo con test E2E
🎯 Funzionalità Implementate: - Frontend React/TypeScript/Tailwind ottimizzato per tablet - Backend mock FastAPI con API complete - Hook RFID multi-pattern (US: ;? / IT: ò_) - Flusso validatore → partecipante → conferma ingresso - Carosello benvenuto multilingua (10 lingue, animazione smooth) - Gestione sessione con invalidazione su server restart - Pagina debug RFID accessibile da /debug 🧪 Test Implementati: - 56 unit test (Vitest) - hook RFID, API, componenti - 14 test E2E (Playwright) - flussi completi con browser reale - Test sicurezza: verifica blocco backend per utenti non ammessi 📋 Comandi Disponibili: - ./dev.sh install → Setup dipendenze - ./dev.sh dev → Sviluppo (hot reload) - ./dev.sh server → Produzione locale - ./dev.sh test → Unit test - ./dev.sh test:e2e → Test E2E headless - ./dev.sh test:e2e:headed → Test E2E con browser visibile - ./dev.sh test:e2e:ui → Playwright UI per debug 📝 Documentazione: - README.md con guida completa - API_SPECIFICATION.md per backend reale - TEST_CHECKLIST.md per test manuali - Piani sviluppo in ai-prompts/ ⏳ Stato: MVP completo, in attesa di feedback e richieste future
This commit is contained in:
155
dev.sh
155
dev.sh
@@ -193,6 +193,134 @@ cmd_clean() {
|
||||
success "Pulizia completata"
|
||||
}
|
||||
|
||||
# Test frontend
|
||||
cmd_test() {
|
||||
check_prereqs
|
||||
info "Esecuzione test frontend..."
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test:run
|
||||
}
|
||||
|
||||
# Test in watch mode
|
||||
cmd_test_watch() {
|
||||
check_prereqs
|
||||
info "Avvio test frontend in watch mode..."
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test
|
||||
}
|
||||
|
||||
# Test in watch mode CON server backend attivo
|
||||
cmd_test_dev() {
|
||||
check_prereqs
|
||||
|
||||
# Rebuild frontend se necessario
|
||||
if needs_rebuild; then
|
||||
warn "Rilevati cambiamenti nel frontend, rebuild in corso..."
|
||||
cmd_build
|
||||
fi
|
||||
|
||||
info "Avvio ambiente di test con server..."
|
||||
info "Server: http://localhost:8000"
|
||||
info "Test: watch mode attivo"
|
||||
echo ""
|
||||
|
||||
# Avvia backend in background
|
||||
cd "$BACKEND_DIR"
|
||||
pipenv run python main.py "$@" &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Aspetta che il server sia pronto
|
||||
sleep 2
|
||||
|
||||
# Trap per cleanup
|
||||
trap "kill $BACKEND_PID 2>/dev/null; echo ''; echo 'Server terminato.'" EXIT
|
||||
|
||||
# Avvia test in watch mode
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test
|
||||
}
|
||||
|
||||
# Test E2E con Playwright (headless - avvia server automaticamente)
|
||||
cmd_test_e2e() {
|
||||
check_prereqs
|
||||
|
||||
# Rebuild frontend se necessario
|
||||
if needs_rebuild; then
|
||||
warn "Rilevati cambiamenti nel frontend, rebuild in corso..."
|
||||
cmd_build
|
||||
fi
|
||||
|
||||
info "Avvio test E2E (headless)..."
|
||||
info "Il server viene avviato automaticamente da Playwright"
|
||||
echo ""
|
||||
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test:e2e "$@"
|
||||
}
|
||||
|
||||
# Test E2E con browser visibile (headed) - avvia server manualmente
|
||||
cmd_test_e2e_headed() {
|
||||
check_prereqs
|
||||
|
||||
if needs_rebuild; then
|
||||
warn "Rilevati cambiamenti nel frontend, rebuild in corso..."
|
||||
cmd_build
|
||||
fi
|
||||
|
||||
info "Avvio test E2E con browser visibile..."
|
||||
info "Server: http://localhost:8000 (users_test.json)"
|
||||
echo ""
|
||||
|
||||
# Avvia backend in background con dati di test
|
||||
cd "$BACKEND_DIR"
|
||||
pipenv run python main.py -d data/users_test.json &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Aspetta che il server sia pronto
|
||||
sleep 3
|
||||
|
||||
# Trap per cleanup
|
||||
trap "kill $BACKEND_PID 2>/dev/null; echo ''; success 'Server terminato.'" EXIT
|
||||
|
||||
# Avvia test headed
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test:e2e:headed -- "$@"
|
||||
}
|
||||
|
||||
# Test E2E con UI interattiva (devi avviare i test manualmente dall'UI)
|
||||
cmd_test_e2e_ui() {
|
||||
check_prereqs
|
||||
|
||||
if needs_rebuild; then
|
||||
warn "Rilevati cambiamenti nel frontend, rebuild in corso..."
|
||||
cmd_build
|
||||
fi
|
||||
|
||||
info "Avvio Playwright UI (IDE interattivo)..."
|
||||
info "Server: http://localhost:8000 (users_test.json)"
|
||||
info ""
|
||||
info "Nell'UI di Playwright:"
|
||||
info " 1. Clicca su un test per eseguirlo"
|
||||
info " 2. Usa i controlli per step-by-step debugging"
|
||||
info " 3. Vedi screenshot e trace in tempo reale"
|
||||
echo ""
|
||||
|
||||
# Avvia backend in background con dati di test
|
||||
cd "$BACKEND_DIR"
|
||||
pipenv run python main.py -d data/users_test.json &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Aspetta che il server sia pronto
|
||||
sleep 3
|
||||
|
||||
# Trap per cleanup
|
||||
trap "kill $BACKEND_PID 2>/dev/null; echo ''; success 'Server terminato.'" EXIT
|
||||
|
||||
# Avvia Playwright UI
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run test:e2e:ui
|
||||
}
|
||||
|
||||
# Help
|
||||
cmd_help() {
|
||||
echo "============================================"
|
||||
@@ -208,6 +336,12 @@ cmd_help() {
|
||||
echo " server Builda frontend (se cambiato) e avvia server completo"
|
||||
echo " backend Avvia solo il backend (api-only)"
|
||||
echo " frontend Avvia solo il frontend in dev mode"
|
||||
echo " test Esegue i test frontend (unit)"
|
||||
echo " test:watch Esegue i test frontend in watch mode"
|
||||
echo " test:dev Avvia server + test in watch mode"
|
||||
echo " test:e2e Test E2E headless (server auto)"
|
||||
echo " test:e2e:headed Test E2E con browser visibile"
|
||||
echo " test:e2e:ui Playwright UI per debug interattivo"
|
||||
echo " shell Apre shell pipenv del backend"
|
||||
echo " clean Pulisce build e cache"
|
||||
echo " help Mostra questo messaggio"
|
||||
@@ -255,6 +389,27 @@ case "${1:-help}" in
|
||||
clean)
|
||||
cmd_clean
|
||||
;;
|
||||
test)
|
||||
cmd_test
|
||||
;;
|
||||
"test:watch")
|
||||
cmd_test_watch
|
||||
;;
|
||||
"test:dev")
|
||||
shift
|
||||
cmd_test_dev "$@"
|
||||
;;
|
||||
"test:e2e")
|
||||
shift
|
||||
cmd_test_e2e "$@"
|
||||
;;
|
||||
"test:e2e:headed")
|
||||
shift
|
||||
cmd_test_e2e_headed "$@"
|
||||
;;
|
||||
"test:e2e:ui")
|
||||
cmd_test_e2e_ui
|
||||
;;
|
||||
help|--help|-h)
|
||||
cmd_help
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user