# BaoLife Mobile E2E Lab

This lab gives agents and humans one place to run human-style UI/UX checks across iOS and Android.

## What It Covers

- A local backend launcher with health checks and logs.
- A scenario manifest at `e2e/scenarios/manifest.json`.
- Maestro flows for iOS and Android under `e2e/maestro/`.
- Native test hooks:
  - iOS accepts `--ws-url <url>` or `BAOLIFE_WS_URL`.
  - Android accepts `baolife://debug/config?wsUrl=<encoded-url>`.
  - Both platforms support `baolife://` navigation routes.
- A generated HTML proof packet at `artifacts/e2e/latest/index.html`.

## Prerequisites

Install Maestro once:

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

For Android verification, install a Java runtime and have an emulator/device connected. For iOS verification, have Xcode and an available simulator.

## Start The Local Backend

```bash
cd /Users/craigvandergalien/Documents/GitHub/lichun
scripts/e2e/start-local-backend.sh
```

The script waits for `http://127.0.0.1:8001/health` and writes logs to:

```text
artifacts/e2e/backend/server.log
```

Stop it with:

```bash
scripts/e2e/stop-local-backend.sh
```

## Run The Golden Path

iOS:

```bash
scripts/e2e/run-maestro.sh ios golden_path
```

Android:

```bash
scripts/e2e/run-maestro.sh android golden_path
```

The Android flow configures the emulator to use the host backend via:

```text
baolife://debug/config?wsUrl=ws%3A%2F%2F10.0.2.2%3A8001
```

For iOS XCUITest/manual simulator runs, pass the local backend explicitly:

```bash
cd ios
BAOLIFE_WS_URL=ws://localhost:8001 xcodebuild test \
  -project lichunWebsocket.xcodeproj \
  -scheme BaoLife \
  -destination 'platform=iOS Simulator,name=iPhone 15' \
  -only-testing:lichunWebsocketUITests
```

## Proof Packet

After a Maestro run, open:

```text
artifacts/e2e/latest/index.html
```

It includes the scenario route walk, Maestro log, and any screenshots produced by the flow.

## Adding A Scenario

1. Add a flow under `e2e/maestro/<platform>/`.
2. Register it in `e2e/scenarios/manifest.json`.
3. Add stable accessibility identifiers or Compose test tags before relying on text selectors.
4. Run:

```bash
node --test scripts/e2e/validate-config.test.mjs
```

## Current Golden Path

The default scenario walks:

```text
baolife://skip-onboarding
baolife://home
baolife://activities
baolife://social/messages
baolife://social/dating
baolife://store
```

That path is deliberately boring and valuable: it proves the app launches, accepts testing routes, and exposes the primary surfaces where UI/UX regressions are easiest to see.
