# Freshyo full-product validation test plan Status: proposed — **not executed**. Branch: `MULTI_REGION_I2` (48 commits ahead of `main`). Scope: backend tRPC/API, customer native + web, admin native + web, superadmin web, cache/jobs, and the cross-app order journey. This is the automation-focused master plan: **311 cases** across seven layers. The exhaustive per-feature edge-case catalog lives in [`docs/test-cases/`](test-cases/README.md); this file lists the cases that must be automated and run for release. A test case is a user journey, an API contract, or a cross-app invariant — **not** a component render or prop unit test. For human reproduction of the app-visible cases, use the companion [`full-product-validation-manual-testing-guide.md`](full-product-validation-manual-testing-guide.md) or its [self-contained HTML version](full-product-validation-manual-testing-guide.html). The manual guide is written for non-technical testers and intentionally excludes the backend/API, security, database and cache procedures. --- ## 1. Goals and boundaries ### Must validate 1. Every authorization boundary: anonymous, customer, staff A, staff B, superadmin. 2. Every money path: cart preview → checkout → persisted order → customer detail → admin detail. 3. Region/bound isolation: catalog, prices, stock, slots, orders, staff, caches. 4. Global entities (stores/products/coupons) in every region, with independent market data. 5. Cache publication: regional vs global regeneration, debounce, versions, bound discovery. 6. COD-only checkout and the absence of online-payment routes/UI. 7. The operational chain: superadmin setup → admin catalog/slots → customer order → admin fulfillment → customer status. 8. Recovery: expired sessions, stale caches, offline, retries, double submits, failed mutations. ### Explicitly out of scope - Component-level unit tests, prop tests, renderer snapshots, and pure-helper tests (the shared pricing helpers are validated through API/UI money cases). - Styling, animation, icon, and layout snapshots. - Third-party internals (Expo, Cloudflare, D1, KV, R2, Maestro/Playwright drivers). - Live SMS/OTP, real push broadcasts, real object-storage deletes outside staging, and online payment gateways. - Drizzle migrations. **Never run migrations as test setup.** The user applies them. - Production mutation tests. All mutation/notification cases use staging only. - `apps/info-site` is a static marketing site: manual link/uptime smoke only, not part of this suite. ### Definition of a valid case A case passes only when the observable result is confirmed from the authoritative surface, not from a toast: - Money: `goods − stored discount + delivery = payable`, per sub-order and in total. - Cache: DB value, served version and elapsed time all agree within the deadline. - Mutations: the intended rows exist **and** no unintended rows/assets changed. - Rejections: correct 4xx contract **and** no partial writes. - UI: the expected screen was actually open; a success toast alone is not evidence. --- ## 2. Automation layers | Layer | Tool | What is real | Network | Location | |---|---|---|---|---| | L1 Backend API | Jest + `ts-jest` + tRPC HTTP client | Backend worker, D1/KV/R2/DO | Real local HTTP | `apps/backend/tests/api/` | | L2 Customer UI | Jest + `jest-expo` + React Native Testing Library | Screen, router, providers, stores, storage | Mocked tRPC/axios boundary | `apps/user-ui/tests/flows/` | | L3 Admin UI | Jest + `jest-expo` + RNTL | Screen, router, providers, stores | Mocked tRPC/axios boundary | `apps/admin-ui/tests/flows/` | | L4 Customer web | Jest + jsdom + React Testing Library | Route, router, providers, localStorage | Mocked tRPC link | `apps/web-ui/tests/flows/` | | L5 Admin web | Jest + jsdom + React Testing Library | Route, router, providers, localStorage | Mocked tRPC link | `apps/admin-web/tests/flows/` | | L6 Superadmin | Vitest + jsdom + React Testing Library (already configured; the same cases run under Jest if the repo standardizes) | Route, router, providers | Mocked tRPC link | `apps/superadmin-ui/src/**/*.test.tsx` | | L7 Cross-app E2E | Maestro (native) + Playwright (web) | Real backend, DB, cache, storage | Real | `tests/e2e/`, `tests/e2e-web/` | Rules for L2–L6: - Mount the **route/screen**, not an isolated component. - Exercise real navigation, state stores, query invalidation and persisted storage. - Mock only the network boundary; keep the app's validation, guards and rendering real. - Prefer `testID` / accessible roles over text that changes with copy. - One test = one user-visible outcome, not one assertion per element. - No shallow rendering, no component prop matrices, no snapshots. Rules for L1: - Talk to a running backend over HTTP, exactly like the apps. - Create fixtures through the API; add a sanctioned fixture/reset path only if API setup becomes too slow. - Tests share data; run serially and use unique name/mobile prefixes. - Never point a mutation test at production. Rules for L7: - Only the critical journeys below. Do not re-implement the full API suite in E2E. - Native: Maestro flows with stable IDs; Web: Playwright Chromium. - A coordinator carries region/product/SKU/slot/order IDs between apps. - Assert persisted state through the UI plus one authoritative API read. --- ## 3. Environment and fixtures ### Environment - Isolated staging backend with its own D1/KV/R2/queue/DO namespace and object store. - Local commands (for the future test harness; **do not run while authoring**): - backend: `cd apps/backend && bun run dev` (wrangler dev on `:8787`) - backend suite: `cd apps/backend && bun run test:api` - native suites: `cd apps/user-ui && bun run test`, `cd apps/admin-ui && bun run test` - web suites: add `bun test` scripts to `apps/web-ui`, `apps/admin-web`, `apps/superadmin-ui` - E2E: `tests/e2e/run.sh` (Maestro) and `npx playwright test` (web) - Web/native unit suites must point at the same staging API version as the backend suite. ### Shared fixtures | Fixture | Required setup | |---|---| | Regions | A and B. A has bounds A1/A2 (priority 1/2, different fees); B has B1. Include interior, edge, overlap and outside points. | | Identities | anonymous, U1 (addresses in A1/A2), U2 (B1), U0 (new, zero addresses), suspended user, staff A, staff B, superadmin. | | Catalog | A-only product P with two SKUs; B-only Q; global G with independent A/B market rows; regular-only R; flash F; combo C with combo-only component K; deleted/OOS/suspended variants. | | Stores | regional store A, regional store B, global store GS. | | Slots | future S1/S2 in A, B slot; inactive, frozen, full, past and midnight-boundary slots. | | Money | per-bound free-delivery threshold T and fee D; flash threshold/fee; T−0.01/T/T+0.01. | | Coupons | regional A/B, global, percent, flat, targeted, whole-cart, capped, min-spend, exclusive, first-order, limited-use, personal, expired, invalidated, reserved. | | Orders | pending COD, packaged, verified, delivered, cancelled, multi-slot group, flash, historical product-deleted. | | Content | tags, groups, banners, upload assets, complaints, notifications, vendor snippets (conditional). | | Notifications | sandbox queue and approved test recipients only. | ### Data rules - Unique run prefix for every created name/mobile/email/code. - Never delete a region; neutralize throwaway regions by renaming/shrinking instead. - Bounds are deletable only when the region has another bound and no addresses reference them. - Product deletion is soft; order history must keep the original name and amount. - Clean up only approved disposable rows/assets; keep failing fixtures for diagnosis. - Record region/bound IDs, product/SKU IDs, slot IDs and order IDs in the run report. --- ## 4. Priorities and release gates | Priority | Meaning | Gate | |---|---|---| | P0 | Authorization, money integrity, core purchasing, region isolation, data loss | Every P0 must pass before any release. | | P1 | Normal feature behaviour, important edge cases, parity | Every P1 must pass or be explicitly waived. | | P2 | Resilience, presentation, conditional/legacy coverage | Run before major releases; document N/A reasons. | Release gate: 1. `typecheck` clean for touched apps/packages. 2. All P0 backend + frontend cases pass on the release candidate. 3. All P1 cases pass or have a signed waiver. 4. E2E critical journeys pass against staging. 5. No P0/P1 open defect without a documented workaround. --- ## 5. Current-branch delta → required coverage The branch changes are concentrated in multi-region support, global entities, bound-based discovery/pricing, cache publication and the COD-only conversion. Each change below has dedicated cases in §7. | # | Change / fixed defect | Regression cases | |---|---|---| | 1 | Admin customer search must be region-scoped (`or()` grouping) | `BR-01`, `BE-ADMIN-15` | | 2 | Web discovery must request `essentialConsts({ boundId })` | `BR-02`, `CUST-01` | | 3 | Global-product edit must preserve SKU IDs | `BR-03`, `BE-SA-09` | | 4 | Regional edit of a global store must not delete its image | `BR-04`, `BE-ADMIN-08` | | 5 | Global cache request must not be narrowed by a regional request | `BR-05`, `BE-CACHE-04` | | 6 | Web scheduled checkout must send each line's slot ID | `BR-06`, `CUST-41` | | 7 | New-region cache generation must be awaited | `BR-07`, `BE-SA-05` | | 8 | Global-product edit form must reset between create/edit | `BR-08`, `SA-12` | | 9 | Regional order list must paginate its own rows, not a global ID window | `BR-09`, `BE-ORDER-23`, `ADM-06` | | 10 | Startup region adoption must not wipe a persisted cart | `BR-10` (known open) | | 11 | Unrelated market edits must preserve regional suspension | `BR-11`, `BE-ADMIN-05` | | 12 | Coupon allocation must never make a sub-order negative | `BR-12`, `CUST-33`, `BE-COUP-15` | | 13 | Historical `discount_amount` backfill | `BR-13` (accepted limitation) | | 14 | Switching a global coupon from percent to flat must clear percent | `BR-14` (known open) | | 15 | Admin-web reload must restore staff identity/region | `BR-15`, `ADM-01`, `ADM-32` | | 16 | Superadmin "Admin Notifs" must use a superadmin-guarded endpoint | `BR-16`, `SA-18` | | 17 | COD-only conversion (no online-payment routes/UI) | `BR-17`, `BE-ORDER-01`, `CUST-42` | | 18 | Per-slot web checkout validation (`slotId` non-null for scheduled) | `BR-18`, `BE-ORDER-08` | | 19 | Bound-based pricing from the address, not the client region | `BR-19`, `BE-ORDER-11`, `CUST-39` | | 20 | Search/order pagination keyset stability | `BR-20`, `BE-ORDER-23` | --- ## 6. Master case inventory ### 6.1 Backend API (L1) #### Common discovery, regions and bounds | ID | P | Case | Expected | |---|---|---|---| | BE-COM-01 | P0 | `GET /api/health` and `common.healthCheck`. | 200/ok; no secrets. | | BE-COM-02 | P0 | `common.listRegions` as anonymous. | Regions with public discovery metadata only; no staff/account data. | | BE-COM-03 | P0 | `resolveRegionByLocation` for A1, A2, B1, overlap, polygon edge. | Correct region/bound; priority wins on overlap; edge follows documented rule. | | BE-COM-04 | P0 | `resolveRegionByLocation` outside every polygon and invalid coordinates. | Outside → `null`; invalid → 400. | | BE-COM-05 | P0 | `resolveBound` for a valid A point, an outside-A point, and a B point with `regionId=A`. | A point → A bound; outside/foreign → 422; no cross-region fallback. | | BE-COM-06 | P1 | `activeBound` signed-out, U1 with A1/A2, U1 with B-only addresses, U0 with none. | Signed-out → effective bound; U1 → lowest-priority A bound; B addresses ignored; U0 → effective bound. | | BE-COM-07 | P1 | `regionSettings` for A; region with no bounds; unknown region. | Effective bound settings; 422 for no bounds; 422/404 for unknown. | | BE-COM-08 | P0 | `essentialConsts` with `boundId`, missing `boundId`, unknown `boundId`. | Merged global/region/bound payload for the bound; validation error when missing; 404 unknown. | | BE-COM-09 | P2 | `essentialConsts` on a `raw`/`mf` host. | Stale-client notice fields present and non-closable; normal hosts omit it. | | BE-COM-10 | P1 | `checkLocationInPolygon` inside/outside/invalid. | Boolean for valid points; validation error for invalid. | | BE-COM-11 | P0 | `getStoresSummary` as staff A, staff B, customer. | Staff A only A stores; staff B only B; customer denied. | #### Customer authentication and profile | ID | P | Case | Expected | |---|---|---|---| | BE-AUTH-01 | P0 | Register a new customer, then log in by mobile and by email. | One user row; both identifiers authenticate; token works. | | BE-AUTH-02 | P0 | Duplicate mobile, duplicate email, malformed mobile/email, weak password. | Rejected; no partial user/credential rows. | | BE-AUTH-03 | P1 | Login with wrong password/unknown identifier and retry correctly. | Rejected then succeeds; no session from the failure. | | BE-AUTH-04 | P0 | Expired, tampered and malformed JWT on a protected query. | 401; no fallback identity/region. | | BE-AUTH-05 | P1 | `getSelfData`, `updateProfile`, avatar change, relaunch/read-back. | Values persist; no other user's data. | | BE-AUTH-06 | P1 | `updatePassword` with wrong old password, then correct; login old/new. | Wrong rejected; new works; old fails. | | BE-AUTH-07 | P1 | `deleteAccount` with wrong confirmation, then correct. | Wrong rejected; correct deletes/revokes access. | | BE-AUTH-08 | P0 | Suspended customer places an order with an existing token; unsuspend; retry. | Blocked while suspended; allowed after unsuspend. | | BE-AUTH-09 | P0 | User token calls admin/superadmin mutations; staff token calls user/superadmin. | Denied at the procedure; no writes. | | BE-AUTH-10 | P0 | Two customers U1/U2 probe each other's profile/address/order/coupon IDs. | Ownership enforced on every surface. | | BE-AUTH-11 | P0 | Customer with zero addresses attempts to place an order. | Rejected with a meaningful address error; no order. | #### Addresses and region/bound attachment | ID | P | Case | Expected | |---|---|---|---| | BE-ADDR-01 | P0 | Create an address with coordinates inside A1 and inside A2. | Correct region + derived bound; coordinates stored. | | BE-ADDR-02 | P0 | Create with coordinates outside every A bound. | 422; no address row. | | BE-ADDR-03 | P1 | Create without coordinates (legacy web) and with a Google Maps URL. | Fallback to region effective bound; URL coords parsed when present. | | BE-ADDR-04 | P1 | Invalid phone (9 digits, starts 5), missing name/line/city/state. | Validation errors; no row. | | BE-ADDR-05 | P1 | First address, then second address with `isDefault=false`, then set it default. | First is default; setting default unsets the previous one. | | BE-ADDR-06 | P0 | Update another user's address ID. | Not found/forbidden; no change. | | BE-ADDR-07 | P1 | Update coordinates from A1 to A2; update region to B with B coordinates. | Bound re-derived; region/bound/address consistent. | | BE-ADDR-08 | P1 | Delete an address used by an ongoing order vs a free address. | Ongoing-order address refused; free address deleted. | | BE-ADDR-09 | P1 | Delete the default address while another exists; delete the last address. | Default policy remains coherent; address gate appears for zero addresses. | | BE-ADDR-10 | P1 | Create/update address and inspect `user_regions` and notification credentials. | Association inserted/reconciled; token region follows the address region. | | BE-ADDR-11 | P0 | Cart/checkout and order use an address whose coordinates are in B while browsing A. | Order is scoped/priced by the address's B region/bound; browsing region unchanged. | | BE-ADDR-12 | P1 | `getDefaultAddress` / `getUserAddresses` for U1 and U2. | Only the caller's addresses; default flag correct. | #### Catalog, stores, search, combos and slots | ID | P | Case | Expected | |---|---|---|---| | BE-CAT-01 | P0 | Read A catalog containing A-only P, B-only Q and global G. | P and G only; Q absent; G uses A market data. | | BE-CAT-02 | P0 | Read B catalog for the same fixture. | Q and G only; P absent; G uses B market data. | | BE-CAT-03 | P1 | Product detail for P, Q, G in A and B. | Correct region/market price, flags and variants; foreign product not purchasable. | | BE-CAT-04 | P1 | Search by name/tag/store in A. | Only A + global matches; no B results; case/whitespace behaviour documented. | | BE-CAT-05 | P1 | Product list with deleted, OOS, globally suspended and regionally suspended SKUs. | Deleted hidden; OOS/suspended flags correct; no orderable invalid SKU. | | BE-CAT-06 | P1 | Stores list/detail in A and B, including global store GS. | Regional isolation; GS visible in both; product counts/assets coherent. | | BE-CAT-07 | P1 | Banners and tags in A/B. | Region-correct order/visibility; no foreign content. | | BE-CAT-08 | P0 | `getSlots` without `regionId`, for A, for B. | Missing → validation error; A/B return only future active slots for that region. | | BE-CAT-09 | P1 | Slots that are full, frozen, past, inactive. | Excluded from customer lists; capacity/status correct. | | BE-CAT-10 | P1 | Slot membership: SKU not assigned to a slot. | Not orderable into that slot; checkout rejects. | | BE-CAT-11 | P1 | Combo C with component K; K unavailable/out of stock. | Combo composition/pricing correct; unavailable component prevents purchase. | | BE-CAT-12 | P0 | Flash product F in A (enabled) and B (disabled). | Flash list/price only where enabled; disabled region cannot order. | | BE-CAT-13 | P1 | Global product with different A/B market prices and suspension. | Each region sees its own price/stock/suspension only. | | BE-CAT-14 | P1 | Product tags/group ordering and popular-items ordering. | Order matches admin configuration; region-scoped. | | BE-CAT-15 | P2 | Empty region with no stores/products/slots. | Intentional empty payloads; no crash or cross-region fallback. | | BE-CAT-16 | P0 | Catalog response inspection. | No customer/staff private data, addresses, tokens or internal notes. | #### Coupons and pricing | ID | P | Case | Expected | |---|---|---|---| | BE-COUP-01 | P0 | Eligible coupon list for U1 in A with regional/global/personal/expired/invalidated/used-up coupons. | Only visible eligible-or-disabled candidates; expired/invalidated/used-up/other-user hidden. | | BE-COUP-02 | P0 | Apply a regional A coupon while ordering in B. | Rejected; no usage recorded. | | BE-COUP-03 | P0 | First-order-only coupon for U0 and for U1 with an order. | U0 accepted; U1 rejected with the documented message. | | BE-COUP-04 | P0 | `minOrder` below, equal and above the eligible subtotal. | Below rejected; equal accepted; reason uses the eligible subtotal. | | BE-COUP-05 | P0 | Targeted coupon whose SKUs are present, partially present and absent. | Discount only on targets; absent → no-applicable-items error. | | BE-COUP-06 | P0 | Coupon at the per-user usage limit and one below it. | Limit enforced; one-time usage recorded. | | BE-COUP-07 | P0 | Exclusive coupon combined with another coupon. | Combination rejected; exclusive alone works. | | BE-COUP-08 | P0 | Stack 10% then ₹100 on ₹1000; reverse order. | 200 (800 payable) vs 190 (810 payable); order-sensitive result. | | BE-COUP-09 | P0 | 15% on ₹999; 12.5% on ₹1000; exact `.5` rounding. | Discounts round to nearest rupee consistently client/server. | | BE-COUP-10 | P1 | Percentage with `maxValue` after a prior coupon; flat above remaining. | Cap applies to its own reduced base; discount clamped to remaining. | | BE-COUP-11 | P0 | 100% and 150% coupons. | Goods never below zero; delivery may remain; no negative totals. | | BE-COUP-12 | P0 | Delivery with a coupon that crosses the free-delivery threshold. | Coupon base excludes delivery; fee uses the defined post-discount goods subtotal. | | BE-COUP-13 | P1 | Targeted + whole-cart coupons across two slots. | Per-sub-order discounts sum exactly; no unrelated goods discounted. | | BE-COUP-14 | P0 | Coupon usage persists once per order group; cancellation restores it. | Usage row/one-time invariants correct; cancel frees usage when no sibling remains. | | BE-COUP-15 | P0 | ₹101 sub-order ×2 with two ₹101 stackable coupons. | Per-sub-order discounts ≤ goods; totals never negative; exact reconciliation. | | BE-COUP-16 | P1 | Coupon invalidated/deleted after being selected but before submit. | Submit rejects; no silently discounted order. | | BE-COUP-17 | P1 | Global coupon authored by superadmin used in A and B. | Applies in both; regional coupon does not leak. | | BE-COUP-18 | P1 | Global coupon switched from 20% to ₹50 in the superadmin form. | Percentage is cleared; pricing uses ₹50 only (`BR-14`, known open). | #### Orders, cancellation and fulfillment | ID | P | Case | Expected | |---|---|---|---| | BE-ORDER-01 | P0 | Valid scheduled COD order with address, slot, notes and coupon. | Correct rows/SKUs/qty/region/amount; COD only; no payment-gateway fields. | | BE-ORDER-02 | P0 | Items assigned to S1 and S2 in one checkout. | One sub-order per slot in one group; one delivery fee on the primary; totals sum. | | BE-ORDER-03 | P0 | Persisted order read back by customer and admin. | Same items, discount, delivery, total, region and status on both surfaces. | | BE-ORDER-04 | P0 | Empty items, unknown SKU, invalid/negative/fractional quantity, duplicate lines. | No empty/invalid order; quantity/duplicate policy enforced. | | BE-ORDER-05 | P0 | Foreign-region SKU, slot or address-bound pairing. | Rejected; no cross-region order or fee manipulation. | | BE-ORDER-06 | P0 | Deleted, OOS, globally suspended and regionally suspended SKU. | Rejected server-side even with a stale client payload. | | BE-ORDER-07 | P0 | Full, frozen, past, inactive or wrong-region slot. | Rejected with the appropriate 4xx; no order. | | BE-ORDER-08 | P0 | Scheduled order with `slotId: null` (the old web bug). | Rejected with "slot required"; valid per-line slot IDs succeed. | | BE-ORDER-09 | P0 | Slot does not carry one of the ordered SKUs. | Rejected; no partial order. | | BE-ORDER-10 | P0 | Address coordinates in B while the client sends `regionId=A`. | Server derives B from coordinates; B pricing/slot/region used. | | BE-ORDER-11 | P0 | Bound A1 vs A2 selected address with different fee/threshold. | Address bound drives the fee/threshold; client bound is ignored. | | BE-ORDER-12 | P0 | Coupon becomes ineligible between selection and submit. | Server revalidates; rejection or documented repricing; no false success. | | BE-ORDER-13 | P1 | User notes and admin notes round-trip. | Persisted and visible on the correct surfaces. | | BE-ORDER-14 | P0 | Flash order with a flash price and null slot. | Flash price/flag/fee; no scheduled slot; admin sees flash order. | | BE-ORDER-15 | P0 | Flash disabled in the address bound but enabled in the browsing region. | Rejected server-side. | | BE-ORDER-16 | P1 | Rapid double tap / duplicate in-app submit. | One in-app request; no duplicate order. | | BE-ORDER-17 | P1 | Raw concurrent API submits (characterization). | Record whether two orders are created; known lack of server idempotency is explicit. | | BE-ORDER-18 | P1 | Historical order after product/variant/store soft delete. | History keeps original name, quantity and charged amount. | | BE-ORDER-19 | P1 | Customer order list pagination and order detail by numeric ID. | Stable order; no duplicates/skips; readable ID rejected if not supported. | | BE-ORDER-20 | P0 | U2 reads/cancels/notes U1's order; staff B reads A's order. | Denied; no private payload. | | BE-ORDER-21 | P0 | Cancel with reason, without reason, by user and by staff. | Reason required; actor/status correct; coupon usage restoration correct. | | BE-ORDER-22 | P1 | Cancel a delivered order; deliver a cancelled order; revert delivered. | Customer cancellation of a delivered order is rejected; staff transitions follow the approved policy. Current gaps (cancelled→delivered, delivered→undelivered) are pinned until the policy changes. | | BE-ORDER-23 | P0 | Quiet region A with old orders while B creates many newer orders; page A. | A returns all its rows and a valid cursor; no global-ID window starvation. | | BE-ORDER-24 | P1 | Admin marks packaged/verified/delivered; customer detail reflects it. | Status and timestamps agree; no partial item/order state. | | BE-ORDER-25 | P1 | Admin removes the delivery charge; rebalances slots/items. | Totals reconcile; historic discount preserved; no duplicate fee. | | BE-ORDER-26 | P1 | Admin delivery sequence for a slot and coordinate override. | Sequence/order correct; coordinates update the intended order only. | | BE-ORDER-27 | P2 | Order-detail money after migration/backfill. | New orders store discount; historical rows may show 0 (accepted; see `BR-13`). | #### Admin API and isolation | ID | P | Case | Expected | |---|---|---|---| | BE-ADMIN-01 | P0 | Staff A/B login, `me`, region-scoped dashboard. | Correct staff/region; no cross-region counters. | | BE-ADMIN-02 | P0 | Staff B reads/writes A product, store, slot, tag, group, banner, coupon IDs. | Denied/not found; no writes. | | BE-ADMIN-03 | P0 | Regional product CRUD and customer publication. | Created/updated product visible in A only; B unchanged. | | BE-ADMIN-04 | P0 | Regional edit of a global product: price, stock, flash, suspension. | Only market rows for A change; global structure and B market untouched. | | BE-ADMIN-05 | P0 | Suspend a global SKU in A, reopen/edit an unrelated price, save. | Suspension remains in A; B unaffected (`BR-11`). | | BE-ADMIN-06 | P0 | Regional admin edits a global SKU's market data; superadmin edits the structure. | Existing SKU IDs preserved; no duplicate variants; market scope is A only. | | BE-ADMIN-07 | P0 | Regional staff edits a global store. | Rejected; regional write never mutates global store data. | | BE-ADMIN-08 | P0 | Failed regional edit of a global store with an old image. | Image is not deleted; object storage unchanged (`BR-04`). | | BE-ADMIN-09 | P0 | Delete a product/store with dependent rows; delete a free one. | Protected deletes rejected; free deletes soft-delete/hide correctly. | | BE-ADMIN-10 | P1 | Product SKU create/edit/delete, features, images, tags, groups, combos. | Correct relations; no orphan rows; duplicate SKU IDs not created. | | BE-ADMIN-11 | P1 | Banner CRUD and active/order state; customer sees only active A banners. | Regional isolation and ordering. | | BE-ADMIN-12 | P1 | Regional coupon CRUD, targeting, user targeting, invalidation. | Region/targets enforced; invalid coupon rejected for use. | | BE-ADMIN-13 | P1 | Slot CRUD, SKU assignment, capacity, freeze/edit. | Customer discovery/checkout reflects changes; full slots disabled. | | BE-ADMIN-14 | P1 | Product tags/groups/customize-app ordering in A. | Persisted order and popular/all-items output. | | BE-ADMIN-15 | P0 | Search customers by name/mobile in A; same search in B. | Only customers with A/B orders respectively; no cross-region mobile leakage (`BR-01`). | | BE-ADMIN-16 | P1 | Customer detail, order history, suspension/unsuspension, incidents. | Region-scoped; suspension blocks ordering; incident audit correct. | | BE-ADMIN-17 | P0 | `sendAdminNotification` as staff, customer, anonymous. | Staff allowed; customer/anonymous denied; no queue write on denial. | | BE-ADMIN-18 | P1 | Vendor snippet CRUD, order/slot reads, packaging (conditional). | Scoped to staff region; unauthorized IDs denied. | | BE-ADMIN-19 | P1 | Complaints list/reply/resolve in A; B complaint invisible. | Region isolation; customer sees the reply. | | BE-ADMIN-20 | P1 | Region constants edit and propagation to A bounds. | A customer discovery/pricing changes; B unchanged. | | BE-ADMIN-21 | P0 | `getStaff`, `createStaffUser`, `getRoles`, `savePushToken` as customer. | Denied (protectedProcedure is not a staff guard — regression check). | | BE-ADMIN-22 | P1 | Image upload URL generation and object round-trip. | Authorized contexts only; stored bytes match; no arbitrary-key delete. | #### Superadmin API | ID | P | Case | Expected | |---|---|---|---| | BE-SA-01 | P0 | Superadmin login/me; direct protected route access. | Correct principal; no staff/customer escalation. | | BE-SA-02 | P0 | Staff/customer/anonymous calls every superadmin mutation. | Denied before DB/job writes. | | BE-SA-03 | P0 | Region list/create/update; duplicate name/invalid bounds. | Valid region; clear conflict; no orphan rows. | | BE-SA-04 | P1 | Bound create/update/delete: last bound, referenced bound, valid bound. | Last/referenced refused; valid delete succeeds. | | BE-SA-05 | P0 | Create a region with global products present; inspect cache files. | Per-region market rows seeded; cache generation awaited and files exist (`BR-07`). | | BE-SA-06 | P1 | Staff list/create/update/remove/roles and region assignment. | Region/role changes effective on next auth; removed staff denied. | | BE-SA-07 | P1 | Global store CRUD and customer visibility in all regions. | Shared store visible; regional admin cannot edit it. | | BE-SA-08 | P0 | Global product create/edit/delete with two SKUs. | Per-region market rows; customer sees it in A/B. | | BE-SA-09 | P0 | Edit an existing global product's SKUs and save. | IDs preserved; no duplicate variants; suspension state coherent (`BR-03`). | | BE-SA-10 | P1 | Elevate a regional product to global. | Region becomes null; market rows exist; former region keeps selling. | | BE-SA-11 | P0 | Global product suspension/market edits. | Global structural suspension applies where intended; regional overrides independent. | | BE-SA-12 | P1 | Global coupon create/edit/delete with percent, flat, targets, users. | Valid coupon; one discount type; superadmin-only. | | BE-SA-13 | P1 | Global constants edit; customer discovery in A/B. | Global values propagate; regional/bound overrides win. | | BE-SA-14 | P1 | Superadmin complaints list/reply. | Cross-region visibility per policy; no customer-private leakage beyond scope. | | BE-SA-15 | P0 | `superadmin.staff.sendAdminNotification` as superadmin/staff/customer. | Superadmin allowed; staff/customer denied; queue write only on success (`BR-16`). | | BE-SA-16 | P1 | Region cache files after create/update; served version matches. | Files exist for the new region; no undefined/version-0 paths. | | BE-SA-17 | P1 | Staff role/permission checks for global authoring. | Only intended roles can author; server-side enforcement. | | BE-SA-18 | P2 | Region rename/priority changes while customers browse. | IDs stable; discovery refreshes within deadline; no data moves. | #### Cache, jobs and health | ID | P | Case | Expected | |---|---|---|---| | BE-CACHE-01 | P0 | Regional product/store/tag/banner change in A. | A cache files/version advance; B unchanged. | | BE-CACHE-02 | P0 | Price/stock/offer/suspension edit in A. | Availability version/data correct; no stale orderable SKU. | | BE-CACHE-03 | P0 | Slot create/update/full/freeze. | Slots/next-delivery/cart choices converge within 120s. | | BE-CACHE-04 | P0 | Global change followed by a regional change in the debounce window. | All regions regenerate; regional request cannot narrow (`BR-05`). | | BE-CACHE-05 | P1 | Rapid A/B edits in the same window. | Both pending regions publish; final write not lost. | | BE-CACHE-06 | P1 | Several same-region writes while generation is running. | Final snapshot is current; no stale final write. | | BE-CACHE-07 | P1 | Missing/corrupt discovery KV for a bound. | Rebuilt for the correct bound; no foreign fallback. | | BE-CACHE-08 | P0 | Products file ready, availability old/missing/wrong region. | No unsafe zero-price/in-stock or mixed-region purchasable catalog. | | BE-CACHE-09 | P1 | Object-storage failure during generation. | Failure recorded; version not falsely complete; retry/repair coherent. | | BE-CACHE-10 | P1 | Fresh vs already-open client after publication. | Both converge; no restart/storage-clear requirement. | | BE-CACHE-11 | P1 | Product soft-deleted while generation pending. | Live surfaces omit it; order history unaffected. | | BE-CACHE-12 | P1 | Cache consistency: every availability entry maps to a product; slot products exist; store counts match. | All cross-file references valid. | | BE-JOB-01 | P1 | Store initializer/startup and flash schedule job in an isolated scheduler. | Stores ready; flash enablement boundaries correct; no production cron touched. | | BE-JOB-02 | P1 | Queue/notification job failure after order commit. | Order remains; job retryable; no duplicate order. | | BE-JOB-03 | P1 | Health check with DB/KV/storage failures. | Explicit degraded status, not false healthy. | | BE-UPL-01 | P1 | Upload URL contexts: review, product, store, complaint, profile, tags, notification. | Correct folder/key and MIME; no arbitrary path. | | BE-UPL-02 | P0 | Unauthorized upload URL request. | Denied; no signed URL returned. | | BE-UPL-03 | P2 | Unsupported MIME/context and oversized payload. | Validation error; no object written. | ### 6.2 Customer frontend flows (L2 native + L4 web) Run each case on both `user-ui` and `web-ui` unless a platform note says otherwise. The expected outcome must match; platform-specific mechanics are noted. #### Startup, location and region | ID | P | Case | Expected | |---|---|---|---| | CUST-01 | P0 | Cold start with GPS inside A; signed out, then signed in. | A resolves once; discovery/catalog/slots load; no bound/version errors. Web: saved region is validated against `listRegions`. | | CUST-02 | P0 | GPS denied, off, outside service and timed out; with and without a default address. | Default address used when available; otherwise a usable manual chooser with the correct reason; no eternal spinner. | | CUST-03 | P0 | Late GPS response after manually choosing B. | Manual choice wins; late response cannot overwrite it. | | CUST-04 | P1 | Signed-in U1 with addresses in A1/A2; remove one; select an address. | Active bound is the lowest-priority A address bound; B addresses ignored; checkout uses selected address bound. | | CUST-05 | P0 | Explicit region switch A→B: cancel, then confirm. | Cancel preserves region/carts; confirm clears A selections and loads B. | | CUST-06 | P1 | Switch A→B→A with populated regular and flash carts. | Each region's cart is restored independently; no cross-region lines/prices. | | CUST-07 | P1 | Cold-start adoption of the first region with a populated local cart. | Cart is preserved (known open if it is wiped — `BR-10`). | | CUST-08 | P2 | Empty region and region with no slots. | Intentional empty states; no crash or fallback to another region. | #### Authentication and account | ID | P | Case | Expected | |---|---|---|---| | CUST-09 | P0 | Browse signed out, open Cart and Me. | Public browsing works; login walls shown without breaking other tabs. | | CUST-10 | P0 | Log in from the cart wall, then from the Me wall; register a new account. | Returns to the originating screen; cart survives login; validation errors are clear. | | CUST-11 | P0 | Wrong password/unknown identifier, then correct; logout and sign in as U2. | No session on failure; U2 cannot see U1 data; logout restores walls. | | CUST-12 | P1 | Session restore after relaunch; expired token during a request. | Valid session restores; expiry forces re-login safely, preserving allowed state. | | CUST-13 | P1 | Edit profile and avatar; relaunch; check admin customer detail. | Saved values/images agree. | | CUST-14 | P1 | Change password, sign out, old vs new password. | New works; old fails; account data intact. | | CUST-15 | P1 | Delete account with wrong/correct confirmation. | Wrong rejected; correct logs out and revokes access. | | CUST-16 | P0 | Suspended customer tries to order; admin unsuspends; retry. | Blocked then allowed; no misleading success. | #### Home, search, stores and product detail | ID | P | Case | Expected | |---|---|---|---| | CUST-17 | P0 | Home in A vs B with regional/global products, tags, banners, stores and slots. | Only correct region + global content; no cross-region prices/assets. | | CUST-18 | P1 | Empty/loading/error/refresh states on Home; pull-to-refresh. | Meaningful states; retry works; no duplicate/stale content. | | CUST-19 | P1 | Search by product name/tag/store; no results. | Correct results for the region; clear empty state. | | CUST-20 | P1 | Stores list and store detail; global store in both regions. | Correct products/counts; global store visible; no foreign store. | | CUST-21 | P0 | Product detail P, Q, G, combo C, flash F. | Correct price/variants/stock/flags/composition; foreign product not reachable. | | CUST-22 | P1 | Add to cart from Home, search, store, product detail, order-again. | Same SKU/quantity/price on every entry point. | | CUST-23 | P1 | Variant/quantity dialog: minimum, increments, maximum, OOS. | Allowed quantities enforced; OOS cannot be added. | | CUST-24 | P1 | Offers/tags/banners deep link to the intended product/store. | Correct destination; no broken/foreign target. | | CUST-25 | P2 | Location bar / address switcher opening and closing. | Current location/address shown; selection updates the active bound. | #### Cart and coupons | ID | P | Case | Expected | |---|---|---|---| | CUST-26 | P0 | Add, re-add, update quantity, remove, cancel removal. | Merge vs set-quantity semantics correct; only the selected line changes. | | CUST-27 | P0 | Populated cart cold start; regular and flash carts separately. | Both restore independently; no silent deletion or cross-cart leak. | | CUST-28 | P1 | Assign/change slots; leave/re-enter/relaunch. | Selection persists per policy; no quantity duplication. | | CUST-29 | P0 | One line becomes OOS/suspended/deleted; all lines invalid. | Invalid lines excluded from pricing/submit; all-invalid checkout blocked. | | CUST-30 | P1 | Notes entered, checkout, back, edit; latest note submitted. | Latest value survives and is persisted. | | CUST-31 | P0 | Coupon dropdown: eligible, wrong region, first-order-used, min-order short, no targets, expired, invalidated, used-up, personal. | Eligible first; disabled rows show the exact reason; hidden coupons never appear. | | CUST-32 | P0 | Apply/remove stacked coupons; change quantities. | Marginal savings and totals recompute; no stale invalid discount. | | CUST-33 | P0 | 10% then ₹100 vs ₹100 then 10%; 15% rounding; 100%+ coupon. | Order-sensitive totals; nearest-rupee rounding; no negative preview. | | CUST-34 | P1 | "Products discount" row shown/hidden at >₹1 vs ≤₹1; coupons separate. | Correct label/visibility; bill lines sum to total. | | CUST-35 | P0 | Checkout guard: item without slot, selected slot no longer offered, freeze passed, valid slots, flash cart. | Button disabled with the correct message for scheduled; flash exempt; recovery re-enables. | | CUST-36 | P0 | Cart preview vs checkout vs persisted order totals. | All three agree: goods − discount + delivery = payable. | | CUST-37 | P1 | Corrupt storage, storage full, slow price refresh. | Recoverable state; no phantom/zero-priced purchase; coherent loading. | | CUST-38 | P1 | Logout/login U2 with U1's cart; account switch. | Agreed cart-retention policy; no U1 address/coupon/notes leakage. | #### Checkout and order placement | ID | P | Case | Expected | |---|---|---|---| | CUST-39 | P0 | Checkout with an address in A1 vs A2 vs B; inspect fee/threshold. | Selected address's bound/region drives pricing; browsing region does not override. | | CUST-40 | P0 | Customer with zero addresses opens cart/checkout. | First-address gate appears before cart, even when empty; after saving, cart renders. | | CUST-41 | P0 | Scheduled checkout with items assigned to S1/S2. | Each submitted line carries its own slot ID; no null scheduled slot (`BR-06`). | | CUST-42 | P0 | Valid COD checkout; inspect payment UI. | COD succeeds; online option is disabled "coming soon"; no gateway invocation. | | CUST-43 | P0 | Change coupons/address/slot/notes after returning from cart. | Latest state shown and submitted; no stale route params. | | CUST-44 | P0 | Double-tap Place Order; pending rerender. | Synchronous guard sends one in-app request. | | CUST-45 | P1 | Mutation fails, then retry; session expires mid-checkout. | Loading released, error shown, state preserved; login return safe. | | CUST-46 | P1 | Response lost after commit. | History checked before retry; no false claim of server deduplication. | | CUST-47 | P0 | Client tampers with price/discount/region/bound/slot. | Server ignores client money/region and uses authoritative values. | | CUST-48 | P1 | Multi-sub-order success and zero-total success. | Success references valid orders/group; authoritative totals/zero handled. | | CUST-49 | P1 | Flash checkout in A (enabled) vs B (disabled). | Flash price/fee/null slot in A; rejected in B even via direct route. | | CUST-50 | P1 | Android back/iOS swipe/browser refresh/deep link to success. | No duplicate order, lost notes or wrong-order detail. | #### Orders, profile and support | ID | P | Case | Expected | |---|---|---|---| | CUST-51 | P0 | My Orders list: pending/delivered/cancelled, split group, pagination. | Correct rows/status/labels; no missing/duplicate pages. | | CUST-52 | P1 | Order detail: items, address, slots, bill, status timeline, notes. | Matches persisted order/admin view; discount/delivery/total reconcile. | | CUST-53 | P0 | Cancel a fresh order with a reason; cancel a delivered order. | Reason required; allowed/denied transitions correct; coupon restored when applicable. | | CUST-54 | P1 | Order again / reorder; historical deleted product. | Valid lines re-added; unavailable lines handled; history remains readable. | | CUST-55 | P1 | Raise a complaint with/without image; view admin reply. | Persisted, region-correct, visible reply; no cross-user access. | | CUST-56 | P1 | Addresses: add with map coords, edit/default/delete, outside-area point. | Bound/region derived; errors clear; default policy correct. | | CUST-57 | P1 | Coupons page: eligible/used/expired labels and empty state. | Agrees with eligibility rules; no hidden coupon shown as available. | | CUST-58 | P1 | Push permission/token registration; region sync after address add; notification deep link. | Token stored for the address region; link opens the intended order/product. | | CUST-59 | P2 | Offline/network failure on Home/cart/checkout. | Explicit error/retry; no false success; cart preserved. | | CUST-60 | P2 | Keyboard, safe area, back navigation and accessibility labels on checkout/cart. | Usable on small screens; no hidden action; controls have accessible names. | ### 6.3 Admin frontend flows (L3 native + L5 web) Run each case on `admin-ui` and `admin-web`; note platform-specific reload/storage behaviour. | ID | P | Case | Expected | |---|---|---|---| | ADM-01 | P0 | Staff A login; reload; direct protected route. | Correct staff/region; session restores; no privileged flash before auth. | | ADM-02 | P0 | Staff A vs B dashboard/orders/products. | Only own-region data; no B counts/rows. | | ADM-03 | P0 | Logout, login as B; browser back to A route. | A data cleared; denied/redirected; no cached private content. | | ADM-04 | P0 | Customer/anonymous token on admin mutations. | Denied; UI hiding is not the only guard. | | ADM-05 | P0 | Orders list: filters, search, pagination, empty/error, delivered toggle. | Correct filtered rows and counts; keyset pagination stable. | | ADM-06 | P0 | Quiet region A with old orders while B has newer orders; load more. | A paginates its own rows; no empty list/starvation (`BR-09`). | | ADM-07 | P0 | Order detail: items, bill, address, notes, status, customer. | Matches persisted order; discount/delivery/total reconcile. | | ADM-08 | P0 | Mark packaged/verified/delivered; customer sees the change. | Status/timestamps persist; no partial item state. | | ADM-09 | P0 | Cancel with reason; cancel delivered; remove delivery charge. | Correct transitions; no duplicate fee; customer view reflects it. | | ADM-10 | P1 | Rebalance slots/items; verify pricing and discount preservation. | Items move; totals recompute; historic discount/delivery preserved. | | ADM-11 | P1 | Delivery sequence/map: order, coordinates, missing coords. | Stable sequence; coordinate edits scoped to the order. | | ADM-12 | P1 | Admin notes and customer notes. | Persist on the correct order; visible to the intended audience. | | ADM-13 | P0 | Products list/search/filter; open detail. | Region-correct products; OOS/suspended flags; no foreign items. | | ADM-14 | P0 | Create a regional product with two SKUs, features, images, tags. | Product/SKUs persist; customer sees it in A only. | | ADM-15 | P0 | Edit a regional product's SKU/price/stock/offer. | Updates one product; no duplicate SKUs; availability cache refreshes. | | ADM-16 | P0 | Edit a global product's market price/stock/flash/suspension in A. | Only A market changes; structure/B untouched. | | ADM-17 | P0 | Suspend a global SKU in A, reopen, change price, save. | Suspension preserved (`BR-11`). | | ADM-18 | P0 | Edit/delete a product with dependent rows. | Delete guards correct; image/asset lifecycle safe. | | ADM-19 | P1 | Prices overview and variant stock dialog. | Inline edits persist; invalid values rejected; cache updates. | | ADM-20 | P1 | Product tags: create/edit/delete/order; assign products. | Persisted ordering/membership; customer order matches. | | ADM-21 | P1 | Product groups: create/edit/delete/membership; assign to slot. | Group/slot semantics consistent; no orphan membership. | | ADM-22 | P1 | Combos: create combo and components; check customer detail. | Composition/pricing/flags correct. | | ADM-23 | P0 | Stores list/add/edit/delete; global store read-only. | Region isolation; global edit blocked; image preserved on failure. | | ADM-24 | P0 | Slots: create with SKUs, edit, capacity, freeze, detail. | Customer discovery/checkout reflects it; full slot blocked. | | ADM-25 | P1 | Coupons: list/create/edit/invalidate; targets/users. | Region/targets enforced; invalid coupon cannot be used. | | ADM-26 | P1 | Banners: create/edit/delete/order/active. | Customer sees only active A banners in order. | | ADM-27 | P1 | Customize app: popular items and all-items ordering. | Persisted order; customer home matches. | | ADM-28 | P1 | Users: list, search by name/mobile, detail, suspend/unsuspend. | Search region-scoped; suspension blocks ordering; no cross-region leakage (`BR-01`). | | ADM-29 | P0 | Search a U1 mobile from staff B; search same name with A/B customers. | B sees nothing/only B; A sees only A (`BR-01`). | | ADM-30 | P1 | User incidents and notifications to selected users. | Incident audit correct; notification queued only for allowed recipients. | | ADM-31 | P1 | Complaints list/reply/resolve. | Region-scoped; customer sees the reply. | | ADM-32 | P1 | Vendor snippets: create/edit/delete, order/slot reads. | Region-scoped; slot picker works after reload (web, `BR-15`). | | ADM-33 | P1 | Region constants edit. | A customer discovery/pricing changes; B unchanged. | | ADM-34 | P1 | Upload product/store/banner images. | Upload succeeds; URL persisted; replaced image cleanup safe. | | ADM-35 | P2 | Empty/loading/error states across dashboard routes. | Retry/back navigation works; no permanent spinner. | ### 6.4 Superadmin frontend flows (L6) | ID | P | Case | Expected | |---|---|---|---| | SA-01 | P0 | Login/logout, reload, direct protected route. | Session restores; logout clears; no staff/customer access. | | SA-02 | P0 | Regions list; create region with at least one bound. | Region appears; cache files generated; assignments possible. | | SA-03 | P0 | Create region without bounds, duplicate priorities, malformed GeoJSON. | Validation/conflict; no half-created region. | | SA-04 | P1 | Edit region name/metadata; add/edit/delete bounds. | Stable IDs; last/referenced bound refused; customers converge. | | SA-05 | P0 | Region creation with global products. | Per-region market rows seeded; no zero-price sale. | | SA-06 | P0 | Region cache generation on create/edit. | Files exist and are served; no `v-undefined` (`BR-07`). | | SA-07 | P1 | Staff list/create/update/remove/roles. | Region/role assignment effective; removed staff denied. | | SA-08 | P1 | Global stores CRUD. | Visible in all regions; regional admins read-only. | | SA-09 | P0 | Global products list/create/edit/delete; two SKUs. | Per-region markets; customer sees in A/B. | | SA-10 | P0 | Edit an existing global product; save twice. | SKU IDs preserved; no duplicate variants (`BR-03`). | | SA-11 | P0 | Switch create→edit and edit→create in the form. | Form state resets/keyed; no draft bleed (`BR-08`). | | SA-12 | P0 | Suspend/edit market data; regional admin view. | Global vs regional flags independent. | | SA-13 | P1 | Elevate a regional product. | Region null, market rows, still purchasable. | | SA-14 | P1 | Global coupons: create/edit/delete/targets/users. | Valid; one discount type; applies in both regions. | | SA-15 | P0 | Change a global coupon from percent to flat and save. | Percent cleared; pricing uses flat only (`BR-14`, known open). | | SA-16 | P1 | Global constants edit. | Propagates to A/B discovery; regional overrides win. | | SA-17 | P1 | Complaints list/reply; admin notifications. | Correct scope; no private leakage. | | SA-18 | P0 | "Admin Notifs": send as superadmin. | Success and queue write; no guard failure (`BR-16`). | | SA-19 | P0 | Staff/customer token calls superadmin routes. | Denied; no data. | | SA-20 | P1 | Empty/loading/error states and destructive confirmations. | No accidental delete; clear errors. | | SA-21 | P1 | Upload global store/product images. | URL persists; shared asset not deleted by regional failure. | | SA-22 | P2 | Region tabs and selected-region switching. | Correct context; stale labels refresh by ID. | | SA-23 | P1 | Cache status after global edit. | All regions publish within deadline; no regional narrowing. | ### 6.5 Conditional and legacy surfaces Run only when product/operations confirms support. `N/A` requires a reason. | ID | P | Case | Expected | |---|---|---|---| | COND-01 | P2 | Vendor snippet page: login, list orders, open packaging. | Scoped to the snippet/staff region; packaging correct. | | COND-02 | P2 | Reviews: create a review with image; admin response. | Persisted/visible if the feature is supported; otherwise N/A. | | COND-03 | P2 | OTP login in an isolated provider sandbox. | Account created/authenticated once; no real SMS; otherwise N/A. | | COND-04 | P2 | Legacy fallback login/home/order-details pages. | Only supported ownership paths are exercised; demos/unsupported pages are N/A with reason. | ### 6.6 Cross-app E2E journeys (L7) Only these critical chains use the real backend and real clients. | ID | P | Journey | Expected | |---|---|---|---| | E2E-01 | P0 | Superadmin creates region A + bound + staff → staff creates store/product/slot/coupon → customer U1 sees catalog and places COD order → staff packages/delivers → customer sees delivered. | Full chain; IDs and money agree at every step. | | E2E-02 | P0 | Superadmin creates global product G with A/B prices → customer sees G in A and B with different prices → regional admin edits A market price → A changes, B does not. | Global structure shared; market data isolated. | | E2E-03 | P0 | Customer switches A→B and back on native and web with populated carts. | Region content/carts isolated; explicit switch clears/restores correctly. | | E2E-04 | P0 | Coupon stack (10% + ₹100) across web/native checkout; verify persisted order/admin detail. | 200 discount on ₹1000; all surfaces agree; no negative totals. | | E2E-05 | P0 | Flash order in A (enabled) and blocked flash attempt in B. | Flash price/flag in A; server rejection in B. | | E2E-06 | P0 | Multi-slot order S1/S2 with one delivery fee; admin fulfills both. | One group, two sub-orders, one fee; statuses consistent. | | E2E-07 | P0 | Cancel an order using a first-order coupon; verify usage restoration and re-order. | Coupon usable again only when no sibling remains. | | E2E-08 | P0 | Web scheduled checkout with items in two slots. | No null-slot rejection; correct slots persisted (`BR-06`). | | E2E-09 | P0 | Staff B searches U1's name/mobile; staff A searches same. | B cannot see A customer; A can (`BR-01`). | | E2E-10 | P0 | Global product edit → both region caches refresh → customers in A/B see it. | All regions publish; regional edit does not narrow (`BR-05`). | | E2E-11 | P1 | Admin-web reload → vendor snippet slot picker. | Slots load; staff/region restored (`BR-15`). | | E2E-12 | P1 | Superadmin sends "Admin Notifs" to admins. | Queued, not UNAUTHORIZED (`BR-16`). | | E2E-13 | P0 | Authorization probe: customer token against admin/superadmin mutations; staff against superadmin. | Denied at every step; no writes. | | E2E-14 | P1 | Product soft-delete after an order; customer/admin order history. | Original name/amount render; catalog removes it. | | E2E-15 | P0 | Address with coordinates in B while browsing A; place order. | Order appears in B admin queue and B pricing; A unaffected. | | E2E-16 | P1 | Cancelled/delivered transitions and customer notification deep link. | Correct status/link; no duplicate order. | --- ## 7. Current-branch regression pack (release-blocking) These cases must be automated first; they encode the defects found in the `MULTI_REGION_I2` review and the fixes applied during hardening. | ID | P | Scenario | Expected | Automation | |---|---|---|---|---| | BR-01 | P0 | Staff A and B search customers by a name/mobile that exists in both regions. | A returns only customers with A orders; B only B; no cross-region mobile leakage. | `apps/backend/tests/api/admin-region-isolation.test.ts` | | BR-02 | P0 | Web customer selects region/bound; inspect `essentialConsts` request. | Request sends `{ boundId }`, never `{ regionId }`; catalog/slots enable. | `apps/web-ui/tests/flows/discovery.test.tsx` + E2E | | BR-03 | P0 | Superadmin edits a global product with two existing SKUs and saves twice. | SKU IDs preserved; SKU count unchanged; no suspended duplicate. | `apps/backend/tests/api/superadmin.test.ts` | | BR-04 | P0 | Regional staff edits a global store with an image; mutation rejected. | Image/object remains; no partial update. | `apps/backend/tests/api/admin-catalog.test.ts` | | BR-05 | P0 | Global product edit, then regional banner edit inside the debounce window; inspect caches. | `allRegionsPending` wins; every region regenerates. | `apps/backend/tests/api/cache-region.test.ts` | | BR-06 | P0 | Web scheduled checkout with items in S1/S2. | Each item sends its `slotId`; no `slotId: null`; order succeeds. | `apps/web-ui/tests/flows/checkout.test.tsx` + E2E-08 | | BR-07 | P0 | Superadmin creates a region with global products. | Cache files exist after the response; `createRegionCacheFiles` awaited. | `apps/backend/tests/api/regions.test.ts` | | BR-08 | P1 | Superadmin global products: open create, then edit, then create again. | Form resets/keyed; no draft bleed; submit targets the selected product. | `apps/superadmin-ui/src/routes/global-products.test.tsx` | | BR-09 | P0 | Region A has old orders; region B creates > limit + 5 newer orders; page A. | A returns its rows and a valid next cursor; no global-ID window starvation. | `apps/backend/tests/api/admin-orders.test.ts` | | BR-10 | P1 | Cold start adopts the first region with a populated persisted cart. | Cart preserved; only an explicit switch away clears it. | `apps/user-ui/tests/flows/region.test.tsx` + `apps/web-ui/tests/flows/cart.test.tsx` — **known open** | | BR-11 | P0 | Suspend a global SKU in A; reopen; change only price/stock; save. | Suspension remains `true` in A; B unchanged. | `apps/backend/tests/api/admin-catalog.test.ts` | | BR-12 | P0 | Two ₹101 sub-orders + two ₹101 stackable coupons. | Discounts `[101, 101]`; totals `[0, 0]`; no negative; delivery handled separately. | `apps/backend/tests/api/coupon-math.test.ts` + `packages/shared` via API | | BR-13 | P2 | Historical order with a coupon-implied discount after migration. | `discount_amount` is `0` (accepted): invoices show no discount; derivation is not required. | `apps/backend/tests/api/order-lifecycle.test.ts` — **accepted limitation** | | BR-14 | P1 | Change a global coupon 20% → ₹50 and save. | Percent is cleared; pricing uses ₹50. | `apps/backend/tests/api/coupons.test.ts` — **known open** | | BR-15 | P1 | Admin-web reload on the vendor snippet screen. | `admin.staffUser.me` restores staff/region; slots load. | `apps/admin-web/tests/flows/vendor-snippets.test.tsx` | | BR-16 | P0 | Superadmin sends an admin notification. | `superadmin.staff.sendAdminNotification` succeeds; staff endpoint still staff-guarded. | `apps/backend/tests/api/admin-ops.test.ts` | | BR-17 | P0 | Customer checkout and order detail. | COD only; no online-payment method/routes; disabled "coming soon" card if present. | `apps/backend/tests/api/order-flow.test.ts` + customer UI flows | | BR-18 | P0 | Scheduled order with one null slot and one valid slot. | Rejected; no partial order; valid per-line slots succeed. | `apps/backend/tests/api/place-order-edge-cases.test.ts` | | BR-19 | P0 | Address in B while client sends A; bound-specific fee. | Address region/bound wins; correct fee/region. | `apps/backend/tests/api/order-rules.test.ts` | | BR-20 | P1 | A/B order pagination with interleaved IDs. | Stable keyset pages for each region; no skipped duplicate rows. | `apps/backend/tests/api/admin-orders.test.ts` | --- ## 8. Existing coverage and gaps ### Reuse before writing new files | Existing suite | Reuse/extend for | |---|---| | `apps/backend/tests/api/order-flow.test.ts`, `order-rules.test.ts`, `place-order-edge-cases.test.ts` | `BE-ORDER-01`–`BE-ORDER-15`, `BR-18`, `BR-19` | | `apps/backend/tests/api/coupon-math.test.ts`, `coupons.test.ts`, `coupon-ux.test.ts`, `order-lifecycle-gaps.test.ts` | `BE-COUP-01`–`BE-COUP-18`, `BR-12`, `BR-14` | | `apps/backend/tests/api/admin-orders.test.ts`, `admin-ops.test.ts`, `order-lifecycle.test.ts` | `BE-ORDER-20`–`BE-ORDER-26`, `BR-09`, `BR-20` | | `apps/backend/tests/api/authorization.test.ts`, `authorization-matrix.test.ts` | `BE-AUTH-09`, `BE-ADMIN-02`, `BE-ADMIN-21`, `BR-16` | | `apps/backend/tests/api/cache-*.test.ts` | `BE-CACHE-01`–`BE-CACHE-12`, `BR-05` | | `apps/user-ui/tests/screens/cart-*.test.tsx`, `checkout*.test.tsx`, `order-*.test.tsx` | `CUST-26`–`CUST-55` baseline; replace component assertions with flow assertions where needed | | `apps/admin-ui/tests/screens/*` | `ADM-05`–`ADM-35` baseline; add multi-region/global cases | | `apps/superadmin-ui/src/lib/bound-rules.test.ts` | Pure bound validation only; keep as-is, add route-level `SA-*` cases | ### Current coverage | App / suite | Existing | Gaps to fill | |---|---|---| | `apps/backend/tests/api` | 35 Jest files (~192 describe/it entries), real HTTP, auth/order/coupon/cache/admin basics. | Multi-region/bounds, global products/stores, superadmin, region isolation, keyset pagination, store ownership/image, SKU ID preservation, cache all-regions flag, COD-only regression, web discovery contract, discount history. | | `apps/user-ui/tests` | 367 tests, mostly screen/component with mocked network. | Real screen-flow coverage for region adoption/switch, web parity, flash, checkout per-slot payload, account switching, startup cart preservation. | | `apps/admin-ui/tests` | 497 tests, screen/component with mocked network. | Multi-region/global market editing, region isolation, order keyset pagination, store image ownership, admin-web parity, cache-visible effects. | | `apps/web-ui` | None. | Full L4 route-level harness + flows: discovery, auth, catalog, cart, checkout, orders, profile, flash. | | `apps/admin-web` | None. | Full L5 route-level harness + flows; staff restore after reload; parity with admin-ui. | | `apps/superadmin-ui` | One unit test (`bound-rules.test.ts`). | L6 route tests for login, regions/bounds, staff, global stores/products/coupons, constants, notifications, cache. | | `tests/e2e` | 3 Maestro flows + subflows (add product, add slot, user order). | Region/global journeys, web checkout, coupon money, cancellation, authorization probes, cross-app chain. | | `tests/e2e-web` | None. | Playwright critical web journeys. | Recommended new files: - Backend: `regions-bounds.test.ts`, `global-catalog.test.ts`, `superadmin.test.ts`, `admin-region-isolation.test.ts`, `cache-region.test.ts`, `payments-removed.test.ts`, `discount-history.test.ts`. - Customer native: `tests/flows/region.test.tsx`, `cart-region.test.tsx`, `checkout-slots.test.tsx`, `flash.test.tsx`, `orders.test.tsx`. - Admin native: `tests/flows/region-scope.test.tsx`, `global-products.test.tsx`, `order-pagination.test.tsx`, `store-safety.test.tsx`. - Customer web: `tests/flows/discovery.test.tsx`, `cart.test.tsx`, `checkout.test.tsx`, `orders.test.tsx`, `auth.test.tsx`. - Admin web: `tests/flows/auth-restore.test.tsx`, `orders.test.tsx`, `products-global.test.tsx`, `vendor-snippets.test.tsx`. - Superadmin: `src/routes/regions.test.tsx`, `staff.test.tsx`, `global-products.test.tsx`, `global-coupons.test.tsx`, `send-notifications.test.tsx`. - E2E: `tests/e2e/multi-region-order.yaml`, `tests/e2e-web/critical-journeys.spec.ts`. --- ## 9. Recommended implementation order 1. **Harness first**: backend fixture helpers for regions/bounds/global entities; web Jest/jsdom config; superadmin Vitest/jsdom config. 2. **P0 backend**: authorization matrix, region isolation, order placement/money, coupon math, cache all-regions, store/global SKU safety. 3. **P0 web**: discovery `boundId`, scheduled checkout slots, admin-web reload, superadmin notifications. 4. **P0 native**: region startup/switch, checkout slot payload, coupon stacking, order/cancel flows. 5. **P1 backend/admin**: CRUD coverage, fulfillment, pagination, notifications, uploads. 6. **P1 web/superadmin**: parity flows and global authoring. 7. **E2E**: only the critical journeys in §6.6, after the lower layers are stable. 8. **Full regression** before release; run P0 twice (fresh session and already-open session). CI split: - PR: typecheck + backend P0 + affected UI flow suites. - Nightly: all backend API + web/native flow suites. - Pre-release: all P0/P1 + E2E + security matrix + cache deadline checks. --- ## 10. Known open / accepted items | Item | Status | Handling | |---|---|---| | Startup region adoption clears a persisted cart (`region-switch.ts`) | **Open** | `BR-10` is expected to fail until fixed; mark as known defect, not a test bug. | | Global coupon percent→flat keeps the old percent (`global-coupons.ts`) | **Open** | `BR-14`/`SA-15`/`BE-COUP-18` must fail until fixed. | | Historical `discount_amount = 0` backfill | **Accepted** | `BR-13` asserts the accepted behavior; do not block release on it. | | Server-side order idempotency | Deferred | Characterize concurrent submits; UI guard is required; do not assert deduplication. | | OTP login/SMS | Approval-only | Excluded from default regression; use an isolated provider sandbox. | | Reviews, vendor snippets, legacy fallback pages | Conditional | Run only if product/operations confirms support. | | Online payments | Removed | Assert COD-only; no gateway routes/UI. | | Admin `protectedProcedure` endpoints (`getStaff`, `createStaffUser`, `getRoles`, `savePushToken`) | **Pending decision** | `BE-ADMIN-21` encodes the staff-only expectation; if customers are intentionally allowed, document it and downgrade the case. | | No emulator/browser in the authoring environment | Process limitation | Cases are static proposals until a device/browser is available. | --- ## 11. Run report template ```text Run ID / date / code revision: Environment / verified API host / client build: Layer (L1–L7) / case ID / client / identity / region / bound: Fixture IDs and relevant pre-state: Actions and exact inputs: Expected / actual: Status: PASS | FAIL | BLOCKED | NOT RUN | N/A API status/body, persisted values, versions, timestamps: Screenshots/logs (redacted): Cleanup / retained evidence / linked defect: ``` For every failure include the smallest reproduction, the authoritative data read, and whether any data was mutated. A `BLOCKED` harness result is never a pass.