# Test Plan — Region consts model + active bound + login walls Verification plan for the consts three-table model, the active-bound model, and the user-app flows built in this session. Uses **Maestro MCP**. ## Environments | Env | Where | Id / URL | |---|---|---| | Backend | `wrangler dev` (local) | http://localhost:8787 (tunnel `devbackend.freshyo.in`) | | Superadmin UI | Chromium (Maestro web) | http://localhost:4175 | | User app (customer) | iOS simulator — `iphone 16 pr max - iOS 18.6` (`B1F98A94-9733-46A6-9EB2-76F33C15240D`) | appId `com.freshyotrial.app` | ## Fixtures | Thing | Value | |---|---| | Region 1 | Mahabubnagar, bounds `Mbnr-1` (priority 1), `Mbnr-2` (priority 2) | | Region 2 / 3 | Test regions as configured in dev (e.g. `Testnagar`, `Test-1`) | | Staff (admin-ui, out of scope) | `uitest` / `uitest2`, password `test1234` | | Superadmin | username `superadmin`, password **BLOCKER — unknown** | ## Blockers / prerequisites | Id | Item | Status | |---|---|---| | P-1 | Superadmin password needed for every superadmin-UI case | blocker (must ask) | | P-2 | Customer login = SMS OTP to a real phone — needs the physical device to read the OTP, or an already-logged-in test user on the simulator | blocker / workaround | | P-3 | Metro dev server (`npx expo start`) must be running for the dev app; port 8081 was down | prereq | | P-4 | User app must be installed on the simulator | to verify | | P-5 | Migration `0007_addresses_bound_id` applied to the dev DB | user runs it | --- ## A. Superadmin UI (Chromium @ :4175) ### SU-1 Login with superadmin credentials - Steps: open `/login` → username `superadmin` + password → submit. - Expected: lands on the dashboard; no UNAUTHORIZED errors anywhere. ### SU-2 Regions page — region constants editor - Steps: Regions → pick a region. - Expected: **Region settings** editor shows the region keys (`Popular Items`, `All Items Order`, `Tags Order`, `Enable Flash Delivery`, `Support Mobile`, `Support Email`, `Welcome Message`) with the 3 version counters **hidden**. ### SU-3 Regions page — bound constants editor + effective badge - Steps: select each bound tab. - Expected: **Bound settings** editor shows ONLY the 5 bound keys (`minRegularOrderValue`, `freeDeliveryThreshold`, `deliveryCharge`, `flashFreeDeliveryThreshold`, `flashDeliveryCharge`); the lowest-priority bound shows the **EFFECTIVE** badge. ### SU-4 Update bound settings → KV refreshed - Steps: change `deliveryCharge` on a bound → Save. - Expected: success; KV key `essentialConsts_{boundId}` reflects the new value (`npx wrangler kv:key get "essentialConsts_1" --namespace-id `). ### SU-5 Constants page — Global + Legacy (superadmin token) - Steps: Constants → check Global section shows the 4 global keys and Legacy shows the 7 leftover keys → change one global and one legacy value → Save each. - Expected: saves succeed with a superadmin token (this was previously UNAUTHORIZED via `admin.const.*`); entries persist after reload. ### SU-6 Update region constants (superadmin) → KV refreshed - Steps: Regions → region editor → toggle `isFlashDeliveryEnabled` → Save region settings. - Expected: success; `essentialConsts_{boundId}` for that region reflects it. --- ## B. User app (iOS simulator) ### U-1 Startup resolve — location granted - Setup: app state cleared, location permission allowed, device fix inside bound **Mbnr-1**. - Expected: spinner **"Finding your region..."** → app renders; location bar shows `Mahabubnagar`; a (now commented-out) ` essentialConsts boundId` log would have printed the containing bound. ### U-2 Startup resolve — location denied - Setup: app state cleared, location permission **denied**. - Expected: full-screen **region chooser** (`RegionSelector` gate) — pick `Mahabubnagar` → app renders. ### U-3 Active bound = least-priority bound of the user's addresses - Setup: signed in, user has an address in region 1 with `bound_id` = the least-priority bound. - Expected: consts (delivery charge / threshold) come from that address's bound — **not** the device-location bound. ### U-3b No address in the region → effective bound - Setup: signed in, user has **no** address in region 1. - Expected: active bound = region's effective (least-priority) bound. ### U-4 Region switch clears the cart - Steps: add items to cart → location bar → choose another region → confirm. - Expected: confirmation dialog; on confirm the cart is emptied (both types) and the app shows the new region. ### U-5 Same-region bound change does NOT clear the cart - Setup: cart with items; user in region 1. - Expected: changing only the bound (where supported) keeps the cart. ### U-6 Cart login wall - Setup: sign out. - Steps: open the cart (regular and 1-hr variants). - Expected: inline **"Please log in"** wall, no cart content; **Back** navigates out; **Log In** → login screen. ### U-7 Post-login returns to the gated page - Steps: from the cart wall → Log In → sign in. - Expected: lands back on the **cart** page (not home). Same for the **Me** tab wall → lands on Me. ### U-8 Cart items behaviour - Expected: quantity stepper works; 0 shows a remove confirmation; per item, out-of-stock / no-slot / not-flash-eligible warnings render; delete button removes the item. ### U-9 Delivery slot picking (regular, cart) - Expected: slot dropdown lists slots; the **Delivery Slot Summary** sits right after items, groups by slot with counts, and offers a merge suggestion when feasible. ### U-10 Coupons (cart) - Expected: dropdown lists eligible coupons with savings labels; ineligible disabled; applied coupon shows under Bill Details and can be removed. ### U-11 Delivery instructions input (cart) - Expected: **Delivery Instructions** input exists **above** the address selector, above Bill Details; the typed text is carried into the order (`userNotes`). ### U-12 Address selector position (cart) - Expected: the selector renders **just above the Bill Details** section. ### U-13 Addresses: data model + first address default - Steps: from the cart selector → add an address for a user with none → save. - Expected: it becomes the user's **default** address automatically. ### U-14 "No Location is attached to address" + attach - Steps: select an address with no coordinates. - Expected: small text **"No Location is attached to address"** above **+ Attach Current Location**; granting permission sets `latitude`/`longitude`. ### U-15 Checkout = read-only summary - Setup: cart with items (regular), at least 2 different slots, a coupon, an address. - Expected: checkout shows — **Items** grouped by slot with the **slot time pill** above each group, **Coupon** card, **Address** card, **Bill** — and NO editable controls (no steppers, no slot dropdowns, no coupon dropdown). ### U-16 Delivery charge vs. displayed bound - Expected: the delivery charge / free-delivery threshold shown is the **active bound's** value, and the order is charged the same (client sends `boundId = constsData.boundId`). ### U-17 Back to Cart - Steps: on checkout tap **Back to Cart**. - Expected: returns to the cart; nothing lost. ### U-18 Place order (COD) - Steps: checkout → Place Order. - Expected: order placed; redirected to order-success; cart cleared. ### U-19 Flash delivery flow - Steps: flash section → add a flash-eligible item → flash cart → flash checkout → place. - Expected: no slot summary in the cart; checkout groups items without slot headers; min-order uses the flash constants (`flashFreeDeliveryThreshold` / `flashDeliveryCharge`). ### U-20 Cross-region checkout address - Setup: user has an address in a **different** region than the browsing region. - Steps: select it on the cart. - Expected: confirmation dialog ("Switch region? ... clears your entire cart") → on confirm the region switches, carts cleared, and the app lands on home. ### U-21 isFlashDeliveryEnabled gate (region consts) - Setup: `isFlashDeliveryEnabled = false` for the active bound's region. - Expected: flash delivery unavailable (403 from the backend; the app marks flash delivery off). --- ## C. Admin apps (admin-ui / admin-web) Out of scope for this run (the admin mobile app is not installed; `apps/admin-ui` dev server is stopped). Flagging for a later pass: - customize-app: Region + Bound tabs only (no Global), region/bound saves reach the right tables, region-scoped popular/all-items ordering, region-scoped `tagsOrder`, region-scoped `welcomeMessage`. --- ## Reporting Each case gets: PASS / FAIL / BLOCKED / SKIPPED, with evidence (screenshot, Maestro Viewer link, KV output, or backend log line). ## Results (2026-10-09) | Case | Result | Evidence | |---|---|---| | SU-1 | ✅ PASS | Logged in as superadmin; Dashboard (Regions / Admin Users / App Constants) rendered | | SU-2 | ✅ PASS | Region settings editor shows Popular Items / Tags Order / Enable Flash Delivery; "Availability Cache Version" NOT visible (counters hidden) | | SU-3 | ✅ PASS | Bound settings editor shows only the 5 bound keys (Minimum Regular Order Value, Delivery Charge…); **EFFECTIVE** badge on the lowest-priority bound | | SU-4 | 🔜 Partial | Verified server-side: `activeBound` returns boundId for region 1; KV UI-edit round-trip not driven from the browser (Maestro web can't target the inputs) | | SU-5/SU-6 | 🔜 Same as above | Server-side `activeBound` sanity verified; UI drive pending | | U-1 | ✅ PASS | Fresh install + GPS set to 16.7489,77.9856 (inside Mbnr-1) → Home shows "DELIVER TO Mahabubnagar", no gate needed; region auto-resolved | | U-6 (Me tab wall) | ✅ PASS | Me tab renders the **Please log in** wall (lock, title, message, Log In) while tabs stay navigable | | U-7 (login navigation) | ✅ PASS (up to credentials) | Wall → Log In → login screen (mobile step) → "other ways to login" → password step with the username prefilled; all navigation works | | U-6/U-7 sign-in completion | 🚫 BLOCKED (test harness) | Maestro `inputText` does not land in the **secure** password field on the iOS Simulator (characters dispatched but RN state never updates; the non-secure mobile field typed fine). Simulator hardware-keyboard/secure-field quirk — manual typing on the simulator works; password login via device was NOT automated | | — | 🔍 **B01** | (pre-B02) Home showed "No products available" + "Shop for ₹+" (threshold undefined) | | — | ✅ **B02 root-cause + fix** | `common.activeBound` was protected + auth-gated, and the location-resolved bound was not propagated → signed-out users had `boundId = null` → consts disabled. Fixed: `activeBound` is now public (signed-out → effective bound) and `useRegion` propagates the location bound again. Verified: products + "₹300 more for FREE Delivery" on Home | | U-10/U-11/U-13/U-15/U-18/U-19/U-20 | ⏳ Not run yet | Needs the sign-in round-trip (blocked above) and further flow driving | ### Notable environment findings - `inspect_screen` / screenshot capture give blank or depth-overflow payloads once the screen has real content on BOTH devices, so verification relied on `run` + `assertVisible` flows, simulator screenshots, and point-tap driving. - Chromium web flows must start with `openLink` (the `url:` header alone doesn't navigate). - `scrollUntilVisible` is required on the admin Regions page: the region cards live below the fold. - On the user app, text-node assertions (`assertVisible "Home"` etc.) failed even on clearly-rendered screens; driving worked via `tapOn: { point: "x%, y%" }` coordinates taken from the screenshots. - `launchApp` permission auto-grants are not supported for `location` on this Maestro build.