mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:01:08 +02:00
Implement rock-solid automated testing infrastructure for mana-core-auth with daily execution, notifications, and comprehensive monitoring. Test Suite Improvements: - Fix all 36 failing BetterAuthService tests (missing service mocks) - Add 21 JwtAuthGuard tests achieving 100% statement coverage - Create silentError helper to suppress intentional error logs - Fix Todo backend TaskService test structure - Add jose mock for JWT testing - Configure jest collectCoverageFrom for mana-core-auth GitHub Actions Workflow: - Daily automated test execution (2 AM UTC + manual trigger) - Matrix parallelization across 6 backend services - PostgreSQL and Redis service containers - Coverage enforcement (80% threshold) - Multi-channel notifications (Discord, Slack, GitHub Issues) - Support for success notifications (opt-in) Test Infrastructure: - Coverage aggregation across multiple services - Flaky test detection with 30-run history tracking - Performance metrics tracking with regression detection - Test data seeding and cleanup scripts - Comprehensive test reporting with formatted metrics Documentation: - TESTING_GUIDE.md (4000+ words) - Complete testing documentation - AUTOMATED_TESTING_SYSTEM.md - System architecture and workflows - DISCORD_NOTIFICATIONS_SETUP.md - Discord webhook setup guide - TESTING_DEPLOYMENT_CHECKLIST.md - Pre-deployment verification - TESTING_QUICK_REFERENCE.md - Quick command reference Final Result: - 180/180 tests passing (100% pass rate) - Zero console errors in test output - Automated daily testing with rich notifications - Production-ready test infrastructure
79 lines
1.9 KiB
Bash
Executable file
79 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# Cleanup Test Data
|
|
#
|
|
# Removes test data from databases after test execution.
|
|
# Can be used to reset databases to a clean state.
|
|
#
|
|
# Usage:
|
|
# ./scripts/test-data/cleanup-test-data.sh [service]
|
|
#
|
|
# Examples:
|
|
# ./scripts/test-data/cleanup-test-data.sh # Clean all services
|
|
# ./scripts/test-data/cleanup-test-data.sh auth # Clean auth only
|
|
|
|
set -e
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
SERVICE_FILTER=${1:-"all"}
|
|
|
|
echo -e "${YELLOW}Cleaning up test data...${NC}"
|
|
|
|
# Configuration
|
|
export NODE_ENV="test"
|
|
export DATABASE_URL_TEMPLATE="postgresql://manacore:devpassword@localhost:5432"
|
|
|
|
# Cleanup function
|
|
cleanup_database() {
|
|
local db_name=$1
|
|
|
|
echo -e "\n${YELLOW}Cleaning database: ${db_name}${NC}"
|
|
|
|
export DATABASE_URL="${DATABASE_URL_TEMPLATE}/${db_name}"
|
|
|
|
# Drop and recreate database
|
|
psql -U manacore -h localhost -c "DROP DATABASE IF EXISTS ${db_name};" postgres 2>/dev/null || true
|
|
psql -U manacore -h localhost -c "CREATE DATABASE ${db_name};" postgres 2>/dev/null || true
|
|
|
|
echo -e "${GREEN}✓ Cleaned ${db_name}${NC}"
|
|
}
|
|
|
|
# Execute cleanup based on filter
|
|
case "$SERVICE_FILTER" in
|
|
"all")
|
|
cleanup_database "manacore"
|
|
cleanup_database "chat"
|
|
cleanup_database "todo"
|
|
cleanup_database "calendar"
|
|
cleanup_database "contacts"
|
|
cleanup_database "picture"
|
|
;;
|
|
"auth")
|
|
cleanup_database "manacore"
|
|
;;
|
|
"chat")
|
|
cleanup_database "chat"
|
|
;;
|
|
"todo")
|
|
cleanup_database "todo"
|
|
;;
|
|
"calendar")
|
|
cleanup_database "calendar"
|
|
;;
|
|
"contacts")
|
|
cleanup_database "contacts"
|
|
;;
|
|
"picture")
|
|
cleanup_database "picture"
|
|
;;
|
|
*)
|
|
echo -e "${RED}Unknown service: $SERVICE_FILTER${NC}"
|
|
echo "Available services: all, auth, chat, todo, calendar, contacts, picture"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo -e "\n${GREEN}✓ Test data cleaned up successfully!${NC}"
|