Files
openhuman/scripts/e2e-run-spec.sh
T
Steven EnamakelandGitHub 5ecc7cbc75 refactor: consolidate CLI binaries and streamline CI workflows (#44)
* chore: update dependencies and remove unused packages

- Removed several unused dependencies from package.json, including `@tauri-apps/plugin-shell`, `@types/react-router-dom`, `immer`, `qrcode.react`, and `@testing-library/user-event`.
- Updated the Vite configuration to exclude `telegram` from the optimizeDeps include list.
- Cleaned up yarn.lock by removing references to deleted packages.
- Deleted outdated GitHub Actions workflows for macOS ARM64 build, package and publish, and update changelog.

* refactor: consolidate CLI binaries and update configurations

- Renamed the main binary from `openhuman-core` to `openhuman` for consistency across the project.
- Removed the `openhuman-cli` and `openhuman-core` binaries, consolidating functionality into the new `openhuman` binary.
- Updated build configurations in GitHub Actions and Tauri to reflect the new binary name and paths.
- Adjusted the Tailwind and Vite configurations to point to the correct HTML and source directories.
- Introduced a new method in the Rust core server for handling JSON-RPC calls, enhancing the API structure.

* chore: update subproject commit reference in skills

* chore: update Rust test workflow and improve CLI command formatting

- Modified the GitHub Actions workflow to include a new job for running Rust tests in the workspace.
- Updated the `test:rust` command in `package.json` to run tests for the entire workspace.
- Refactored CLI command definitions in `openhuman.rs` for improved readability by consolidating struct fields into single lines.

* chore: enhance E2E testing scripts and workflows

- Updated `.prettierignore` to exclude the `rust-core` directory.
- Added new E2E testing commands in `package.json` for running all flows and improved formatting commands to include `cargo fmt`.
- Enhanced GitHub Actions workflows to streamline E2E testing, including new scripts for running individual specs and all flows sequentially.
- Refactored existing E2E scripts to utilize a common function for running tests, improving maintainability and readability.
- Introduced a new script for resolving Node.js and Appium dependencies, ensuring compatibility for E2E tests.
- Cleaned up and simplified existing E2E scripts by removing redundant code and consolidating functionality.

* chore: update GitHub Actions workflows for Tauri build process

- Modified build and release workflows to reference the correct target directory for Rust binaries, ensuring compatibility with the Cargo workspace structure.
- Adjusted caching configuration in the test workflow for consistency and improved readability.
- Standardized environment variable formatting in the test workflow to enhance clarity.

* fix: standardize string formatting in GitHub Actions workflows

- Updated the test workflow to use single quotes for cache configuration and environment variables, enhancing consistency across the file.
2026-03-27 13:58:29 -07:00

69 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Run a single WebDriverIO E2E spec (Appium mac2 + mock server in spec).
#
# Usage:
# ./scripts/e2e-run-spec.sh test/e2e/specs/login-flow.spec.ts [log-suffix]
#
set -euo pipefail
SPEC="${1:?spec path required}"
LOG_SUFFIX="${2:-$(basename "$SPEC" .spec.ts)}"
APPIUM_PORT="${APPIUM_PORT:-4723}"
E2E_MOCK_PORT="${E2E_MOCK_PORT:-18473}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=/dev/null
source "$SCRIPT_DIR/e2e-resolve-node-appium.sh"
export VITE_BACKEND_URL="http://127.0.0.1:${E2E_MOCK_PORT}"
export BACKEND_URL="http://127.0.0.1:${E2E_MOCK_PORT}"
echo "Cleaning cached app data..."
rm -rf ~/Library/WebKit/com.openhuman.app
rm -rf ~/Library/Caches/com.openhuman.app
rm -rf "$HOME/Library/Application Support/com.openhuman.app"
DIST_JS="$(ls dist/assets/index-*.js 2>/dev/null | head -1)"
if [ -z "$DIST_JS" ]; then
echo "ERROR: No frontend bundle found at dist/assets/index-*.js." >&2
echo " Run 'yarn test:e2e:build' to build the app before running E2E tests." >&2
exit 1
fi
if ! grep -q "127.0.0.1:${E2E_MOCK_PORT}" "$DIST_JS"; then
echo "ERROR: frontend bundle does NOT contain mock server URL (127.0.0.1:${E2E_MOCK_PORT})." >&2
echo " Run 'yarn test:e2e:build' to rebuild with the mock URL." >&2
exit 1
fi
echo "Verified: frontend bundle contains mock server URL."
APPIUM_LOG="/tmp/appium-e2e-${LOG_SUFFIX}.log"
NODE_VER=$("$NODE24" --version)
echo "Starting Appium on port $APPIUM_PORT (Node $NODE_VER)..."
echo " Appium logs: $APPIUM_LOG"
"$APPIUM_BIN" --port "$APPIUM_PORT" --relaxed-security > "$APPIUM_LOG" 2>&1 &
APPIUM_PID=$!
cleanup() {
echo "Stopping Appium (pid $APPIUM_PID)..."
kill "$APPIUM_PID" 2>/dev/null || true
wait "$APPIUM_PID" 2>/dev/null || true
}
trap cleanup EXIT
for i in $(seq 1 30); do
if curl -sf "http://127.0.0.1:$APPIUM_PORT/status" >/dev/null 2>&1; then
echo "Appium is ready."
break
fi
if [ "$i" -eq 30 ]; then
echo "ERROR: Appium did not start within 30 seconds." >&2
exit 1
fi
sleep 1
done
echo "Running E2E spec ($SPEC)..."
npx wdio run test/wdio.conf.ts --spec "$SPEC"