|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
ui=false |
|
|
|
|
|
|
|
|
PROJECT_ROOT="../../" |
|
|
|
|
|
|
|
|
for cmd in npx poetry fuser; do |
|
|
if ! command -v $cmd &> /dev/null; then |
|
|
echo "Error: Required command '$cmd' is not installed. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
done |
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do |
|
|
key="$1" |
|
|
case $key in |
|
|
--ui) |
|
|
ui=true |
|
|
shift |
|
|
;; |
|
|
*) |
|
|
echo "Unknown option: $key" |
|
|
exit 1 |
|
|
;; |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
|
|
|
terminate_process_by_port() { |
|
|
port="$1" |
|
|
echo "Terminating process on port: $port" |
|
|
if ! fuser -k -n tcp "$port"; then |
|
|
echo "Failed to terminate process on port $port. Please check manually." |
|
|
else |
|
|
echo "Process terminated." |
|
|
fi |
|
|
} |
|
|
|
|
|
delete_temp() { |
|
|
if cd "$PROJECT_ROOT"; then |
|
|
echo "Deleting temp database" |
|
|
rm -f temp && echo "Temp database deleted." || echo "Failed to delete temp database." |
|
|
else |
|
|
echo "Failed to navigate to project root for cleanup." |
|
|
fi |
|
|
} |
|
|
|
|
|
|
|
|
trap 'terminate_process_by_port 7860; terminate_process_by_port 3000; delete_temp' EXIT |
|
|
|
|
|
|
|
|
if ! cd "$PROJECT_ROOT"; then |
|
|
echo "Error: Failed to navigate to project root directory. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
if ! npx playwright install; then |
|
|
echo "Error: Failed to install Playwright. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
make frontend > /dev/null 2>&1 & |
|
|
|
|
|
|
|
|
sleep 10 |
|
|
|
|
|
|
|
|
if ! poetry install; then |
|
|
echo "Error: Failed to install backend dependencies. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
LANGFLOW_DATABASE_URL=sqlite:///./temp LANGFLOW_AUTO_LOGIN=True poetry run langflow run --backend-only --port 7860 --host 0.0.0.0 --no-open-browser > /dev/null 2>&1 & |
|
|
backend_pid=$! |
|
|
|
|
|
sleep 25 |
|
|
|
|
|
|
|
|
if ! cd src/frontend; then |
|
|
echo "Error: Failed to navigate to test directory. Aborting." |
|
|
kill $backend_pid |
|
|
echo "Backend process terminated." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
if ! lsof -i :7860; then |
|
|
echo "Error: Backend is not running. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$ui" = true ]; then |
|
|
TEST_COMMAND="npx playwright test tests/core --ui --project=chromium" |
|
|
else |
|
|
TEST_COMMAND="npx playwright test tests/core --project=chromium" |
|
|
fi |
|
|
|
|
|
if ! PLAYWRIGHT_HTML_REPORT=playwright-report/e2e $TEST_COMMAND; then |
|
|
echo "Error: Playwright tests failed. Aborting." |
|
|
exit 1 |
|
|
fi |
|
|
|
|
|
if [ "$ui" = true ]; then |
|
|
echo "Opening Playwright report..." |
|
|
npx playwright show-report |
|
|
fi |
|
|
|
|
|
|
|
|
trap 'terminate_process_by_port 7860; terminate_process_by_port 3000; delete_temp; kill $backend_pid 2>/dev/null' EXIT |