Bez popisu

frontend-testing.sh 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. SERVER_URL="http://localhost:3000"
  2. declare -a Routes=($(grep -oP '(?<=path=")[^"]*' src/App.jsx | grep -E '^[a-zA-Z0-9/_:-]+$' | grep -vE '^/$'))
  3. for i in "${!Routes[@]}"; do
  4. Routes[$i]="${Routes[$i]#/}"
  5. done
  6. # # Add all tab routes and unique routes here
  7. Routes+=(
  8. 'workflows?tab=org_workflows'
  9. 'workflows?tab=my_workflows'
  10. 'workflows?tab=all_workflows'
  11. 'apps/gmail'
  12. 'apis/gmail'
  13. 'apps?tab=my_apps'
  14. 'apps?tab=all_apps'
  15. 'search?tab=org_apps'
  16. 'search?tab=my_apps'
  17. 'search?tab=workflows'
  18. 'search?tab=docs'
  19. 'search?tab=creators'
  20. 'search?tab=discord'
  21. "admin?tab=organization"
  22. "admin?tab=users"
  23. "admin?tab=app_auth"
  24. "admin?tab=datastore"
  25. "admin?tab=files"
  26. "admin?tab=triggers"
  27. "admin?tab=locations"
  28. "admin?tab=tenants"
  29. "admin?admin_tab=org_config"
  30. "admin?admin_tab=sso"
  31. "admin?admin_tab=notifications"
  32. "admin?admin_tab=billingstats"
  33. "admin?admin_tab=branding(beta)"
  34. )
  35. # Stop frontend container so it test unpushed changes
  36. docker stop shuffle-frontend
  37. # # Install all frontend dependencies
  38. yarn add selenium-webdriver --dev && yarn install
  39. echo "Starting frontend..."
  40. BROWSER=none yarn start &
  41. SERVER_PID=$!
  42. echo "Frontend started with PID: $SERVER_PID"
  43. echo "Waiting for 1 minute to ensure the server is fully up..."
  44. sleep 60
  45. echo "Server is up! Starting Selenium tests..."
  46. echo "Starting frontend tests..."
  47. node selenium-test.js "$SERVER_URL" "${Routes[@]}"
  48. TEST_EXIT_CODE=$?
  49. if [[ $TEST_EXIT_CODE -ne 0 ]]; then
  50. echo "Selenium tests failed. Exiting..."
  51. kill $SERVER_PID
  52. exit 1
  53. fi
  54. kill $SERVER_PID
  55. echo "Testing complete. See above logs for errors if any."
  56. # Starting shuffle-frontend container
  57. echo "Starting shuffle-frontend container..."
  58. docker start shuffle-frontend
  59. echo "shuffle-frontend started successfully."
  60. exit 0