← back to Dear Bubbe Nextjs
scripts/auto-test-voice.sh
42 lines
#!/bin/bash
# Automated Voice Testing with Playwright - Runs every 5 minutes
# Tests mobile and desktop voice functionality
LOG_FILE="/root/Projects/dear-bubbe-nextjs/voice-test.log"
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$TIMESTAMP] ========== Voice Test Started ==========" >> "$LOG_FILE"
cd /root/Projects/dear-bubbe-nextjs
# Run Playwright test
timeout 45 node test-voice-mobile.js >> "$LOG_FILE" 2>&1
TEST_EXIT=$?
if [ $TEST_EXIT -eq 0 ]; then
echo "[$TIMESTAMP] ✅ Voice test PASSED" >> "$LOG_FILE"
else
echo "[$TIMESTAMP] ❌ Voice test FAILED (exit code: $TEST_EXIT)" >> "$LOG_FILE"
# Auto-fix: Restart PM2 if test failed
echo "[$TIMESTAMP] 🔧 Auto-fix: Restarting PM2..." >> "$LOG_FILE"
pm2 restart bubbe-nextjs >> "$LOG_FILE" 2>&1
sleep 5
# Test again after restart
timeout 45 node test-voice-mobile.js >> "$LOG_FILE" 2>&1
RETEST_EXIT=$?
if [ $RETEST_EXIT -eq 0 ]; then
echo "[$TIMESTAMP] ✅ Voice test PASSED after restart" >> "$LOG_FILE"
else
echo "[$TIMESTAMP] 🚨 Voice test still FAILING after restart!" >> "$LOG_FILE"
fi
fi
echo "[$TIMESTAMP] ========== Voice Test Complete ==========" >> "$LOG_FILE"
echo "" >> "$LOG_FILE"
exit $TEST_EXIT