freshyo/tests/e2e/run.sh
2026-09-15 23:59:59 +05:30

57 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Runs the Maestro E2E suite against a running Android emulator.
#
# Values come from tests/e2e/.env (copy .env.example first). Maestro's CLI does
# not load .env files itself, so we read it here and forward each value with `-e`.
#
# Usage:
# bash tests/e2e/run.sh # run every entry flow in tests/e2e/
# bash tests/e2e/run.sh add-product.yaml
set -euo pipefail
cd "$(dirname "$0")"
if [ ! -f .env ]; then
echo "Missing tests/e2e/.env — copy .env.example to .env and fill it in." >&2
exit 1
fi
# Load .env line-by-line instead of `source`-ing it, so values that contain
# spaces (e.g. `SKU1_QTY=500 g`) work without needing quotes.
while IFS= read -r line || [ -n "$line" ]; do
line="${line%$'\r'}" # tolerate CRLF
case "$line" in
'' | '#'*) continue ;;
esac
export "$line"
done < ./.env
: "${APP_ID:?APP_ID is required}"
: "${STAFF_NAME:?STAFF_NAME is required}"
: "${STAFF_PASSWORD:?STAFF_PASSWORD is required}"
: "${PRODUCT_NAME:?PRODUCT_NAME is required}"
: "${STORE_ID:?STORE_ID is required}"
# Unique product name so repeat runs don't trip the backend's duplicate check.
PRODUCT_NAME="${PRODUCT_NAME} $(date +%s)"
export PRODUCT_NAME
# Default to the whole suite when no path/tags are passed.
if [ "$#" -eq 0 ]; then
set -- .
fi
maestro test \
-e APP_ID="$APP_ID" \
-e STAFF_NAME="$STAFF_NAME" \
-e STAFF_PASSWORD="$STAFF_PASSWORD" \
-e PRODUCT_NAME="$PRODUCT_NAME" \
-e STORE_ID="$STORE_ID" \
-e SKU1_QTY="${SKU1_QTY:-}" \
-e SKU1_PRICE="${SKU1_PRICE:-}" \
-e SKU1_MRP="${SKU1_MRP:-}" \
-e SKU2_QTY="${SKU2_QTY:-}" \
-e SKU2_PRICE="${SKU2_PRICE:-}" \
-e SKU2_MRP="${SKU2_MRP:-}" \
-e SKU2_FLASH_PRICE="${SKU2_FLASH_PRICE:-}" \
"$@"