#!/bin/bash
# test-mobile.sh
# Author: Matthew Raymer
# Description: Mobile test suite for TimeSafari application
# This script builds the Capacitor version and runs Android and iOS tests
# with proper error handling and logging.
#
# Exit Codes:
# 1 - Capacitor build failed
# 2 - Android tests failed
# 3 - iOS tests failed

# Exit on any error
set -e

# Source common utilities
source "$(dirname "$0")/common.sh"

# Parse command line arguments
parse_args "$@"

# Print test header
print_header "TimeSafari Mobile Test Suite"
log_info "Starting mobile test suite at $(date)"

# Step 1: Build Capacitor version
safe_execute "Building Capacitor version" "npm run build:capacitor" || exit 1

# Step 2: Run Android tests
safe_execute "Running Android tests" "npm run test:android" || exit 2

# Step 3: Run iOS tests
safe_execute "Running iOS tests" "npm run test:ios" || exit 3

# Print test summary
log_success "Mobile test suite completed successfully!"
print_footer "Mobile Test Suite"

# Exit with success
exit 0 