62 lines
2.4 KiB
Markdown
62 lines
2.4 KiB
Markdown
# Admin E2E tests (Maestro)
|
|
|
|
Maestro flows that drive the **admin-ui** Expo app on an Android emulator.
|
|
|
|
## Layout
|
|
|
|
```
|
|
tests/e2e/
|
|
config.yaml # workspace config (entry flows = *.yaml at the root)
|
|
add-product.yaml # first flow: create a product with 2 SKUs (one flash)
|
|
subflows/
|
|
login.yaml # reusable login
|
|
pick-image.yaml # OS photo-picker adapter (Android)
|
|
assets/test-product.png # seeded into the emulator gallery via `addMedia`
|
|
run.sh # sources .env and runs `maestro test`
|
|
.env.example # copy to .env and fill in
|
|
```
|
|
|
|
## Prerequisites
|
|
|
|
- Maestro CLI installed (`curl -Ls "https://get.maestro.mobile.dev" | bash`).
|
|
- A booted Android emulator (`maestro start-device --platform android`, or Android Studio).
|
|
- The admin-ui **dev build** installed on the emulator (`bun run --filter admin-ui android`, appId `in.freshyo.adminui`).
|
|
- The build must be able to reach the backend (login + image upload hit the API/R2).
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
cp tests/e2e/.env.example tests/e2e/.env
|
|
# edit tests/e2e/.env — at minimum STAFF_NAME, STAFF_PASSWORD, STORE_ID
|
|
```
|
|
|
|
## Run
|
|
|
|
```bash
|
|
bash tests/e2e/run.sh # every entry flow in tests/e2e/
|
|
bash tests/e2e/run.sh add-product.yaml
|
|
```
|
|
|
|
`run.sh` appends a timestamp to `PRODUCT_NAME` (the backend rejects duplicate names).
|
|
|
|
## What `add-product.yaml` does
|
|
|
|
1. `addMedia` seeds `assets/test-product.png` into the emulator gallery.
|
|
2. `launchApp` with `clearState: true` (forces login) and gallery permission.
|
|
3. Logs in (subflow) and taps the `add-product-menu-item` quick action.
|
|
4. Fills the product name and selects Store + Product Type.
|
|
5. Variant 1: quantity, price, MRP, attaches an image.
|
|
6. Adds Variant 2, fills quantity/prices, toggles **Flash Available**, sets flash price, attaches an image.
|
|
7. Submits and asserts `Product created successfully!`.
|
|
|
|
All in-app interactions use `testID` selectors (`id:`). The only exception is the
|
|
OS photo picker, which is system UI and is targeted by its platform IDs in
|
|
`subflows/pick-image.yaml`.
|
|
|
|
## Notes / gotchas
|
|
|
|
- The image picker flow is the most version-sensitive part; thumbs are targeted by
|
|
the Android 13/14 Photo Picker id with a DocumentsUI fallback, and the confirm
|
|
button by text regex `Add|Done|Select`.
|
|
- On a reused emulator, `addMedia` images accumulate in the gallery (harmless).
|
|
- Tests create real data on the connected backend.
|