# How to Run Maestro Integration Tests

Credentials are injected via env variables — **never hardcoded** in YAML.

## Env variables

| Flow | Env variables |
|------|---------------|
| **Client sign-in** | `TEST_CLIENT_EMAIL`, `TEST_CLIENT_PASSWORD` |
| **Client sign-up** | `TEST_CLIENT_EMAIL`, `TEST_CLIENT_PASSWORD`, `TEST_CLIENT_COMPANY` |
| **Staff sign-in** | `TEST_STAFF_PHONE`, `TEST_STAFF_OTP` |
| **Staff sign-up** | `TEST_STAFF_SIGNUP_PHONE`, `TEST_STAFF_OTP` |

**Example values (login):** legendary@krowd.com / Demo2026! (client), 5557654321 / 123456 (staff)

---

## Step-by-step

### 1. Install Maestro CLI

**Windows:** Download from [Maestro releases](https://github.com/mobile-dev-inc/maestro/releases), extract, add to PATH.

**macOS/Linux:**
```bash
curl -Ls "https://get.maestro.mobile.dev" | bash
```

### 2. Add Firebase test phone (Staff app)

Firebase Console → **Authentication** → **Sign-in method** → **Phone** → **Phone numbers for testing**:
- Add **+1 5557654321** with verification code **123456**

### 3. Build and install apps

```bash
make mobile-client-build PLATFORM=apk MODE=debug
adb install apps/mobile/apps/client/build/app/outputs/flutter-apk/app-debug.apk

make mobile-staff-build PLATFORM=apk MODE=debug
adb install apps/mobile/apps/staff/build/app/outputs/flutter-apk/app-debug.apk
```

### 4. Run E2E tests via Makefile

**Export credentials, then run:**

```bash
# Client login credentials
export TEST_CLIENT_EMAIL=legendary@krowd.com
export TEST_CLIENT_PASSWORD=Demo2026!
export TEST_CLIENT_COMPANY="KROW Demo"

# Staff login credentials
export TEST_STAFF_PHONE=5557654321
export TEST_STAFF_OTP=123456
export TEST_STAFF_SIGNUP_PHONE=5555550000   # use a new number for signup

# Run full suite
make test-e2e

# Or run per app
make test-e2e-client
make test-e2e-staff
```

### 5. Run flows directly (without Make)

```bash
maestro test apps/mobile/apps/client/maestro/auth/sign_in.yaml \
  -e TEST_CLIENT_EMAIL=legendary@krowd.com \
  -e TEST_CLIENT_PASSWORD=Demo2026!

maestro test apps/mobile/apps/staff/maestro/auth/sign_in.yaml \
  -e TEST_STAFF_PHONE=5557654321 \
  -e TEST_STAFF_OTP=123456
```

---

## Folder structure

```
apps/mobile/apps/client/maestro/auth/
  sign_in.yaml
  sign_up.yaml
apps/mobile/apps/staff/maestro/auth/
  sign_in.yaml
  sign_up.yaml
```

---

## Checklist

- [ ] Maestro CLI installed
- [ ] Firebase test phone +1 5557654321 / 123456 added
- [ ] Client & Staff apps built and installed
- [ ] Env vars exported
- [ ] `make test-e2e` run from project root
