248 lines
8.2 KiB
Markdown
248 lines
8.2 KiB
Markdown
# Basic-sanity E2E
|
|
|
|
Executable, test-ID-only version of the basic-sanity scenario. It replaces the
|
|
old percentage/coordinate runbook.
|
|
|
|
## What it covers
|
|
|
|
1. **Offers / combo**
|
|
- Opens the Offers tab.
|
|
- Expands Combos.
|
|
- Opens the generated combo product.
|
|
- Checks the combo items and flash price.
|
|
2. **Dashboard tag**
|
|
- Swipes the horizontal tag strip by ID.
|
|
- Opens the generated tag.
|
|
- Checks both A variants and the combo are present.
|
|
3. **Regular order**
|
|
- Searches for the A product.
|
|
- Opens the 500g SKU.
|
|
- Adds it with the generated slot.
|
|
- Checks the cart row.
|
|
- Places the order.
|
|
- Opens My Orders and checks the product.
|
|
4. **Flash order**
|
|
- Opens the 1 Hr Delivery tab.
|
|
- Finds the generated 500g SKU near the end of the flash catalogue.
|
|
- Adds it and places the flash order.
|
|
5. **Post-admin assertions**
|
|
- Both orders are packaged (Packed dot, no PLACED).
|
|
- Flash delivery is disabled.
|
|
- The suspended combo is no longer searchable.
|
|
- The 1kg SKU is still searchable but flagged out of stock.
|
|
|
|
## Files
|
|
|
|
| File | Purpose |
|
|
| --- | --- |
|
|
| `basic-sanity-setup.sh` | Creates product A (500g + 1kg), the combo, dashboard tag, delivery slot and images. Enables flash, rebuilds caches, writes `.basic-sanity.env` and `.basic-sanity-state.json`. |
|
|
| `basic-sanity.yaml` | Main Maestro flow: regular order + flash order + My Orders. |
|
|
| `basic-sanity-admin-update.sh` | Packages the two new orders, disables flash, suspends the combo, marks the 1kg SKU out of stock, rebuilds caches. |
|
|
| `basic-sanity-after-admin.yaml` | Post-admin Maestro assertions. |
|
|
| `run-basic-sanity.sh` | Runs setup → main flow → admin update → post-admin flow. |
|
|
| `.basic-sanity.env` | Generated environment values. Do not edit by hand. |
|
|
| `.basic-sanity-state.json` | Generated fixture IDs and image URLs. Used by the admin update script. |
|
|
|
|
## Prerequisites
|
|
|
|
- iOS Simulator or connected iOS device with Maestro installed
|
|
(`~/.maestro/bin/maestro` by default).
|
|
- Expo Go installed and **logged in as the test user**.
|
|
- The test user has a saved address with ID `899` (or pass a different
|
|
`ADDRESS_ID`).
|
|
- Metro is serving the user app at `exp://127.0.0.1:8081`.
|
|
- The local backend is running at `http://localhost:8787` (used for the
|
|
synchronous cache rebuild).
|
|
- A valid admin token in `/tmp/dev_admin_token`, or exported as `ADMIN_TOKEN`.
|
|
- The app ID used by the flows is `host.exp.Exponent` (Expo Go).
|
|
|
|
## One-command run
|
|
|
|
```bash
|
|
cd /Users/mohammedshafiuddin/WebDev/freshyo
|
|
./tests/e2e/run-basic-sanity.sh
|
|
```
|
|
|
|
Optional overrides:
|
|
|
|
```bash
|
|
DEVICE=<maestro-device-id> \
|
|
ADDRESS_ID=899 \
|
|
ADMIN_TOKEN=<token> \
|
|
./tests/e2e/run-basic-sanity.sh
|
|
```
|
|
|
|
If only one simulator/device is connected, Maestro selects it automatically.
|
|
If several are connected, pass `DEVICE`.
|
|
|
|
## Manual step-by-step run
|
|
|
|
Use this when debugging a phase instead of running the whole scenario.
|
|
|
|
### 1. Create fixtures
|
|
|
|
```bash
|
|
cd /Users/mohammedshafiuddin/WebDev/freshyo
|
|
./tests/e2e/basic-sanity-setup.sh
|
|
source tests/e2e/.basic-sanity.env
|
|
```
|
|
|
|
The setup script prints the generated IDs and writes them to
|
|
`tests/e2e/.basic-sanity-state.json`.
|
|
|
|
### 2. Run the user flow
|
|
|
|
```bash
|
|
~/.maestro/bin/maestro test \
|
|
--device <device-id> \
|
|
-e PRODUCT_NAME="$PRODUCT_NAME" \
|
|
-e COMBO_NAME="$COMBO_NAME" \
|
|
-e SKU_500G="$SKU_500G" \
|
|
-e SKU_1KG="$SKU_1KG" \
|
|
-e SKU_COMBO="$SKU_COMBO" \
|
|
-e TAG_ID="$TAG_ID" \
|
|
-e SLOT_ID="$SLOT_ID" \
|
|
-e ADDRESS_ID="${ADDRESS_ID:-899}" \
|
|
tests/e2e/basic-sanity.yaml
|
|
```
|
|
|
|
### 3. Apply admin changes
|
|
|
|
```bash
|
|
./tests/e2e/basic-sanity-admin-update.sh
|
|
```
|
|
|
|
This expects **exactly two** orders for the current fixture SKUs. If the main
|
|
flow did not reach both checkouts, fix the failure and re-run from setup with a
|
|
fresh `RUN_ID` instead of continuing with a partial run.
|
|
|
|
### 4. Run post-admin assertions
|
|
|
|
```bash
|
|
~/.maestro/bin/maestro test \
|
|
--device <device-id> \
|
|
-e PRODUCT_NAME="$PRODUCT_NAME" \
|
|
-e COMBO_NAME="$COMBO_NAME" \
|
|
-e SKU_1KG="$SKU_1KG" \
|
|
-e SKU_COMBO="$SKU_COMBO" \
|
|
-e ADDRESS_ID="${ADDRESS_ID:-899}" \
|
|
tests/e2e/basic-sanity-after-admin.yaml
|
|
```
|
|
|
|
## Environment variables
|
|
|
|
### Setup script
|
|
|
|
| Variable | Default | Meaning |
|
|
| --- | --- | --- |
|
|
| `API` | `https://devbackend.freshyo.in/api/trpc` | Admin tRPC endpoint. |
|
|
| `LOCAL_API` | `http://localhost:8787` | Local backend used for `/api/test/rebuild`. |
|
|
| `RUN_ID` | UTC timestamp | Suffix for fixture names. Use a new value for every run. |
|
|
| `IMAGE` | `apps/user-ui/assets/images/icon.png` | Image uploaded for the generated products. |
|
|
| `ADMIN_TOKEN` | contents of `/tmp/dev_admin_token` | Admin bearer token. |
|
|
|
|
### Main flow
|
|
|
|
| Variable | Meaning |
|
|
| --- | --- |
|
|
| `PRODUCT_NAME` | Generated A product name (`SANITY-<RUN_ID>-A`). |
|
|
| `COMBO_NAME` | Generated combo name (`SANITY-<RUN_ID>-COMBO`). |
|
|
| `SKU_500G` | 500g SKU id. |
|
|
| `SKU_1KG` | 1kg SKU id. |
|
|
| `SKU_COMBO` | Combo SKU id. |
|
|
| `TAG_ID` | Generated dashboard tag id. |
|
|
| `SLOT_ID` | Generated delivery slot id. |
|
|
| `ADDRESS_ID` | Saved address to select at launch. Defaults to `899`. |
|
|
|
|
### Post-admin flow
|
|
|
|
`PRODUCT_NAME`, `COMBO_NAME`, `SKU_1KG`, `SKU_COMBO`, `ADDRESS_ID`.
|
|
|
|
## Important behaviour
|
|
|
|
- **No screen percentages.** Taps use `testID`s. Swipes use the tag strip's
|
|
`home-tag-strip` ID.
|
|
- **The location sheet is handled at launch.** The flow taps the saved address
|
|
name ID. There is no close button on the launch gate.
|
|
- **The cart/checkout buttons sit behind the floating cart bar.** The flows
|
|
scroll once more before tapping `combos-show-more`, `checkout-button`, and the
|
|
last combo/flash cards.
|
|
- **The flash catalogue is a nested stack with no bottom tab bar.** After the
|
|
flash order, the main flow relaunches Expo Go before opening My Orders.
|
|
- **The setup clears stale SANITY cart rows** so a failed previous run cannot
|
|
leak items into the next checkout.
|
|
- **Each setup creates a new fixture set** with a unique `RUN_ID`. Old SANITY
|
|
fixtures are not deleted automatically; they can remain visible in the
|
|
catalogue and tag strip. Use the cleanup section below if you need a pristine
|
|
dev DB.
|
|
|
|
## Troubleshooting
|
|
|
|
### `ADMIN_TOKEN is required`
|
|
|
|
Put a fresh admin token in `/tmp/dev_admin_token` or export `ADMIN_TOKEN`:
|
|
|
|
```bash
|
|
export ADMIN_TOKEN="<token>"
|
|
./tests/e2e/run-basic-sanity.sh
|
|
```
|
|
|
|
### `cache rebuild failed`
|
|
|
|
Make sure the local backend is running:
|
|
|
|
```bash
|
|
curl -X POST 'http://localhost:8787/api/test/rebuild?regionId=1' \
|
|
-H "authorization: Bearer $ADMIN_TOKEN"
|
|
```
|
|
|
|
### The flow stops at the location sheet
|
|
|
|
The test user must have the address ID passed as `ADDRESS_ID`. Check the saved
|
|
addresses in the app and use the matching id.
|
|
|
|
### The Offers/Combos Show More tap does nothing
|
|
|
|
The button is the last child and starts behind the floating cart bar. The flow
|
|
scrolls it up first. If you edit the flow, keep the extra `scroll` before the
|
|
tap.
|
|
|
|
### `place-order-button` is not found
|
|
|
|
The checkout screen opens but the button is below the fold. The flow uses
|
|
`scrollUntilVisible`; do not replace it with `assertVisible`.
|
|
|
|
### The flash product is not found
|
|
|
|
The generated SKU is appended near the end of the flash catalogue. Keep the
|
|
`timeout: 120000`, `speed: 90`, `visibilityPercentage: 50`, and
|
|
`centerElement: true` settings.
|
|
|
|
### Admin update says `Expected 2 new orders ... found N`
|
|
|
|
The main flow must place both the regular and flash orders first. If it failed
|
|
mid-way, run the whole runner again; setup creates fresh fixture SKUs, so the
|
|
partial run's orders will not match the new fixtures.
|
|
|
|
## Cleanup
|
|
|
|
After a successful run, the test fixture and order rows can be removed manually
|
|
if you want a pristine dev DB. The setup script creates them again on the next
|
|
run. The important cleanup targets are:
|
|
|
|
- orders for the generated SKUs, plus `order_items`, `order_status`, and
|
|
`coupon_usage` rows;
|
|
- `cart_items` for the generated SKUs;
|
|
- `product_combos`, `product_tags`, `product_market_stats`, `sku_features`,
|
|
`product_skus`, and `product_info` for the generated fixtures;
|
|
- the generated `product_tag_info` row and `delivery_slot_info` row;
|
|
- `upload_url_status` rows for the uploaded product images.
|
|
|
|
Rebuild the caches after cleanup:
|
|
|
|
```bash
|
|
curl -X POST 'http://localhost:8787/api/test/rebuild?regionId=1' \
|
|
-H "authorization: Bearer $ADMIN_TOKEN"
|
|
```
|
|
|
|
Do not run Drizzle migrations as part of this scenario.
|