Files
halobestie-clone/client_app/.maestro
Ramadhan Sjamsani e09f76ceb6 Phase 4 §4: payment-before-pair for returning users + Maestro suite
Stages 5.1, 5.3, 5.4 of the returning-user flow rework. All three §4
entry paths now require payment BEFORE pairing, matching the updated
mermaid spec.

* Spec (requirement/flow_customer.mermaid.md §4): payment block converges
  three call-sites (bestie-yang-udah-kenal-online, bestie-baru,
  offline-popup → cari bestie lain). PairRoute dispatches lama → targeted
  pair, baru/cari-lain → §3 blast. §3 retains its post-payment-shared
  contract.

* Stage 5.1 (client_app): PaymentDraft carries targetedMitraId +
  topicSensitivity. bestie_history_list seeds the draft + pushes
  /payment/entry (was legacy /payment). searching_screen branches on
  draft.targetedMitraId for blast-vs-targeted dispatch.
  payment_entry uses resetExceptTarget(); bestie_choice_sheet + home
  _onCurhatBestieBaruPressed call explicit reset() before push so
  the keepAlive draft can't leak stale targeting into a blast.

* Stage 5.3 (client_app): new BestieOfflineVariant.prePayReturning.
  Bestie-history-list _BestieRow splits tappable from dim so offline
  rows render dimmed but route taps into the popup. CTA "cari bestie
  lain" resets the draft + pushes /payment/entry.

* Stage 5.4 (client_app): deleted legacy /payment route,
  payment_screen.dart, payment_notifier.dart(+.g.dart). router cleaned.

* Tests (requirement/phase4-customer-flow.md + client_app/.maestro/):
  six Maestro flows TS-01..TS-06 covering every §4 branching point,
  all passing end-to-end. Shared onboarding prelude under
  .maestro/subflows/. New helper scripts: accept_latest_pending,
  force_mitra_offline, force_other_mitra_online,
  reset_all_mitras_online, mitra_accept_latest_internal. New backend
  _test endpoints to match. /reset-phone now cascade-deletes
  customer_transactions (FK was blocking). /force-pairing-timeout
  branches targeted (RETURNING_CHAT_TIMEOUT via
  expireTargetedPairingRequest, now exported) vs blast (PAIRING_FAILED).
  seed_history_session also outputs MITRA_NAME_RE (regex-escaped) for
  reliable selectors against display names containing regex specials.

* mitra_app: dispose-during-deactivate guardrail for back-press on the
  mitra chat screen after the customer's goodbye message. Pending real
  emulator repro verification (carried over from 2026-05-15).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 20:25:15 +08:00
..

client_app Maestro flows

End-to-end UI automation for the customer Flutter app using Maestro. Single-emulator + curl-as-mitra pattern — the customer app is driven by real Maestro touches; the mitra side is simulated via backend API calls fired from runScript steps.

One-time install

Maestro is a global CLI (not a project dependency). Install on your dev machine once:

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

Verify with maestro --version. See the Maestro install docs for Homebrew / chocolatey / Docker alternatives.

You also need:

  • adb on your PATH (comes with Android Studio's platform-tools)
  • jq for the helper scripts (apt install jq / brew install jq)
  • One Android emulator OR one connected device — only one at a time (per project decision)

Folder layout

.maestro/
├── README.md                 # this file
├── config.yaml               # shared env: app IDs, backend URL, test credentials
├── flows/                    # the YAML test scripts
│   ├── 01_smoke.yaml
│   ├── 02_cta_disabled_when_no_mitra.yaml
│   └── 03_payment_to_chat_happy.yaml
└── scripts/                  # bash helpers invoked by `runScript` steps
    ├── mitra_accept_latest.sh
    └── force_all_mitras_offline.sh

Configure for your environment

Edit .maestro/config.yaml and fill in:

  • BACKEND_URL — must match the --dart-define=API_BASE_URL=... value the installed APK was built with
  • TEST_MITRA_ID and TEST_MITRA_JWT — used by the curl harness to "accept" requests from the customer's blast

The config file is committed because the values are dev-environment defaults. Sensitive credentials (real JWTs, CC operator tokens) should be passed at runtime instead — see "Per-machine overrides" below.

Run a flow

Single emulator (typical case — Maestro auto-picks the only attached device):

# from repo root or anywhere
maestro test client_app/.maestro/flows/01_smoke.yaml

# or run all flows in the directory
maestro test client_app/.maestro/flows/

If both an emulator and a real device happen to be connected, list them and pick one explicitly:

adb devices                                       # list attached devices
maestro --device emulator-5554 test client_app/.maestro/flows/01_smoke.yaml

Per-machine overrides

Override any config.yaml value at runtime with --env:

maestro test \
  --env BACKEND_URL=http://192.168.99.10:3000 \
  --env TEST_MITRA_JWT=eyJhbGc... \
  client_app/.maestro/flows/03_payment_to_chat_happy.yaml

Or export shell variables — runScript steps inherit them:

export CC_JWT=eyJhbGc...
maestro test client_app/.maestro/flows/02_cta_disabled_when_no_mitra.yaml

Single-emulator + curl pattern

Phase 3.7 flows often need a customer + a mitra acting in concert. Instead of running two emulators (RAM-heavy, flaky), the flows drive the customer side with Maestro and simulate the mitra via backend curl calls:

  1. Maestro flow drives customer up to the "Mencari Bestie..." state
  2. runScript: ../scripts/mitra_accept_latest.sh fires POST /api/mitra/chat-requests/:id/accept against the backend, using a pre-minted mitra JWT
  3. Maestro flow asserts the customer screen transitions to "Bestie Ditemukan" via the WS round-trip

This works for ~90% of multi-actor scenarios — including all the Section D ("Curhat lagi") and Section J ("Mitra goes offline mid-session") tests in phase3.7-testing.md. The 10% that needs both UIs running (e.g., asserting the mitra-side overlay countdown displays correctly) is in mitra_app/.maestro/ and runs separately.

Adding a new flow

Pick a Phase 3.7 testing checklist scenario (see phase3.7-testing.md), then:

  1. Copy an existing flow as a template (e.g., 03_payment_to_chat_happy.yaml)
  2. Update the pre-req comment, the steps, and the assertions
  3. If you need a "second actor" action, add a bash helper under scripts/ and call it via runScript:
  4. If you need new env vars, add them to config.yaml with sensible defaults

Tips

  • Find the right text to tap onmaestro studio opens a live UI inspector showing every visible label/widget. Run it while the app is on the screen you care about.
  • Slow it down for debuggingmaestro test --debug-output ./debug flows/foo.yaml saves screenshots + logs per step.
  • Add flows incrementally — Maestro's reload-on-save in maestro studio makes iteration fast.
  • Don't commit screenshots / debug output — add .maestro/output/ and .maestro/screenshots/ to .gitignore if you generate them locally.

Troubleshooting

  • maestro: device not found → run adb devices; if empty, start an emulator (emulator -avd <name>) or plug in a USB device with debugging enabled.
  • Element not visible errors → use maestro studio to inspect actual labels — they may have changed since the flow was written.
  • Flow hangs at assertVisible waiting for backend → check BACKEND_URL matches the APK's build-time value (grep API_BASE_URL build.gradle).
  • runScript exits non-zero → run the script directly to see its error: bash client_app/.maestro/scripts/mitra_accept_latest.sh. Most often a missing env var or stale JWT.