1918 lines
100 KiB
Markdown
1918 lines
100 KiB
Markdown
# backend — API test case catalogue (100% procedure coverage)
|
||
|
||
> **Implemented.** These cases now live as a runnable live HTTP/tRPC suite in
|
||
> [`tests/`](./tests/) (61 files, 1196 `it()` blocks; 1181 catalogue rows plus a
|
||
> few harness/flash smoke cases). See [`tests/README.md`](./tests/README.md) for
|
||
> the harness, fixtures, credentials and authoring rules. Run with:
|
||
>
|
||
> ```bash
|
||
> cd apps/backend
|
||
> bun run dev # wrangler dev on :8787 (keep running)
|
||
> bun run tests/seed-local.ts # once: seeds e2e_super / e2e_staff / e2e_user
|
||
> bun run test:api # jest --runInBand
|
||
> ```
|
||
>
|
||
> Rows that pin current (not intended) behaviour are prefixed `(current)` with a
|
||
> comment in the corresponding test. See `tests/README.md` § "Local-dev
|
||
> environment limitations" for the seeded-DB quirks (per-store detail files,
|
||
> KV/D1 version lag, all-region rebuild OOM).
|
||
|
||
This is the replacement checklist for the deleted `apps/backend/tests` suite. It is written for
|
||
**live HTTP/API tests**, not unit tests: the test process talks to a running backend, authenticates
|
||
with real tokens, creates data through the API, and reads the generated public cache files.
|
||
|
||
- **Runner:** jest + ts-jest, node environment, `--runInBand`
|
||
- **Target:** a running dev backend (`wrangler dev`, default `http://localhost:8787`)
|
||
- **No mocks:** real D1, real R2/S3, real Durable Object cache creator, real queue bindings
|
||
- **One row = one `it()`** unless the row explicitly says “table test”
|
||
- **Suggested layout:** `apps/backend/tests/api/<router>/<procedure>.test.ts`
|
||
- **DB state:** API-created fixtures are preferred. Immutable state (roles, regions, bounds,
|
||
superadmin, staff login) may be seeded once in local D1. Unique suffixes keep reruns valid.
|
||
|
||
> The old `apps/backend/test-case-info.md` describes the deleted 107-test suite and still uses
|
||
> old contracts (for example `cacheVersion` and `placeOrder` without `regionId`). Treat this file
|
||
> as the current source of truth.
|
||
|
||
---
|
||
|
||
## 1. Harness and execution rules
|
||
|
||
### 1.1 Environment
|
||
|
||
| Variable | Purpose |
|
||
| --- | --- |
|
||
| `API_BASE_URL` | backend origin, default `http://localhost:8787` |
|
||
| `TEST_STAFF_NAME` / `TEST_STAFF_PASSWORD` | real staff login |
|
||
| `TEST_USER_IDENTIFIER` / `TEST_USER_PASSWORD` | real user login |
|
||
| `TEST_SUPERADMIN_USERNAME` / `TEST_SUPERADMIN_PASSWORD` | real superadmin login |
|
||
| `TEST_REGION_ID` | a serviceable region used by most suites |
|
||
| `TEST_BOUND_ID` | a bound in `TEST_REGION_ID` |
|
||
| `TEST_OTHER_REGION_ID` / `TEST_OTHER_BOUND_ID` | cross-region isolation |
|
||
| `CACHE_POLL_TIMEOUT_MS` | default `180000`; the product/cache flow should wait at least 60s |
|
||
| `CACHE_POLL_INTERVAL_MS` | default `3000` |
|
||
|
||
Tests must fail fast with a clear message if the backend is not up:
|
||
|
||
```ts
|
||
beforeAll(async () => {
|
||
const res = await fetch(`${API_BASE_URL}/api/health`)
|
||
if (!res.ok) throw new Error(`Backend not reachable at ${API_BASE_URL}`)
|
||
})
|
||
```
|
||
|
||
### 1.2 Tokens and HTTP details
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| HARNESS-01 | setup | staff login | token present; staff id/regionId present |
|
||
| HARNESS-02 | setup | user login | token present; user id present |
|
||
| HARNESS-03 | setup | superadmin login | token present; superadmin id present |
|
||
| HARNESS-04 | setup | bearer header | `Authorization: Bearer <token>` authenticates |
|
||
| HARNESS-05 | edge | user token from cookie | cookie `auth_token` authenticates when no bearer |
|
||
| HARNESS-06 | edge | `Caller-Interface: web` on user login | `Set-Cookie` contains HttpOnly/Secure/SameSite=Lax/Path=/ |
|
||
| HARNESS-07 | edge | mobile login | no `Set-Cookie` |
|
||
| HARNESS-08 | edge | expired/garbage token | treated as anonymous; protected endpoint returns 401 |
|
||
| HARNESS-09 | edge | staff token on user-only endpoint | rejected (`ctx.user` absent) |
|
||
| HARNESS-10 | edge | user token on staff-only write | rejected (`ctx.staffUser` absent) |
|
||
| HARNESS-11 | edge | superadmin token on staff-only endpoint | rejected |
|
||
| HARNESS-12 | edge | staff token on superadmin endpoint | rejected |
|
||
| HARNESS-13 | edge | suspended user token | every tRPC request is rejected (current context behavior) |
|
||
| HARNESS-14 | edge | unknown `boundId` | 404 from `common.essentialConsts` |
|
||
| HARNESS-15 | edge | invalid JSON/batch body | tRPC error, no process crash |
|
||
| HARNESS-16 | edge | OPTIONS CORS preflight | allowed origin/headers/methods |
|
||
| HARNESS-17 | edge | unknown route | 404 JSON, no stack trace |
|
||
| HARNESS-18 | edge | ApiError status mapping | 400/401/403/404/409/422 map to matching tRPC/HTTP codes |
|
||
| HARNESS-19 | edge | unhandled error | 500 with generic message, not raw SQL |
|
||
| HARNESS-20 | edge | concurrent suites | tests run serially; shared region counters are not raced |
|
||
|
||
### 1.3 Reusable fixtures
|
||
|
||
| Fixture | Creation | Notes |
|
||
| --- | --- | --- |
|
||
| `staff` | `admin.staffUser.login` | region-scoped |
|
||
| `superadmin` | `superadmin.auth.login` | global |
|
||
| `user` | `user.auth.register` | unique email/mobile |
|
||
| `store` | `admin.store.createStore` | unique name |
|
||
| `product` | `admin.product.createProduct` | one or more SKUs; features include `quantity` |
|
||
| `slot` | `admin.slots.createSlot` | future delivery/freeze |
|
||
| `address` | `user.address.createAddress` | valid coords inside `TEST_BOUND_ID` |
|
||
| `coupon` | `admin.coupon.create` | unique code |
|
||
| `review` | `user.product.createReview` | attached to product |
|
||
| `complaint` | `user.complaint.raise` | own order or none |
|
||
| `region` | `superadmin.regions.create` | bounds required; unique priorities |
|
||
|
||
Rules:
|
||
|
||
1. Every name/code gets `uniqueSuffix()`.
|
||
2. Future slot times are at least 2 hours ahead and freeze at least 1 hour ahead.
|
||
3. Order tests use a fresh user unless testing history/usage limits.
|
||
4. Cache tests use a dedicated product/store so unrelated writes do not confuse version polling.
|
||
5. Cleanup is best-effort; never make a test depend on a previous cleanup.
|
||
6. Do not import backend runtime modules; import only shared types and a tRPC client.
|
||
|
||
### 1.4 Optional local D1 seed
|
||
|
||
The user explicitly allows creating SQLite/D1 state if needed. Keep it minimal and idempotent:
|
||
|
||
| Seed | Why |
|
||
| --- | --- |
|
||
| one role (`owner`/`admin`) | `createStaffUser` needs a valid role |
|
||
| one staff login | authenticates every admin suite |
|
||
| one superadmin | authenticates superadmin suites |
|
||
| two regions with at least one bound each | region isolation and effective-bound tests |
|
||
| region/bound/global consts | deterministic thresholds and delivery charges |
|
||
| one user login | order/address suites that need stable history |
|
||
|
||
Seed script requirements:
|
||
|
||
- `INSERT OR IGNORE` / upsert by unique name.
|
||
- Never reset the whole DB inside a test run.
|
||
- Never point at production.
|
||
- Keep test-created data distinguishable by suffix.
|
||
- If a test needs an empty region, create it through the superadmin API instead of deleting seeds.
|
||
|
||
---
|
||
|
||
## 2. Golden end-to-end API flows
|
||
|
||
These are the first tests to write; they prove the whole API/cache pipeline is wired.
|
||
|
||
### 2.1 The requested product → list → cache flow
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| E2E-01 | happy | staff login and resolve region/bound | `admin.region.current` and `admin.region.effective` return `TEST_REGION_ID`/bound |
|
||
| E2E-02 | happy | capture baseline `common.essentialConsts({boundId})` | `products_version_num`, `slots_version_num`, `availability_version_num` numeric |
|
||
| E2E-03 | happy | create a unique store `XYZ Store <suffix>` | `store.id > 0`; `getStoreById` returns it |
|
||
| E2E-04 | happy | create product `XYZ Product <suffix>` with one SKU | `product.id` and `skus[0].id` exist; price/feature `quantity` round-trip |
|
||
| E2E-05 | happy | `admin.product.getProducts` | created product/SKU present in the admin list |
|
||
| E2E-06 | happy | `common.product.getAllProductsSummary` | created SKU present; scoped to staff region |
|
||
| E2E-07 | happy | create a future slot containing the SKU | `slot.products`/SKU ids include it |
|
||
| E2E-08 | happy | `user.slots.getSlots({regionId})` | new slot present, future only |
|
||
| E2E-09 | happy | create address and place one COD order | one order returned; total > 0 |
|
||
| E2E-10 | happy | `user.order.getOrders` | order present; `deliveryStatus: 'pending'`; pagination count > 0 |
|
||
| E2E-11 | happy | `user.order.getOrderById({orderId:'<id>'})` | same order, item and amount |
|
||
| E2E-12 | cache | poll `common.essentialConsts` after product creation | `products_version_num` advances past E2E-02 baseline |
|
||
| E2E-13 | cache | fetch `products.json` at the new version | product by SKU id present; storeId, price, images, tags correct |
|
||
| E2E-14 | cache | fetch `stores.json` | new store present; `productCount` matches |
|
||
| E2E-15 | cache | fetch `stores/<storeId>.json` | `store.id` matches; product present |
|
||
| E2E-16 | cache | fetch `availability.json` | entry keyed by SKU id present; price/flags match |
|
||
| E2E-17 | cache | fetch `slots.json` | new slot present; product id present |
|
||
| E2E-18 | cache | fetch `essential-consts.json` | `boundId`/`regionId` match; version fields numeric |
|
||
| E2E-19 | cache | fetch `banners.json` | file exists and is valid JSON |
|
||
| E2E-20 | cache | all cache files are readable by public URL | no auth header required |
|
||
| E2E-21 | cache | wait timing | poll at least 60s; first 404/old version is tolerated |
|
||
| E2E-22 | edge | product appears in admin list before cache version moves | allowed: admin D1 read is immediate, cache is eventual |
|
||
| E2E-23 | edge | cache version moves but one file 404s | poll that file individually until ready |
|
||
| E2E-24 | edge | product created in region A | region B cache never contains it |
|
||
| E2E-25 | edge | suspended SKU | absent from products/cache but still in admin DB |
|
||
|
||
### 2.2 Order lifecycle golden flow
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| E2E-26 | happy | place two orders in different slots | one order per slot; delivery charged once per order |
|
||
| E2E-27 | happy | admin `getSlotOrders` / `getAll` | both orders visible; first-order flag correct |
|
||
| E2E-28 | happy | admin packaged then delivered | user sees `deliveryStatus: packaged` then `success` |
|
||
| E2E-29 | happy | admin removes delivery charge | user `deliveryCharge` becomes 0 |
|
||
| E2E-30 | happy | admin cancels fresh order | user sees cancelled + reason |
|
||
| E2E-31 | happy | user cancels fresh order | list/detail reflect cancellation |
|
||
| E2E-32 | edge | coupon first-order-only | second order rejects/does not apply |
|
||
| E2E-33 | edge | coupon usage released on cancel | first-order status restored if it was first |
|
||
|
||
### 2.3 Coupon golden flow
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| E2E-34 | happy | admin creates flat coupon | `getById` round-trips |
|
||
| E2E-35 | happy | user `getEligible` | coupon present |
|
||
| E2E-36 | happy | user places order with coupon | `discountAmount` equals expected; `couponCode` set |
|
||
| E2E-37 | happy | admin invalidates coupon | `getEligible` excludes; order with it rejects |
|
||
| E2E-38 | edge | coupon with both discount types | rejected |
|
||
| E2E-39 | edge | coupon code duplicate | rejected |
|
||
| E2E-40 | edge | user-based coupon for another user | never visible |
|
||
|
||
### 2.4 Catalog mutation golden flow
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| E2E-41 | cache | update product name/price | admin list immediate; cache eventually reflects |
|
||
| E2E-42 | cache | update SKU price | `availability.json` bumped synchronously; value updated |
|
||
| E2E-43 | cache | toggle out of stock | availability entry updated synchronously; products file eventually |
|
||
| E2E-44 | cache | update slot | `slots.json` bumped synchronously; new time present |
|
||
| E2E-45 | cache | set slot capacity full | slot removed from public `slots.json` |
|
||
| E2E-46 | cache | create/update/delete banner | `banners.json` eventually reflects |
|
||
| E2E-47 | cache | create/update/delete tag | products.json tag list/order eventually reflects |
|
||
| E2E-48 | cache | update `tagsOrder` region constant | product tag order eventually reflects |
|
||
| E2E-49 | cache | update bound delivery constants | `common.essentialConsts` reflects after KV refresh |
|
||
| E2E-50 | cache | delete store/product | removed from cache after rebuild; historical orders retain data |
|
||
|
||
### 2.5 Upload golden flow
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| E2E-51 | happy | generate upload URL | URL returned; key has correct folder/extension |
|
||
| E2E-52 | happy | PUT bytes to presigned URL | 200; object readable at public assets URL |
|
||
| E2E-53 | edge | same mime type twice in one call | current implementation may share a millisecond key; assert returned URLs/keys if so |
|
||
| E2E-54 | edge | unknown/already claimed key in product create | rejected before DB write |
|
||
| E2E-55 | edge | unknown key in review | logged but review still creates (lenient contract) |
|
||
|
||
---
|
||
|
||
## 3. HTTP routes and authorization matrix
|
||
|
||
### 3.1 REST routes outside tRPC
|
||
|
||
| ID | Type | Request | Assert |
|
||
| --- | --- | --- | --- |
|
||
| HTTP-01 | happy | `GET /api/health` | 200 `{status:'OK', timestamp, uptime, message}` |
|
||
| HTTP-02 | happy | `GET /api/seed` | 200, no auth |
|
||
| HTTP-03 | happy | `GET /api/test/` | 200 `{status:'ok'}` after auth middleware |
|
||
| HTTP-04 | edge | `GET /api/test/` without token | 401 `Authorization token required` |
|
||
| HTTP-05 | edge | `GET /api/health` with invalid token | still 200 (public) |
|
||
| HTTP-06 | happy | `GET /api/v1/cm/products/summary?tagId=<id>` with token | products for tag |
|
||
| HTTP-07 | edge | summary without token | 401 |
|
||
| HTTP-08 | edge | summary `tagId` missing | all products |
|
||
| HTTP-09 | edge | summary `tagId` non-numeric | all products or no filter (current `parseInt` semantics) |
|
||
| HTTP-10 | edge | summary unknown tag | `{products:[],count:0}` |
|
||
| HTTP-11 | happy | summary product fields | id/name/price/marketPrice/unit/quantity/stock/nextDeliveryDate/images |
|
||
| HTTP-12 | edge | summary image keys | signed/public asset URLs |
|
||
| HTTP-13 | edge | unknown `/api/*` | 404 |
|
||
| HTTP-14 | edge | malformed JSON | 400, no crash |
|
||
| HTTP-15 | edge | CORS allowed origin | `Access-Control-Allow-Origin` |
|
||
| HTTP-16 | edge | CORS disallowed origin | not echoed |
|
||
| HTTP-17 | edge | preflight headers | Authorization and Caller-Interface allowed |
|
||
| HTTP-18 | edge | `Caller-Interface: web` cookie login | cookie set |
|
||
| HTTP-19 | edge | cookie-only authenticated request | accepted |
|
||
| HTTP-20 | edge | `Set-Cookie` flags | HttpOnly/Secure/SameSite=Lax/Path=/ |
|
||
|
||
### 3.2 Principal matrix
|
||
|
||
Apply these to every procedure in the groups below. The row is the expected result with no token.
|
||
|
||
| ID | Group | Procedures | Expected |
|
||
| --- | --- | --- | --- |
|
||
| AUTH-01 | public | `common.healthCheck`, `common.listRegions`, `common.checkLocationInPolygon`, `common.resolveRegionByLocation`, `common.resolveBound`, `common.regionSettings`, `common.activeBound`, `common.essentialConsts`, `user.auth.*` public, `admin.staffUser.login`, `superadmin.auth.login` | succeeds without token |
|
||
| AUTH-02 | user protected | every `user.*` protected procedure except public ones | 401 UNAUTHORIZED |
|
||
| AUTH-03 | admin/staff reads | every `admin.*` `protectedProcedure` read | user token may pass (current gap); no token 401; staff passes |
|
||
| AUTH-04 | admin/staff writes | every `admin.*` `protectedProcedure` mutation | user token may pass today (current gap); no token 401; staff passes |
|
||
| AUTH-05 | staff-only | `admin.banner.createBanner`, `admin.product.createProduct`, `admin.product.createGroup`, `admin.product.createProductTag`, `admin.store.createStore`, `admin.staffUser.me`, `admin.staffUser.sendAdminNotification`, every `admin.region.*` | no token/user token/superadmin 401; staff passes |
|
||
| AUTH-06 | authenticated-any | `common.generateUploadUrls` | user, staff and superadmin pass; anonymous 401 |
|
||
| AUTH-07 | superadmin-only | every `superadmin.*` procedure | user/staff 401; superadmin passes |
|
||
| AUTH-08 | cross-principal | staff token on `user.order.getOrders` | rejected |
|
||
| AUTH-09 | cross-principal | user token on `admin.slots.createSlot` | rejected |
|
||
| AUTH-10 | cross-principal | superadmin token on `admin.product.getProducts` | 401/500; no data leak |
|
||
| AUTH-11 | suspended | suspended user on any user endpoint | rejected before resolver |
|
||
| AUTH-12 | expired | expired user/staff/superadmin tokens | 401 |
|
||
| AUTH-13 | forged | token signed with wrong secret | 401 |
|
||
| AUTH-14 | wrong role | user token on `common.getStoresSummary` | 500/error because `ctx.staffUser` absent; assert no data |
|
||
|
||
> The current branch has known `protectedProcedure` gaps on admin reads and several admin writes.
|
||
> Keep those as explicit “current” cases until the guards are changed to `staffProcedure`.
|
||
|
||
### 3.3 Common request-shape edge cases
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| REQ-01 | edge | unknown procedure path | 404/NOT_FOUND |
|
||
| REQ-02 | edge | wrong HTTP verb for mutation | method not supported |
|
||
| REQ-03 | edge | missing required input | BAD_REQUEST with field name |
|
||
| REQ-04 | edge | wrong type (string where number) | BAD_REQUEST |
|
||
| REQ-05 | edge | extra unknown fields | stripped, not written |
|
||
| REQ-06 | edge | `null` for optional field | accepted/rejected per schema |
|
||
| REQ-07 | edge | batch request with one failure | other results still returned; failure isolated |
|
||
| REQ-08 | edge | very large array | bounded by schema (where max exists) |
|
||
| REQ-09 | edge | negative id | zod positive rejection where declared |
|
||
| REQ-10 | edge | float where int expected | BAD_REQUEST |
|
||
| REQ-11 | edge | empty string required field | BAD_REQUEST |
|
||
| REQ-12 | edge | SQL-like search strings | treated as text, no SQL error |
|
||
| REQ-13 | edge | Unicode/emoji names | stored/returned unchanged |
|
||
| REQ-14 | edge | leading/trailing whitespace | trimmed where code trims; assert per procedure |
|
||
| REQ-15 | edge | concurrent identical mutation | both return or one conflict; no duplicate unique key crash |
|
||
|
||
---
|
||
|
||
## 4. Cache contract suite
|
||
|
||
`common.essentialConsts({boundId})` is the source of truth for the version numbers. Cache files are
|
||
public and versioned:
|
||
|
||
```
|
||
products ${assetsDomain}${apiCacheKey}/regions/${regionId}/v-${products_version_num}/products.json
|
||
essential consts ${assetsDomain}${apiCacheKey}/regions/${regionId}/v-${products_version_num}/essential-consts.json
|
||
stores ${assetsDomain}${apiCacheKey}/regions/${regionId}/v-${products_version_num}/stores.json
|
||
store detail ${assetsDomain}${apiCacheKey}/regions/${regionId}/v-${products_version_num}/stores/<storeId>.json
|
||
banners ${assetsDomain}${apiCacheKey}/regions/${regionId}/v-${products_version_num}/banners.json
|
||
slots ${assetsDomain}regions/${regionId}/slots/v-${slots_version_num}/slots.json
|
||
availability ${assetsDomain}regions/${regionId}/av-${availability_version_num}/availability.json
|
||
```
|
||
|
||
### 4.1 Essential constants
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-01 | happy | `common.essentialConsts({boundId})` | `regionId`, `boundId`, `assetsDomain`, `apiCacheKey` present |
|
||
| CACHE-02 | happy | global fields | `versionNum`, `playStoreUrl`, `appStoreUrl`, `internalAppVersion` |
|
||
| CACHE-03 | happy | region fields | `products_version_num`, `availability_version_num`, `slots_version_num`, `popularItems`, `allItemsOrder`, `supportMobile`, `supportEmail`, `welcomeMessage` |
|
||
| CACHE-04 | happy | bound fields | `freeDeliveryThreshold`, `deliveryCharge`, `flashFreeDeliveryThreshold`, `flashDeliveryCharge` |
|
||
| CACHE-05 | happy | flash flag | `isFlashDeliveryEnabled` boolean |
|
||
| CACHE-06 | edge | missing numeric const | fallback 200/0/500/69 per scaffold |
|
||
| CACHE-07 | edge | empty string const | fallback used |
|
||
| CACHE-08 | edge | non-numeric const | fallback used |
|
||
| CACHE-09 | edge | boolean `true` / `1` | true |
|
||
| CACHE-10 | edge | boolean `false` / `0` / other | false |
|
||
| CACHE-11 | edge | missing string const | empty string |
|
||
| CACHE-12 | edge | unknown bound id | 404 `Bound not found` |
|
||
| CACHE-13 | edge | bound from another region | payload uses that bound's region |
|
||
| CACHE-14 | edge | global < region < bound precedence | bound value wins |
|
||
| CACHE-15 | edge | KV miss | payload built from D1 and backfilled |
|
||
| CACHE-16 | edge | KV hit | served without rebuild (observable via changed DB value not yet refreshed) |
|
||
| CACHE-17 | edge | host contains `raw` | `webviewHtml` update notice; `isWebviewClosable:false` |
|
||
| CACHE-18 | edge | host contains `mf` | same update notice |
|
||
| CACHE-19 | edge | normal host | `webviewHtml:null`, closable true |
|
||
| CACHE-20 | edge | region constants update | refreshed KV reflects new support values |
|
||
| CACHE-21 | edge | bound settings update | refreshed KV reflects new threshold/charge |
|
||
| CACHE-22 | edge | global constants update | refreshed KV reflects new version/store URLs |
|
||
| CACHE-23 | edge | missing assets domain/cache key env | payload null/empty; cache tests should fail with actionable message |
|
||
| CACHE-24 | edge | bound deleted and recreated | old KV key removed; new bound does not serve stale payload |
|
||
| CACHE-115 | happy | `essentialUrls` in API + KV | products/stores/banners/essential-consts under the cache key; availability/slots outside it; store template substitutes |
|
||
| CACHE-117 | edge | `updatePrompt` switches | object `{isEnabled, isClosable}`, computed per request (not in the cached payload); `isEnabled:false` suppresses the user-ui update dialog, `isClosable` adds a "Later" dismiss |
|
||
|
||
### 4.2 products.json
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-25 | happy | file exists at current version | valid JSON, `products` array + `count` |
|
||
| CACHE-26 | happy | count | `count === products.length` |
|
||
| CACHE-27 | happy | product fields | id/name/shortDescription/unit/unitNotation/incrementStep/productQuantity/storeId/isOutOfStock/nextDeliveryDate/images/productType/isComboOnly/price/marketPrice/flashPrice/isFlashAvailable |
|
||
| CACHE-28 | edge | image keys | converted to public asset URLs |
|
||
| CACHE-29 | edge | suspended SKU | absent |
|
||
| CACHE-30 | edge | combo-only SKU | present with `isComboOnly:true` (client hides it) |
|
||
| CACHE-31 | edge | out-of-stock SKU | present with flag |
|
||
| CACHE-32 | edge | nextDeliveryDate | latest in-region future/available slot or null |
|
||
| CACHE-33 | edge | price numeric | number, not string/null |
|
||
| CACHE-34 | edge | storeId | number or null |
|
||
| CACHE-35 | edge | tag order | follows `tagsOrder` region constant; unknown tags after |
|
||
| CACHE-36 | edge | tag product order | follows tag `sortOrder`; unknown ids after |
|
||
| CACHE-37 | edge | tag image | signed/public URL |
|
||
| CACHE-38 | edge | tag with no products | `productIds:[]` |
|
||
| CACHE-39 | edge | product not in any tag | still in products array |
|
||
| CACHE-40 | edge | duplicate tag mapping | product id once per tag |
|
||
| CACHE-41 | cache | product create | version increments; new product appears after 30–60s |
|
||
| CACHE-42 | cache | product update | version increments; updated name/price/images appear |
|
||
| CACHE-43 | cache | product delete | version increments; product disappears |
|
||
| CACHE-44 | cache | tag create/update/delete | version increments; tag appears/renames/disappears |
|
||
| CACHE-45 | cache | `tagsOrder` update | version increments; order changes |
|
||
| CACHE-46 | cache | store name update | products file's store-facing data eventually reflects |
|
||
| CACHE-47 | edge | two writes in one debounce window | one rebuild includes both; versions still monotonic |
|
||
| CACHE-48 | edge | global product edit | every region's cache rebuilds (`allRegionsPending`) |
|
||
| CACHE-49 | edge | regional edit while global pending | regional request does not narrow the global rebuild |
|
||
| CACHE-50 | edge | first file 404 after version bump | poll same URL until ready; do not assume atomic |
|
||
|
||
### 4.3 stores.json and store detail
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-51 | happy | stores file | every store: id/name/description/signedImageUrl/productCount/sampleProducts |
|
||
| CACHE-52 | happy | detail file | `store.id`, products, tags |
|
||
| CACHE-53 | edge | productCount | equals detail products length after rebuild |
|
||
| CACHE-54 | edge | sample products | only in-region products; image URLs |
|
||
| CACHE-55 | edge | store with no products | productCount 0 |
|
||
| CACHE-56 | edge | global store | visible without region ownership? assert current |
|
||
| CACHE-57 | edge | store image missing | null |
|
||
| CACHE-58 | cache | create store | `stores.json` + `stores/<id>.json` appear |
|
||
| CACHE-59 | cache | update store | name/description/image update |
|
||
| CACHE-60 | cache | delete store | removed after rebuild |
|
||
| CACHE-61 | edge | detail file can be a later version than captured | resolve current version each poll |
|
||
| CACHE-62 | edge | cross-region store | absent from other region's stores/detail |
|
||
| CACHE-113 | edge | global store with a global product | productCount/samples include global products; count matches detail |
|
||
| CACHE-114 | edge | global store tagged in the region | detail keeps the region-scoped tag |
|
||
|
||
### 4.4 slots.json
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-63 | happy | slots file | valid JSON; count |
|
||
| CACHE-64 | happy | slot fields | id/deliveryTime/freezeTime/products |
|
||
| CACHE-65 | edge | slot delivery past | excluded |
|
||
| CACHE-66 | edge | slot freeze past | excluded |
|
||
| CACHE-67 | edge | capacity full | excluded |
|
||
| CACHE-68 | edge | product images | public URLs |
|
||
| CACHE-69 | edge | productAvailability | present in slots payload |
|
||
| CACHE-70 | cache | create slot | `slots_version_num` increments synchronously; new slot present |
|
||
| CACHE-71 | cache | update slot | version increments; times updated |
|
||
| CACHE-72 | cache | capacity full | version increments; slot removed |
|
||
| CACHE-73 | cache | capacity restored | version increments; slot returns |
|
||
| CACHE-74 | edge | cross-region slot | absent |
|
||
| CACHE-75 | edge | slot with no products | present with empty products |
|
||
| CACHE-76 | edge | unknown group ids | silently normalised to [] |
|
||
|
||
### 4.5 availability.json
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-77 | happy | availability file | array + count |
|
||
| CACHE-78 | happy | entry key | `id` is SKU id, not product id |
|
||
| CACHE-79 | happy | flags | price/marketPrice/flashPrice/isFlashAvailable/isOutOfStock/isOffer/isSuspended |
|
||
| CACHE-80 | cache | toggle product out of stock | version increments synchronously; all SKU entries true |
|
||
| CACHE-81 | cache | toggle one SKU | only that SKU changes; product aggregate matches |
|
||
| CACHE-82 | cache | update price | version increments synchronously; price updates |
|
||
| CACHE-83 | cache | update flash price/flag | version increments; fields update |
|
||
| CACHE-84 | cache | invalid SKU in batch | 400 with invalid ids; assert whether valid rows were written (current path is not guaranteed atomic) |
|
||
| CACHE-85 | edge | suspended SKU | flag true/absent per current implementation |
|
||
| CACHE-86 | edge | missing availability row for product | products merge defaults 0/false; cache consistency may fail |
|
||
| CACHE-87 | edge | cross-region SKU | absent |
|
||
|
||
### 4.6 banners.json and essential-consts.json
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-88 | happy | banners file | `banners` array; active only |
|
||
| CACHE-89 | edge | banner fields | id/name/imageUrl/description/skuIds/redirectUrl/serialNum/isActive |
|
||
| CACHE-90 | edge | skuIds migration | always array |
|
||
| CACHE-91 | cache | create banner | appears after rebuild; initially inactive if create defaults inactive |
|
||
| CACHE-92 | cache | activate/update banner | updated fields appear |
|
||
| CACHE-93 | cache | delete banner | disappears |
|
||
| CACHE-94 | happy | essential-consts file | flat payload; version fields numeric |
|
||
| CACHE-95 | edge | file version matches path | `products_version_num` equals path version |
|
||
| CACHE-96 | edge | essential-consts lag | slots/availability versions may lag live; test only numeric/stable fields |
|
||
| CACHE-97 | edge | bound/region identity | match effective bound used to build |
|
||
| CACHE-98 | edge | webview fields in file | null/closable (file build uses default host) |
|
||
| CACHE-116 | happy | `essentialUrls` in the file | matches the file's own version fields; availability/slots outside the cache key |
|
||
|
||
### 4.7 Cross-file invariants
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CACHE-99 | invariant | every availability SKU maps to a product | 0 orphans after convergence |
|
||
| CACHE-100 | invariant | every slot product maps to a product | 0 orphans after convergence |
|
||
| CACHE-101 | invariant | every store detail productCount matches | all stores |
|
||
| CACHE-102 | invariant | no cross-region product/store/slot ids | 0 leaks |
|
||
| CACHE-103 | invariant | every file is valid JSON | parse all |
|
||
| CACHE-104 | invariant | version counters monotonic | no decrease across writes |
|
||
| CACHE-105 | invariant | cache rebuild non-atomic | tolerate temporary mismatches; poll to convergence |
|
||
| CACHE-106 | invariant | public access | files readable with no Authorization header |
|
||
| CACHE-107 | invariant | cache purge | changed file served after purge/rebuild, not stale CDN copy |
|
||
| CACHE-108 | edge | cache creator global pending | all regions eventually advance |
|
||
| CACHE-109 | edge | cache creator regional pending | only requested region advances |
|
||
| CACHE-110 | edge | no CACHE_CREATOR binding | schedule logs warning; API mutation still succeeds |
|
||
| CACHE-111 | edge | cache upload fails | mutation succeeds; error logged; no partial DB rollback |
|
||
| CACHE-112 | edge | repeated rebuilds | versions strictly increase; no duplicate counters |
|
||
|
||
---
|
||
|
||
## 5. Common router
|
||
|
||
### 5.1 `common.product.getAllProductsSummary`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-01 | happy | staff call | products from staff region only |
|
||
| COMMON-02 | edge | no products | `{products:[],count:0}` |
|
||
| COMMON-03 | edge | suspended SKU | filtered |
|
||
| COMMON-04 | edge | tags ordering | follows region tagsOrder |
|
||
| COMMON-05 | edge | tag product order | follows sortOrder |
|
||
| COMMON-06 | edge | image keys | public URLs |
|
||
| COMMON-07 | edge | user token | current `protectedProcedure` allows call but `ctx.staffUser` may be null → assert current |
|
||
| COMMON-08 | edge | no token | 401 |
|
||
| COMMON-09 | edge | other-region staff | sees only its region |
|
||
| COMMON-10 | edge | product with multiple SKUs | each SKU represented as its own entry |
|
||
|
||
### 5.2 `common.product.getAllSkusSummary`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-11 | happy | staff call | SKU ids/names/price/unit/features |
|
||
| COMMON-12 | edge | empty region | empty array |
|
||
| COMMON-13 | edge | suspended/out-of-stock | present with flags (picker) |
|
||
| COMMON-14 | edge | multi-SKU product | all SKUs |
|
||
| COMMON-15 | edge | region isolation | no foreign SKU |
|
||
| COMMON-16 | edge | no token | 401 |
|
||
| COMMON-17 | edge | global SKU price | uses the caller region’s market row (not 0) |
|
||
| COMMON-18 | edge | global SKU regional suspension | hidden only in the suspending region |
|
||
|
||
### 5.3 `common.getStoresSummary`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-17 | happy | staff call | stores with id/name/product counts |
|
||
| COMMON-18 | edge | empty region | empty |
|
||
| COMMON-19 | edge | user token | current 500/no data; assert no leak |
|
||
| COMMON-20 | edge | no token | 401 |
|
||
| COMMON-21 | edge | cross-region | only own region |
|
||
|
||
### 5.4 `common.checkLocationInPolygon`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-22 | happy | point inside Mahabubnagar polygon | `{isInside:true}` |
|
||
| COMMON-23 | happy | point outside | false |
|
||
| COMMON-24 | edge | boundary point | deterministic true/false |
|
||
| COMMON-25 | edge | lat/lng at limits | accepted where within range |
|
||
| COMMON-26 | edge | lat > 90 / lng > 180 | BAD_REQUEST |
|
||
| COMMON-27 | edge | non-number | BAD_REQUEST |
|
||
| COMMON-28 | edge | (0,0) | false, no crash |
|
||
| COMMON-29 | edge | no token | succeeds (public) |
|
||
|
||
### 5.5 `common.generateUploadUrls`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-30 | happy | review context, png | URL contains `review-images/` and `.png` |
|
||
| COMMON-31 | happy | product_info jpeg | `product-images/`, `.jpg` |
|
||
| COMMON-32 | happy | store png | `store-images/` |
|
||
| COMMON-33 | happy | review_response | `review-response-images/` |
|
||
| COMMON-34 | happy | complaint gif | `complaint-images/`, `.gif` |
|
||
| COMMON-35 | happy | profile | `profile-images/` |
|
||
| COMMON-36 | happy | tags | `tags/` |
|
||
| COMMON-37 | happy | notification | `notification-images/` (common router) |
|
||
| COMMON-38 | edge | empty mimeTypes | `{uploadUrls:[]}` |
|
||
| COMMON-39 | edge | unknown mime | `.jpg` fallback |
|
||
| COMMON-40 | edge | unknown context | BAD_REQUEST |
|
||
| COMMON-41 | edge | user/staff/superadmin token | all allowed by `authenticatedProcedure` |
|
||
| COMMON-42 | edge | no token | 401 |
|
||
| COMMON-43 | error | S3 presign fails | 500 `Failed to generate upload URL` |
|
||
| COMMON-44 | edge | two same mime in one call | assert key collision behavior; do not rely on it |
|
||
| COMMON-45 | edge | pending upload row | one per URL created; claim test in upload suite |
|
||
|
||
### 5.6 `common.healthCheck`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-46 | happy | call | truthy status |
|
||
| COMMON-47 | edge | public | no token |
|
||
| COMMON-48 | error | DB down | error/500 not hang |
|
||
|
||
### 5.7 `common.listRegions`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-49 | happy | call | regions with id/name/description/center/effectiveBoundId |
|
||
| COMMON-50 | edge | no regions | empty array |
|
||
| COMMON-51 | edge | bounds not included/aggregate | assert current shape |
|
||
| COMMON-52 | edge | public | no token |
|
||
|
||
### 5.8 `common.resolveRegionByLocation`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-53 | happy | point inside region/bound | resolves region + lowest-priority containing bound |
|
||
| COMMON-54 | edge | outside every bound | null |
|
||
| COMMON-55 | edge | point inside overlapping bounds | lowest priority number wins |
|
||
| COMMON-56 | edge | invalid lat/lng | BAD_REQUEST |
|
||
| COMMON-57 | edge | boundary | deterministic |
|
||
| COMMON-58 | edge | public | no token |
|
||
|
||
### 5.9 `common.resolveBound`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-59 | happy | point in region bound | `{regionId,boundId}` |
|
||
| COMMON-60 | error | point outside region | 422 |
|
||
| COMMON-61 | error | unknown region | 422/404 |
|
||
| COMMON-62 | edge | overlapping bounds | lowest priority |
|
||
| COMMON-63 | edge | invalid inputs | BAD_REQUEST |
|
||
| COMMON-64 | edge | public | no token |
|
||
|
||
### 5.10 `common.regionSettings` / `common.activeBound`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-65 | happy | regionSettings | effective lowest-priority bound settings |
|
||
| COMMON-66 | error | region with no bound | 422 |
|
||
| COMMON-67 | error | unknown region | 422 |
|
||
| COMMON-68 | edge | activeBound signed out | effective bound |
|
||
| COMMON-69 | edge | activeBound user with address in region | least-priority bound among addresses |
|
||
| COMMON-70 | edge | user with two addresses in same region | lowest priority wins |
|
||
| COMMON-71 | edge | user address in another region only | effective bound, no leak |
|
||
| COMMON-72 | edge | no bound | `boundId:null` |
|
||
| COMMON-73 | edge | invalid region | BAD_REQUEST |
|
||
|
||
### 5.11 `common.essentialConsts`
|
||
|
||
Covered comprehensively by section 4 (CACHE-01..24); add procedure-level cases:
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| COMMON-74 | edge | missing `boundId` input (legacy no-arg call) | falls back to bound 1 / region 1 |
|
||
| COMMON-75 | edge | boundId 0/negative/float | BAD_REQUEST |
|
||
| COMMON-76 | edge | no token | succeeds |
|
||
| COMMON-77 | edge | response shape flat (no nesting) | all keys at root |
|
||
| COMMON-78 | edge | `webviewHtml` only for raw/mf host | assert with `Host` header override |
|
||
|
||
---
|
||
|
||
## 6. User router
|
||
|
||
### 6.1 `user.auth.login`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UAUTH-01 | happy | email + password | token + user payload |
|
||
| UAUTH-02 | happy | mobile + password | token + user |
|
||
| UAUTH-03 | edge | email uppercase | case-insensitive lookup |
|
||
| UAUTH-04 | edge | email with surrounding spaces | current behavior: identifier not trimmed before lookup; assert |
|
||
| UAUTH-05 | edge | mobile with country code | lookup by raw identifier; current behavior |
|
||
| UAUTH-06 | error | unknown identifier | 401 `Invalid credentials` |
|
||
| UAUTH-07 | error | wrong password | 401 |
|
||
| UAUTH-08 | error | missing identifier/password | BAD_REQUEST |
|
||
| UAUTH-09 | error | account without credentials | 401 `Account setup incomplete` |
|
||
| UAUTH-10 | happy | profile image set | signed URL in response |
|
||
| UAUTH-11 | edge | caller-interface web | auth cookie |
|
||
| UAUTH-12 | edge | mobile caller | no cookie |
|
||
| UAUTH-13 | edge | suspended user login | login succeeds; subsequent requests blocked (assert current) |
|
||
| UAUTH-14 | edge | token lifetime/shape | JWT userId claim |
|
||
| UAUTH-15 | edge | no token returned in body? | token present |
|
||
|
||
### 6.2 `user.auth.register`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UREG-01 | happy | valid registration | user + token + persisted profile |
|
||
| UREG-02 | edge | name/email trimmed, email lowercased, mobile digits cleaned | stored normalized |
|
||
| UREG-03 | error | name empty | BAD_REQUEST |
|
||
| UREG-04 | error | invalid email | BAD_REQUEST |
|
||
| UREG-05 | error | duplicate email (case-insensitive) | 409 |
|
||
| UREG-06 | error | mobile not 10 digits / not 6–9 | 400 |
|
||
| UREG-07 | error | duplicate mobile | 409 |
|
||
| UREG-08 | edge | mobile with spaces/dashes | cleaned; duplicate check uses cleaned |
|
||
| UREG-09 | edge | profileImageUrl | signed URL in response |
|
||
| UREG-10 | edge | caller web | cookie |
|
||
| UREG-11 | edge | concurrent same email/mobile | one succeeds, one 409 |
|
||
| UREG-12 | edge | password hash | never returned; login works |
|
||
| UREG-13 | edge | first user has no addresses | default address null |
|
||
|
||
### 6.3 `user.auth.sendOtp` / `verifyOtp`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UOTP-01 | happy | send OTP valid mobile | success/message; OTP stored |
|
||
| UOTP-02 | edge | invalid mobile | current OTP util behavior; assert |
|
||
| UOTP-03 | edge | throttle/rapid resend | assert current (no throttle or provider response) |
|
||
| UOTP-04 | edge | verify without send | 400 `OTP not sent or expired` |
|
||
| UOTP-05 | edge | wrong OTP | 400 `Invalid OTP` |
|
||
| UOTP-06 | edge | expired OTP | 400 |
|
||
| UOTP-07 | happy | verify existing user | token + user |
|
||
| UOTP-08 | happy | verify new mobile | creates user + token |
|
||
| UOTP-09 | edge | verify consumes OTP | second verify fails/current |
|
||
| UOTP-10 | edge | web caller | cookie |
|
||
| UOTP-11 | edge | response token duplicated? | assert current shape has token |
|
||
| UOTP-12 | edge | malformed mobile/otp | BAD_REQUEST/provider error |
|
||
|
||
### 6.4 `user.auth.updatePassword`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UPASS-01 | happy | new password ≥6 | success; old password fails; new works |
|
||
| UPASS-02 | error | <6 | BAD_REQUEST |
|
||
| UPASS-03 | edge | no token | 401 |
|
||
| UPASS-04 | edge | account with no password | row inserted; login works |
|
||
| UPASS-05 | edge | repeated update | latest wins |
|
||
| UPASS-06 | edge | staff token | rejected/500 no user |
|
||
|
||
### 6.5 `user.auth.updateProfile`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UPROF-01 | happy | name/email/mobile | updated; response reflects |
|
||
| UPROF-02 | edge | empty email | leaves email unchanged |
|
||
| UPROF-03 | edge | invalid email | 400 |
|
||
| UPROF-04 | edge | duplicate email | 409 |
|
||
| UPROF-05 | edge | invalid/duplicate mobile | 400/409 |
|
||
| UPROF-06 | edge | password | hashed; login with new password |
|
||
| UPROF-07 | edge | bio/dateOfBirth/gender/occupation | round-trip |
|
||
| UPROF-08 | edge | profileImageUrl | signed URL |
|
||
| UPROF-09 | edge | partial update | omitted fields unchanged |
|
||
| UPROF-10 | edge | no token | 401 |
|
||
| UPROF-11 | edge | other user's email/mobile | 409, no takeover |
|
||
| UPROF-12 | edge | invalid dateOfBirth | current behavior; assert |
|
||
| UPROF-13 | edge | response token | same bearer token returned |
|
||
|
||
### 6.6 `user.auth.deleteAccount`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UDEL-01 | happy | matching mobile | success; user cannot login; data removed |
|
||
| UDEL-02 | error | wrong mobile | 400 |
|
||
| UDEL-03 | edge | formatting differences | cleaned digits match |
|
||
| UDEL-04 | error | mobile <10 | BAD_REQUEST |
|
||
| UDEL-05 | error | no token | 401 |
|
||
| UDEL-06 | error | nonexistent user token | 404 |
|
||
| UDEL-07 | edge | other user's mobile | 400 |
|
||
| UDEL-08 | edge | address/order/complaint/review cleanup | assert no orphan/cascade per schema |
|
||
| UDEL-09 | edge | token after deletion | any request fails/expired identity |
|
||
|
||
### 6.7 Address API
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UADDR-01 | happy | create first address | success; `isDefault:true` |
|
||
| UADDR-02 | happy | second address non-default | stays false |
|
||
| UADDR-03 | edge | explicit default | unsets previous |
|
||
| UADDR-04 | edge | phone regex valid 6–9 | accepted |
|
||
| UADDR-05 | error | phone invalid | BAD_REQUEST |
|
||
| UADDR-06 | edge | coords inside bound | boundId derived |
|
||
| UADDR-07 | edge | no coords | effective bound fallback |
|
||
| UADDR-08 | error | coords outside region | 422 |
|
||
| UADDR-09 | edge | googleMapsUrl fallback | coords extracted |
|
||
| UADDR-10 | edge | malformed googleMapsUrl | no coords → effective bound or 422; assert |
|
||
| UADDR-11 | edge | region required | BAD_REQUEST |
|
||
| UADDR-12 | edge | optional line2 | round-trip |
|
||
| UADDR-13 | edge | user isolation | other user cannot read/update/delete |
|
||
| UADDR-14 | happy | getDefaultAddress | default or null |
|
||
| UADDR-15 | happy | getUserAddresses | own only, ordered as DB |
|
||
| UADDR-16 | happy | update all fields | round-trip |
|
||
| UADDR-17 | edge | update without isDefault | preserves |
|
||
| UADDR-18 | edge | update to default | unsets old |
|
||
| UADDR-19 | edge | update coords | backfilled flag cleared |
|
||
| UADDR-20 | edge | update moves region | region/bound updated; user-region reconciled |
|
||
| UADDR-21 | error | update other user's address | not found |
|
||
| UADDR-22 | error | update missing | not found |
|
||
| UADDR-23 | error | delete only address | 409 |
|
||
| UADDR-24 | error | delete default | 409 |
|
||
| UADDR-25 | error | delete address with ongoing order | 409 |
|
||
| UADDR-26 | happy | delete non-default with another address | success |
|
||
| UADDR-27 | error | delete other user's | 404 |
|
||
| UADDR-28 | edge | delete triggers region/token reconcile | token region follows remaining address |
|
||
| UADDR-29 | edge | no token | 401 |
|
||
| UADDR-30 | edge | invalid id/region | BAD_REQUEST |
|
||
|
||
### 6.8 Cart slots
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UCART-01 | happy | one product with slots | map productId → slots |
|
||
| UCART-02 | edge | empty productIds | `{}` |
|
||
| UCART-03 | edge | unknown SKU | `[]` |
|
||
| UCART-04 | edge | SKU from another region | `[]` |
|
||
| UCART-05 | edge | region required | BAD_REQUEST |
|
||
| UCART-06 | edge | past/full slots | filtered by slot store |
|
||
| UCART-07 | edge | global SKU | served in requested region |
|
||
| UCART-08 | edge | no token | public |
|
||
|
||
### 6.9 Complaints
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UCOMP-01 | happy | raise without order | success; own list contains |
|
||
| UCOMP-02 | happy | raise with numeric order id | linked |
|
||
| UCOMP-03 | edge | `ORD123` / `ORD-123` | linked |
|
||
| UCOMP-04 | edge | invalid order string | saved with null orderId |
|
||
| UCOMP-05 | error | empty body | BAD_REQUEST |
|
||
| UCOMP-06 | edge | body trimmed | stored trimmed |
|
||
| UCOMP-07 | happy | images | URLs stored/returned signed |
|
||
| UCOMP-08 | happy | getAll | own only |
|
||
| UCOMP-09 | edge | another user cannot see | isolation |
|
||
| UCOMP-10 | edge | cross-user order id | current behavior: no ownership check; assert gap |
|
||
| UCOMP-11 | edge | no token | 401 |
|
||
|
||
### 6.10 User coupons
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UCOUP-01 | happy | getEligible | visible coupons + `isFirstOrder` |
|
||
| UCOUP-02 | edge | expired | excluded |
|
||
| UCOUP-03 | edge | invalidated | excluded |
|
||
| UCOUP-04 | edge | usage limit reached | excluded |
|
||
| UCOUP-05 | edge | other user's personal coupon | excluded |
|
||
| UCOUP-06 | edge | min-order/region ineligible | still returned for client disabled state |
|
||
| UCOUP-07 | edge | first-order-only non-first | current `getEligible` still returns? assert current |
|
||
| UCOUP-08 | happy | getMyCoupons | personal/general split |
|
||
| UCOUP-09 | edge | first-order-only non-first | filtered |
|
||
| UCOUP-10 | edge | expired/invalidated | filtered |
|
||
| UCOUP-11 | edge | used-up | included with `isUsedUp:true`? assert current |
|
||
| UCOUP-12 | edge | region input | filter applies? assert current |
|
||
| UCOUP-13 | happy | redeem valid secret | success; coupon appears |
|
||
| UCOUP-14 | error | unknown code | 400 |
|
||
| UCOUP-15 | error | expired secret | 400 |
|
||
| UCOUP-16 | error | already redeemed by same user | 400 |
|
||
| UCOUP-17 | error | first-order-only and user has order | 400 |
|
||
| UCOUP-18 | edge | race two users redeem same secret | one success, one 400 |
|
||
| UCOUP-19 | edge | no token | 401 |
|
||
| UCOUP-20 | edge | secret case | lookup as supplied? assert current |
|
||
| UCOUP-21 | error | coupon-code collision on redeem | redemption fails; reserved coupon stays unredeemed |
|
||
|
||
### 6.11 `user.order.placeOrder`
|
||
|
||
All calls require `regionId`. A test helper should always pass it; the old suite’s omission is a
|
||
known stale-test bug.
|
||
|
||
#### Guards and input validation
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UORD-01 | happy | one SKU/one slot/COD | one order; total >0; items persisted |
|
||
| UORD-02 | error | no token | 401 |
|
||
| UORD-03 | error | suspended user | rejected before order; current context may surface 401 instead of the handler’s 403 `Unable to place order` — assert the actual contract |
|
||
| UORD-04 | error | empty `selectedItems` | current raw DB/validation error; assert not success |
|
||
| UORD-05 | error | quantity 0 | BAD_REQUEST |
|
||
| UORD-06 | error | negative quantity | BAD_REQUEST |
|
||
| UORD-07 | edge | huge quantity (1e9) | current cap absent; assert current or add cap |
|
||
| UORD-08 | error | unknown SKU | `not found` rejection |
|
||
| UORD-09 | error | SKU from another region | rejection / not found |
|
||
| UORD-10 | error | suspended SKU | rejection |
|
||
| UORD-11 | error | out-of-stock SKU | rejection |
|
||
| UORD-12 | error | address id missing | `Invalid address` |
|
||
| UORD-13 | error | address belongs to another user | `Invalid address` |
|
||
| UORD-14 | edge | address coords outside region | region resolution rejects or falls back; assert current |
|
||
| UORD-15 | edge | client `regionId` differs from address coords region | address coords win |
|
||
| UORD-16 | edge | address has no coords but stored region | stored region used |
|
||
| UORD-17 | edge | boundId supplied vs derived | address bound wins or validates; assert |
|
||
| UORD-18 | error | regionId missing | BAD_REQUEST |
|
||
| UORD-19 | error | invalid regionId | BAD_REQUEST |
|
||
| UORD-20 | error | regular item with null slotId | rejection |
|
||
| UORD-21 | error | regular item slot from another region | rejection |
|
||
| UORD-22 | error | regular item slot not offered for SKU | rejection |
|
||
| UORD-23 | error | regular item slot freeze passed | rejection |
|
||
| UORD-24 | error | regular item slot capacity full | 403 capacity |
|
||
| UORD-25 | edge | two items same slot | one order |
|
||
| UORD-26 | edge | two items different slots | one order per slot, delivery charged once each |
|
||
| UORD-27 | edge | flash order with slot ids | slot ids ignored/null |
|
||
| UORD-28 | edge | flash disabled | 403 |
|
||
| UORD-29 | edge | flash enabled + eligible SKU | order with `isFlashDelivery:true`, null slot |
|
||
| UORD-30 | edge | flash enabled + ineligible SKU | rejection |
|
||
| UORD-31 | edge | flash out-of-stock | rejection |
|
||
| UORD-32 | edge | combo product | combo line/price accepted |
|
||
| UORD-33 | edge | combo-only SKU direct order | assert accepted/rejected per stock rules |
|
||
| UORD-34 | edge | duplicate same SKU lines | merged or separate per current; amount correct |
|
||
| UORD-35 | edge | two slots with same SKU | separate orders, quantities correct |
|
||
| UORD-36 | edge | userNotes | persisted |
|
||
| UORD-37 | edge | long notes | accepted (no max declared) |
|
||
| UORD-38 | edge | special chars/emoji notes | round-trip |
|
||
| UORD-39 | edge | no coupons | no coupon usage rows |
|
||
| UORD-40 | edge | one coupon | applied |
|
||
| UORD-41 | edge | multiple coupons | sequential stack |
|
||
| UORD-42 | edge | coupon from another region | rejected/not applied |
|
||
| UORD-43 | edge | coupon owned by another user | rejected |
|
||
| UORD-44 | edge | invalidated/expired coupon | rejected |
|
||
| UORD-45 | edge | usage-limit coupon | rejected |
|
||
| UORD-45B | edge | coupon with 2 permitted usages | two orders store the coupon; usageCount is 2; third order rejects with usage limit exceeded |
|
||
| UORD-46 | edge | min-order not met | rejected/not applied |
|
||
| UORD-47 | edge | targeted SKU coupon | discount only target |
|
||
| UORD-47B | edge | targeted SKU coupon, target below minOrder but whole cart above it | accepted; discount only on target |
|
||
| UORD-48 | edge | first-order-only | first works, second rejects |
|
||
| UORD-49 | edge | exclusive coupon + another | reject or exclusive wins per contract |
|
||
| UORD-50 | edge | 100%+ percentage coupon | total never negative; delivery still correct |
|
||
| UORD-51 | edge | flat discount > goods | capped at goods |
|
||
| UORD-52 | edge | fractional percentage | whole-rupee rounding |
|
||
| UORD-53 | edge | delivery threshold after discount | delivery re-added |
|
||
| UORD-54 | edge | flash threshold/charge | flash values used |
|
||
| UORD-55 | edge | user coupon usage row | created with order/order group |
|
||
| UORD-56 | edge | first-order flag | cleared/updated |
|
||
| UORD-57 | edge | double-submit same payload | current no idempotency; assert two orders or add key |
|
||
| UORD-58 | edge | two concurrent placeOrder | both persisted; no shared state corruption |
|
||
| UORD-59 | edge | order publish/queue | queue failure does not roll back order; logged |
|
||
| UORD-60 | edge | order grouping id | same `orderGroupId` across split orders |
|
||
| UORD-61 | edge | order visibility | immediately in getOrders/getOrderById |
|
||
| UORD-62 | edge | order region/cache | appears in region's order queries only |
|
||
| UORD-63 | edge | address region/permission | cannot use address outside user |
|
||
| UORD-64 | edge | no address at all | 400 |
|
||
| UORD-65 | edge | stock changes between validation and write | transaction/stock check rejects |
|
||
| UORD-66 | edge | slot capacity changes between validation and write | rejects or one succeeds |
|
||
| UORD-67 | edge | price changes between quote and write | server price wins |
|
||
| UORD-68 | edge | `isCod`/payment fields removed | payload only COD contract; no online path |
|
||
| UORD-69 | edge | malformed selectedItems | BAD_REQUEST |
|
||
| UORD-70 | edge | address with only one coordinate | current behavior; assert |
|
||
|
||
#### Reads and lifecycle
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UORD-71 | happy | getOrders defaults | page 1/pageSize 10 |
|
||
| UORD-72 | edge | pagination page 2 | different orders; no overlap |
|
||
| UORD-73 | error | pageSize 51 | BAD_REQUEST |
|
||
| UORD-74 | error | page 0 | BAD_REQUEST |
|
||
| UORD-75 | edge | no orders | data [], totalCount 0, totalPages 0 |
|
||
| UORD-76 | edge | pending status | deliveryStatus pending; orderStatus success |
|
||
| UORD-77 | edge | all items packaged | deliveryStatus packaged |
|
||
| UORD-78 | edge | delivered | deliveryStatus success |
|
||
| UORD-79 | edge | cancelled | both cancelled; cancelReason |
|
||
| UORD-80 | edge | mixed item packaging | pending until all packaged |
|
||
| UORD-81 | edge | order item fields | name/skuName/quantity/unit/price/discountedPrice/amount/image |
|
||
| UORD-82 | edge | order list user isolation | only own orders |
|
||
| UORD-83 | edge | region fields | regionId/regionName from order region |
|
||
| UORD-84 | edge | flash flag/date | isFlashDelivery |
|
||
| UORD-85 | happy | getOrderById numeric string | detail matches |
|
||
| UORD-86 | error | `ORD123`/`ORD-123` | parseInt behavior; assert current (likely 500 not found) |
|
||
| UORD-87 | error | unknown id | not found |
|
||
| UORD-88 | error | another user's order | not found |
|
||
| UORD-89 | edge | detail coupon | couponCode/list, discountAmount from stored order |
|
||
| UORD-90 | edge | detail totals | orderAmount/totalAmount/deliveryCharge |
|
||
| UORD-91 | edge | detail cancellation | cancelReason |
|
||
| UORD-92 | edge | detail flash | isFlashDelivery |
|
||
| UORD-93 | happy | update notes pending | persisted |
|
||
| UORD-94 | error | update notes delivered | 400 |
|
||
| UORD-95 | error | update notes cancelled | 400 |
|
||
| UORD-96 | error | update notes other user's order | not found |
|
||
| UORD-97 | edge | empty notes | accepted (string no min) |
|
||
| UORD-98 | happy | cancel pending own order | success; status cancelled; reason |
|
||
| UORD-99 | error | cancel without/blank reason | BAD_REQUEST |
|
||
| UORD-100 | error | cancel missing order | 404/generic |
|
||
| UORD-101 | error | cancel another user's order | generic 500 `failed to cancel order` current |
|
||
| UORD-102 | error | cancel already cancelled | 400/generic current |
|
||
| UORD-103 | error | cancel delivered | 400/generic current |
|
||
| UORD-104 | edge | cancel releases coupon usage | coupon usable again if applicable |
|
||
| UORD-105 | edge | cancel clears first-order | first-order-only available again |
|
||
| UORD-106 | edge | cancel publishes cancellation | queue/publish called; failure logged |
|
||
| UORD-107 | edge | double cancel race | one success/one failure, no corrupt status |
|
||
| UORD-108 | edge | order with orderGroup | cancellation updates group/status consistently |
|
||
| UORD-108B | edge | grouped order with a usage-capped coupon; cancel siblings one by one | coupon stays exhausted until the last sibling is cancelled, then becomes reusable |
|
||
|
||
### 6.12 User product API
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UPROD-01 | happy | getProductDetails numeric id + region | product detail |
|
||
| UPROD-02 | error | non-numeric id | BAD_REQUEST regex |
|
||
| UPROD-03 | error | region missing | BAD_REQUEST |
|
||
| UPROD-04 | error | unknown product | not found |
|
||
| UPROD-05 | error | product owned by another region | not found |
|
||
| UPROD-06 | edge | global SKU | served in requested region |
|
||
| UPROD-07 | edge | cache hit | slots filtered to future/non-full |
|
||
| UPROD-08 | edge | cache miss | DB fallback with signed images |
|
||
| UPROD-09 | edge | no slots | empty deliverySlots |
|
||
| UPROD-10 | edge | combo items/special deals/store | present per fixture |
|
||
| UPROD-11 | happy | reviews pagination | limit/offset/hasMore |
|
||
| UPROD-12 | error | limit 0/51 | BAD_REQUEST |
|
||
| UPROD-13 | error | offset negative | BAD_REQUEST |
|
||
| UPROD-14 | edge | no reviews | [] hasMore false |
|
||
| UPROD-15 | happy | create review | success; visible in list |
|
||
| UPROD-16 | error | rating 0/6 | BAD_REQUEST |
|
||
| UPROD-17 | error | empty body | BAD_REQUEST |
|
||
| UPROD-18 | error | unknown product | 404 |
|
||
| UPROD-19 | edge | upload URLs/images | stored; signed URLs returned |
|
||
| UPROD-20 | edge | unknown upload URL | logged, review still created (lenient) |
|
||
| UPROD-21 | edge | no token create review | 401 |
|
||
| UPROD-22 | edge | one review per user? | assert current (multiple allowed or rejected) |
|
||
| UPROD-23 | edge | review images | signed |
|
||
| UPROD-24 | edge | XSS string | stored/escaped, not executed |
|
||
|
||
### 6.13 User slots
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| USLOT-01 | happy | getSlots region | future, non-full only |
|
||
| USLOT-02 | edge | past delivery | excluded |
|
||
| USLOT-03 | edge | past freeze | excluded |
|
||
| USLOT-04 | edge | capacity full | excluded |
|
||
| USLOT-05 | edge | unknown region | empty |
|
||
| USLOT-06 | error | region missing | BAD_REQUEST |
|
||
| USLOT-07 | edge | cross-region | no leak |
|
||
| USLOT-08 | edge | no slots | count 0 |
|
||
| USLOT-09 | edge | public | no token |
|
||
| USLOT-10 | edge | products | id + images only |
|
||
|
||
### 6.14 User profile / push token
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UUSER-01 | happy | getSelfData | id/name/email/mobile/profile fields |
|
||
| UUSER-02 | edge | profile image | signed URL |
|
||
| UUSER-03 | edge | missing detail row | nulls, no crash |
|
||
| UUSER-04 | error | deleted user token | 404 |
|
||
| UUSER-05 | error | no token | 401 |
|
||
| UUSER-06 | happy | savePushToken authenticated | token stored; region from address |
|
||
| UUSER-07 | edge | authenticated, no address, region supplied | supplied region used |
|
||
| UUSER-08 | edge | authenticated, no address/no region, prior unlogged token | prior region carried |
|
||
| UUSER-09 | edge | notif_creds region column failure | token still stored without region |
|
||
| UUSER-10 | happy | savePushToken unauthenticated | unlogged token stored |
|
||
| UUSER-11 | edge | unlogged token with region | region stored |
|
||
| UUSER-12 | edge | re-save token | upsert, no duplicate |
|
||
| UUSER-13 | edge | address region wins over browser region | token follows address |
|
||
| UUSER-14 | happy | recordTrackedRegion | success; association inserted/updated |
|
||
| UUSER-15 | error | region invalid/missing | BAD_REQUEST |
|
||
| UUSER-16 | edge | no token record | 401 |
|
||
| UUSER-17 | edge | location association does not move token | current rule |
|
||
|
||
### 6.15 User file upload
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UUP-01 | happy | review jpeg | URL/key |
|
||
| UUP-02 | happy | product_info png | folder/extension |
|
||
| UUP-03 | happy | notification/tags/profile/complaint | folders |
|
||
| UUP-04 | edge | empty mimeTypes | [] |
|
||
| UUP-05 | edge | unknown mime | `.jpg` |
|
||
| UUP-06 | error | invalid context | BAD_REQUEST |
|
||
| UUP-07 | error | no token | 401 |
|
||
| UUP-08 | error | S3 failure | 500 |
|
||
| UUP-09 | edge | `review_response` context | current enum excludes it here; assert BAD_REQUEST if used |
|
||
| UUP-10 | edge | one pending row per URL | pending status exists |
|
||
|
||
### 6.16 User complaint API
|
||
|
||
Covered by UCOMP-01..11. Add admin-side cases in section 7.
|
||
|
||
---
|
||
|
||
## 7. Admin router
|
||
|
||
### 7.1 `admin.staffUser` — login/identity
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ASTAFF-01 | happy | staff login | token + staff id/name/regionId |
|
||
| ASTAFF-02 | error | unknown name | 401 invalid credentials |
|
||
| ASTAFF-03 | error | wrong password | 401 |
|
||
| ASTAFF-04 | error | missing fields | 400 |
|
||
| ASTAFF-05 | happy | `me` | id/name/regionId/regionName |
|
||
| ASTAFF-06 | error | `me` no token | 401 |
|
||
| ASTAFF-07 | edge | `me` user token | rejected/500 no staff |
|
||
| ASTAFF-08 | happy | getStaff | staff list; role/permissions |
|
||
| ASTAFF-09 | edge | user token getStaff | current protected read allows; assert gap |
|
||
| ASTAFF-10 | happy | getRoles | roles list |
|
||
| ASTAFF-11 | happy | createStaffUser | staff created; login works |
|
||
| ASTAFF-12 | error | duplicate name | 409 |
|
||
| ASTAFF-13 | error | password <6 | BAD_REQUEST |
|
||
| ASTAFF-14 | error | invalid role | 400 |
|
||
| ASTAFF-15 | edge | createStaffUser region id? | current derives staff region; assert |
|
||
| ASTAFF-16 | happy | savePushToken | stored |
|
||
| ASTAFF-17 | error | no staff | 401 |
|
||
| ASTAFF-18 | happy | sendAdminNotification | queued count/message |
|
||
| ASTAFF-19 | error | empty title/text | BAD_REQUEST |
|
||
| ASTAFF-20 | edge | no admins with tokens | queued 0, success |
|
||
| ASTAFF-21 | edge | queue push fails | logged; success? assert current |
|
||
| ASTAFF-22 | edge | user token on sendAdminNotification | rejected |
|
||
|
||
### 7.2 `admin.banner`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ABAN-01 | happy | getBanners empty | [] |
|
||
| ABAN-02 | happy | getBanners populated | only staff region; skuIds array; image URL |
|
||
| ABAN-03 | edge | no image | imageUrl null |
|
||
| ABAN-04 | happy | getBanner | by id |
|
||
| ABAN-05 | error | unknown banner | null? assert current returns null |
|
||
| ABAN-06 | error | other-region banner | null |
|
||
| ABAN-07 | happy | createBanner | banner created inactive, serial 999, skuIds default [] |
|
||
| ABAN-08 | error | name empty | BAD_REQUEST |
|
||
| ABAN-09 | error | invalid image URL | BAD_REQUEST |
|
||
| ABAN-10 | edge | no image | imageUrl required in schema; assert |
|
||
| ABAN-11 | edge | redirectUrl invalid | BAD_REQUEST |
|
||
| ABAN-12 | edge | URL key extraction | stored object key |
|
||
| ABAN-13 | edge | send notification? | create does not notify; assert |
|
||
| ABAN-14 | happy | update name/active/serial/skuIds | round-trip |
|
||
| ABAN-15 | edge | update image replaces key | old key deletion? assert current |
|
||
| ABAN-16 | edge | update serial null | null accepted |
|
||
| ABAN-17 | error | update unknown | 404 |
|
||
| ABAN-18 | happy | delete | success; getBanner null |
|
||
| ABAN-19 | error | delete unknown | 404 |
|
||
| ABAN-20 | edge | user token write | current protected gap; assert |
|
||
| ABAN-21 | cache | create/update/delete | schedule cache; banners.json eventually |
|
||
|
||
### 7.3 `admin.complaint`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ACOMP-01 | happy | getAll | complaints for staff region |
|
||
| ACOMP-02 | edge | pagination cursor/limit | nextCursor |
|
||
| ACOMP-03 | edge | empty | [] |
|
||
| ACOMP-04 | edge | status mapping | resolved/pending |
|
||
| ACOMP-05 | edge | images signed | |
|
||
| ACOMP-06 | happy | resolve | response stored; status resolved |
|
||
| ACOMP-07 | error | unknown id | not found |
|
||
| ACOMP-08 | error | empty response | BAD_REQUEST |
|
||
| ACOMP-09 | edge | response trimmed | stored trimmed |
|
||
| ACOMP-10 | edge | user notified | queue called; no tokens tolerated |
|
||
| ACOMP-11 | edge | other-region complaint | not found |
|
||
| ACOMP-12 | edge | user token | current protected gap; assert |
|
||
|
||
### 7.4 `admin.product`
|
||
|
||
#### Reads
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| APROD-01 | happy | getProducts | all products/SKUs in region |
|
||
| APROD-02 | edge | empty | [] |
|
||
| APROD-03 | edge | image signing | SKU images public URLs |
|
||
| APROD-04 | edge | suspended/deleted | current inclusion |
|
||
| APROD-05 | happy | getProductById | product + skus |
|
||
| APROD-06 | error | unknown | 404 |
|
||
| APROD-07 | error | other region | 404 |
|
||
| APROD-08 | edge | user token read | current gap |
|
||
| APROD-09 | happy | getProductReviews | limit/offset/hasMore |
|
||
| APROD-10 | error | limit 0/51 | BAD_REQUEST |
|
||
| APROD-11 | edge | no reviews | [] |
|
||
| APROD-12 | edge | signed image arrays | |
|
||
| APROD-13 | happy | getGroups | groups with SKUs |
|
||
| APROD-14 | happy | getProductTags | tags + message |
|
||
| APROD-15 | happy | getProductTagById | tag/products/productIds |
|
||
| APROD-16 | error | unknown tag | 404 |
|
||
|
||
#### Create/update/delete
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| APROD-17 | happy | create product | product/SKU IDs; feature quantity; images |
|
||
| APROD-18 | error | duplicate name | 400 |
|
||
| APROD-19 | error | name empty | BAD_REQUEST |
|
||
| APROD-20 | error | storeId 0/missing | BAD_REQUEST |
|
||
| APROD-21 | error | no SKUs | BAD_REQUEST |
|
||
| APROD-22 | error | price 0/negative | BAD_REQUEST |
|
||
| APROD-23 | error | no feature | BAD_REQUEST |
|
||
| APROD-24 | error | feature value empty | BAD_REQUEST |
|
||
| APROD-25 | edge | multiple SKUs | all created |
|
||
| APROD-26 | edge | combo type + combo items | stored |
|
||
| APROD-27 | edge | flash fields | stored |
|
||
| APROD-28 | edge | marketPrice null | stored null |
|
||
| APROD-29 | edge | image upload URLs | keys stored/claim |
|
||
| APROD-30 | error | fabricated/reused image key | rejected before write |
|
||
| APROD-31 | edge | no images | [] |
|
||
| APROD-32 | edge | duplicate SKU names? | assert current |
|
||
| APROD-33 | cache | create schedule | products version eventually |
|
||
| APROD-34 | happy | update product | fields/SKUs update |
|
||
| APROD-35 | error | update unknown | 404 |
|
||
| APROD-36 | error | update name empty/price invalid | BAD_REQUEST |
|
||
| APROD-37 | edge | update SKU id omitted | create new/current semantics |
|
||
| APROD-38 | edge | deleting images | deletedImageKeys removed after update |
|
||
| APROD-39 | edge | new image URL validation | claim before delete |
|
||
| APROD-40 | edge | current image re-sent | not treated as new |
|
||
| APROD-41 | edge | regional suspension | stored in product_market_stats.is_suspended_in_region |
|
||
| APROD-42 | cache | update schedule | eventually |
|
||
| APROD-43 | error | delete product with SKUs | current FK/raw failure; assert rejection |
|
||
| APROD-44 | error | delete unknown | 404 |
|
||
| APROD-45 | edge | delete image cleanup | best-effort |
|
||
| APROD-46 | happy | toggle whole product out of stock | all SKUs flip; availability sync |
|
||
| APROD-47 | happy | toggle specific SKUs | only those flip; ignored IDs 400 |
|
||
| APROD-48 | edge | skuIds without isOutOfStock | 400 |
|
||
| APROD-49 | edge | partial variants | product aggregate/partial message |
|
||
| APROD-50 | error | unknown product/SKU | 404/400 |
|
||
| APROD-51 | happy | update prices | updatedCount/message |
|
||
| APROD-52 | error | empty updates | 400 |
|
||
| APROD-53 | error | invalid SKU id | 400 with ids |
|
||
| APROD-54 | error | no price fields | 400 |
|
||
| APROD-55 | cache | price update | availability version sync |
|
||
| APROD-56 | happy | create group | group returned |
|
||
| APROD-57 | happy | update group | name/description/products |
|
||
| APROD-58 | error | update unknown group | 404 |
|
||
| APROD-59 | happy | delete group | success |
|
||
| APROD-60 | error | delete unknown group | 404 |
|
||
| APROD-61 | happy | create tag | tag + product mapping |
|
||
| APROD-62 | error | duplicate tag name | 400 |
|
||
| APROD-63 | error | empty tag name | BAD_REQUEST |
|
||
| APROD-64 | edge | tag image URL | normalized/signed |
|
||
| APROD-65 | edge | relatedStores/productIds | stored/mapped |
|
||
| APROD-66 | edge | upload URL validation | before tag write |
|
||
| APROD-67 | happy | update tag | rename/image/products |
|
||
| APROD-68 | error | update unknown | 404 |
|
||
| APROD-69 | edge | image replacement cleanup | old image deleted best-effort |
|
||
| APROD-70 | happy | delete tag | success; image cleanup best-effort |
|
||
| APROD-71 | error | delete unknown | 404 |
|
||
| APROD-72 | cache | tag writes | products version eventually |
|
||
| APROD-73 | happy | respond to review | response/images stored |
|
||
| APROD-74 | error | unknown review | 404 |
|
||
| APROD-75 | edge | empty response/images | accepted? assert |
|
||
| APROD-76 | edge | upload URLs claim | validated/claimed |
|
||
| APROD-77 | edge | user token write | current gap |
|
||
| APROD-78 | happy | regional admin edits a global product | market data only |
|
||
| APROD-79 | error | regional admin changes global structure | 403, rejected fields named |
|
||
| APROD-80 | error | regional admin deletes a global image | 403; image key kept |
|
||
| APROD-81 | error | regional update sets the structural isSuspended | global flag untouched |
|
||
| APROD-82 | edge | regional create with isSuspended | region flag set; global false |
|
||
|
||
### 7.5 `admin.order`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| AORD-01 | happy | getAll default | 20 orders; nextCursor |
|
||
| AORD-02 | edge | pagination | no overlap |
|
||
| AORD-03 | edge | filters packaged/delivered/cancelled/flash | each applied |
|
||
| AORD-04 | edge | slotId filter | only slot |
|
||
| AORD-05 | error | limit invalid? schema default only, no max | assert current |
|
||
| AORD-06 | edge | empty | []/undefined on error |
|
||
| AORD-07 | happy | getOrderDetails | full detail |
|
||
| AORD-08 | error | unknown | `Order not found` |
|
||
| AORD-09 | error | other region | not found |
|
||
| AORD-10 | happy | updateNotes | stored |
|
||
| AORD-11 | error | unknown | error |
|
||
| AORD-12 | edge | empty notes | stored null |
|
||
| AORD-13 | happy | updatePackaged true/false | status; user notification |
|
||
| AORD-14 | error | unknown order | 404 |
|
||
| AORD-15 | edge | string orderId | schema requires string |
|
||
| AORD-16 | happy | updateDelivered true/false | user status success/pending |
|
||
| AORD-17 | error | unknown | 404 |
|
||
| AORD-18 | happy | updateOrderItemPackaging | flags |
|
||
| AORD-19 | error | unknown item | 404 |
|
||
| AORD-20 | edge | only one flag supplied | other preserved |
|
||
| AORD-21 | happy | removeDeliveryCharge | 0; user sees |
|
||
| AORD-22 | error | unknown | error |
|
||
| AORD-23 | happy | getSlotOrders | orders + isFirstOrder |
|
||
| AORD-24 | edge | no orders | [] |
|
||
| AORD-25 | error | invalid slot string | current behavior |
|
||
| AORD-26 | happy | updateAddressCoords | success |
|
||
| AORD-27 | error | unknown address | 404 |
|
||
| AORD-28 | edge | coords visible to user? | current gap: not exposed |
|
||
| AORD-29 | happy | rebalanceSlots | result; sequence updated |
|
||
| AORD-30 | error | empty/over-50 slot ids | BAD_REQUEST |
|
||
| AORD-31 | happy | cancel fresh order | success; user sees cancelled |
|
||
| AORD-32 | error | blank reason | BAD_REQUEST |
|
||
| AORD-33 | error | unknown order | 404 |
|
||
| AORD-34 | error | already cancelled | 400 |
|
||
| AORD-35 | error | delivered | 400 |
|
||
| AORD-36 | edge | cancellation clears first order | tracker updated |
|
||
| AORD-37 | edge | publish cancellation | queue called |
|
||
| AORD-38 | edge | user token write | current gap |
|
||
|
||
### 7.6 `admin.coupon`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ACOUP-01 | happy | create flat | returns array; code uppercase/trim |
|
||
| ACOUP-02 | happy | create percent | percent stored |
|
||
| ACOUP-03 | happy | multiple codes | one coupon per code |
|
||
| ACOUP-04 | edge | no code | generated MF code |
|
||
| ACOUP-05 | error | both discount types | error |
|
||
| ACOUP-06 | error | neither | error |
|
||
| ACOUP-07 | error | user-based without users | error |
|
||
| ACOUP-08 | error | user-based + apply-all | error |
|
||
| ACOUP-09 | error | invalid applicable user | error |
|
||
| ACOUP-10 | error | duplicate code | error |
|
||
| ACOUP-11 | edge | skuIds null/empty | whole cart |
|
||
| ACOUP-12 | edge | max/min/maxLimit/exclusive/first-order | stored |
|
||
| ACOUP-13 | edge | validTill | parsed |
|
||
| ACOUP-14 | happy | getAll + pagination + search | |
|
||
| ACOUP-15 | happy | getById | coupon + applicableUsers ids |
|
||
| ACOUP-15B | happy | getById for a global coupon | region admin reads a superadmin-created global coupon |
|
||
| ACOUP-16 | error | unknown | error |
|
||
| ACOUP-17 | happy | update partial | fields present win |
|
||
| ACOUP-18 | edge | update code top-level/array | uppercase |
|
||
| ACOUP-19 | edge | update applicableUsers | relationships replaced |
|
||
| ACOUP-20 | error | update both discount types | error |
|
||
| ACOUP-21 | error | update unknown | error |
|
||
| ACOUP-22 | happy | delete | soft invalidate; message |
|
||
| ACOUP-23 | edge | getById after delete | still returns row invalidated |
|
||
| ACOUP-24 | edge | user getEligible after delete | excluded |
|
||
| ACOUP-25 | happy | getReservedCoupons | pagination/search |
|
||
| ACOUP-26 | happy | createReservedCoupon | secret code; one/multiple |
|
||
| ACOUP-27 | error | duplicate secret | error |
|
||
| ACOUP-28 | error | both/neither discount | error |
|
||
| ACOUP-29 | happy | getUsersMiniInfo | limit/offset/search |
|
||
| ACOUP-30 | edge | search matching | |
|
||
| ACOUP-31 | happy | createCoupon by mobile | 20%/min1000/max500/limit1 |
|
||
| ACOUP-32 | error | mobile not 10 digits | error |
|
||
| ACOUP-33 | error | unknown mobile | error |
|
||
| ACOUP-34 | edge | generated code uniqueness | |
|
||
| ACOUP-35 | edge | user token write | current gap |
|
||
| ACOUP-36 | cache | none for coupons | no cache version bump required |
|
||
|
||
### 7.7 `admin.region`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| AREG-01 | happy | current | staff region |
|
||
| AREG-02 | happy | bounds | priority ascending |
|
||
| AREG-03 | happy | effective | lowest-priority settings |
|
||
| AREG-04 | error | effective no bound | 422 |
|
||
| AREG-05 | happy | getRegionConstants | key/value rows |
|
||
| AREG-06 | edge | update constants | updated/deleted counts |
|
||
| AREG-07 | edge | null deletes | key removed |
|
||
| AREG-08 | error | wrong-scope key | BAD_REQUEST |
|
||
| AREG-09 | edge | tagsOrder update | cache schedule |
|
||
| AREG-10 | edge | non-cache key | no cache schedule |
|
||
| AREG-11 | happy | getBoundSettings | bound in staff region |
|
||
| AREG-12 | error | bound from another region | 404 |
|
||
| AREG-13 | happy | updateBoundSettings | counts |
|
||
| AREG-14 | error | wrong-scope bound key | BAD_REQUEST |
|
||
| AREG-15 | edge | null deletes | removed |
|
||
| AREG-16 | edge | user token | 401 staff-only |
|
||
| AREG-17 | edge | superadmin token | 401 staff-only |
|
||
| AREG-18 | cache | constants/bound settings | essentialConsts reflects after refresh |
|
||
|
||
### 7.8 `admin.slots`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ASLOT-01 | happy | getAll | ≤20 slots, region only |
|
||
| ASLOT-02 | edge | >20 slots | cap 20 |
|
||
| ASLOT-03 | happy | create slot | slot + products/groups |
|
||
| ASLOT-04 | error | missing times | 400 |
|
||
| ASLOT-05 | edge | invalid date strings | current DB/parse behavior |
|
||
| ASLOT-06 | edge | no skus | empty slot |
|
||
| ASLOT-07 | error | invalid sku | DB/validation error |
|
||
| ASLOT-10 | cache | create | slots version sync |
|
||
| ASLOT-11 | happy | getSlotById | slot + products |
|
||
| ASLOT-12 | error | unknown | 404 |
|
||
| ASLOT-13 | happy | update slot | times/products |
|
||
| ASLOT-14 | error | unknown | current catch masks to 500 `Unable to Update Slot` |
|
||
| ASLOT-15 | cache | update | slots version sync |
|
||
| ASLOT-16 | happy | getDeliverySequence | sequence map |
|
||
| ASLOT-17 | error | unknown | 404 |
|
||
| ASLOT-18 | happy | updateDeliverySequence | stored |
|
||
| ASLOT-19 | error | unknown | 404 |
|
||
| ASLOT-20 | happy | updateSlotCapacity | flag |
|
||
| ASLOT-21 | error | unknown | 404 |
|
||
| ASLOT-22 | cache | capacity | slots version sync; public file removes/returns |
|
||
| ASLOT-23 | edge | user token | current gap for protected procedures |
|
||
| ASLOT-24 | edge | other-region slot | not found |
|
||
|
||
### 7.9 `admin.store`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ASTORE-01 | happy | getStores | own region, signed images |
|
||
| ASTORE-02 | edge | empty | [] |
|
||
| ASTORE-03 | happy | getStoreById | |
|
||
| ASTORE-04 | error | unknown | 404 |
|
||
| ASTORE-05 | error | other region | 404 |
|
||
| ASTORE-06 | happy | create store | store id |
|
||
| ASTORE-07 | error | name empty | BAD_REQUEST |
|
||
| ASTORE-08 | edge | no image | null |
|
||
| ASTORE-09 | edge | products array | associations |
|
||
| ASTORE-10 | edge | image URL key extraction | |
|
||
| ASTORE-11 | happy | update store | name/description/products |
|
||
| ASTORE-12 | error | unknown/other region/global | 404 |
|
||
| ASTORE-13 | edge | image replacement | old deleted after update |
|
||
| ASTORE-14 | error | update rejected | old image not deleted |
|
||
| ASTORE-15 | happy | delete store | success |
|
||
| ASTORE-16 | error | unknown | 404 |
|
||
| ASTORE-17 | edge | store with products | delete behavior/FK; assert |
|
||
| ASTORE-18 | edge | user token write | current gap |
|
||
| ASTORE-19 | cache | create/update/delete | stores/stores detail eventually |
|
||
|
||
### 7.10 `admin.user`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| AUSER-01 | happy | getEssentials | unresolved complaints count |
|
||
| AUSER-02 | happy | getAllUsers | pagination, stats, last order, suspension |
|
||
| AUSER-03 | edge | search | name/mobile filter |
|
||
| AUSER-04 | edge | cursor | no overlap |
|
||
| AUSER-05 | edge | limit max 100 | BAD_REQUEST above |
|
||
| AUSER-06 | happy | getUserDetails | user + order list/status/item counts |
|
||
| AUSER-07 | error | unknown | 404 |
|
||
| AUSER-08 | error | other region | 404 |
|
||
| AUSER-09 | edge | long order history | current unchunked IN bug; assert failure/limit |
|
||
| AUSER-10 | happy | update suspension | reflected |
|
||
| AUSER-11 | happy | unsuspend | reflected |
|
||
| AUSER-12 | error | unknown user | current upsert behavior; assert |
|
||
| AUSER-13 | happy | getUsersForNotification | eligibility flag |
|
||
| AUSER-14 | edge | search | |
|
||
| AUSER-15 | happy | sendNotification all | token batches, queued count |
|
||
| AUSER-16 | happy | sendNotification specific | only those tokens |
|
||
| AUSER-17 | edge | no tokens | success 0 |
|
||
| AUSER-18 | error | empty title/text | BAD_REQUEST |
|
||
| AUSER-19 | edge | queue failure | logged; success/count behavior |
|
||
| AUSER-20 | happy | getUserIncidents | list with order status |
|
||
| AUSER-21 | error | unknown user | empty |
|
||
| AUSER-22 | happy | addUserIncident | created; negativity recompute |
|
||
| AUSER-23 | edge | optional order/comment/score | nulls accepted |
|
||
| AUSER-24 | error | no staff auth | 401 |
|
||
| AUSER-25 | edge | user token | current gap |
|
||
| AUSER-26 | edge | cross-region user | not found/empty |
|
||
|
||
## 8. Superadmin router
|
||
|
||
### 8.1 `superadmin.auth`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SAUTH-01 | happy | valid username/password | token + superadmin id/username |
|
||
| SAUTH-02 | error | unknown username | 401 |
|
||
| SAUTH-03 | error | wrong password | 401 |
|
||
| SAUTH-04 | error | empty fields | 400 |
|
||
| SAUTH-05 | happy | `me` | superadmin identity |
|
||
| SAUTH-06 | error | `me` no token | 401 |
|
||
| SAUTH-07 | error | staff/user token | 401 |
|
||
| SAUTH-08 | edge | token identity | superadminId/identityType claims |
|
||
| SAUTH-09 | edge | suspended/removed superadmin | token no longer resolves |
|
||
|
||
### 8.2 `superadmin.const`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SCONST-01 | happy | getGlobalConstants | key/value list |
|
||
| SCONST-02 | edge | update global constants | counts/keys; KV refresh |
|
||
| SCONST-03 | edge | null value deletes | removed |
|
||
| SCONST-04 | edge | unknown key | inserted/current |
|
||
| SCONST-05 | happy | getLegacyConstants | key/value list |
|
||
| SCONST-06 | happy | update legacy constants | counts/keys |
|
||
| SCONST-07 | edge | empty array | success 0 |
|
||
| SCONST-08 | error | no token/staff | 401 |
|
||
| SCONST-09 | cache | global update | every bound's essentialConsts refreshes |
|
||
| SCONST-10 | edge | invalid value object | BAD_REQUEST |
|
||
|
||
### 8.3 `superadmin.regions`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SREG-01 | happy | list | all regions |
|
||
| SREG-02 | happy | get | region + bounds |
|
||
| SREG-03 | error | unknown | 404 |
|
||
| SREG-04 | happy | create region with one bound | region + bound; cache files generated |
|
||
| SREG-05 | error | no bounds | BAD_REQUEST |
|
||
| SREG-06 | error | duplicate priority | 409 |
|
||
| SREG-07 | edge | explicit center | stored |
|
||
| SREG-08 | edge | no center | computed from bound |
|
||
| SREG-09 | edge | invalid geojson shape | BAD_REQUEST |
|
||
| SREG-10 | edge | priority numeric string | stored |
|
||
| SREG-11 | error | non-numeric priority | BAD_REQUEST |
|
||
| SREG-12 | happy | update name/description | round-trip |
|
||
| SREG-13 | error | update unknown | 404 |
|
||
| SREG-14 | happy | bounds list | priority ascending |
|
||
| SREG-15 | happy | createBound | bound + refresh |
|
||
| SREG-16 | error | duplicate priority | 409 |
|
||
| SREG-17 | error | unknown region | 409/404 |
|
||
| SREG-18 | happy | updateBound | description/geojson/priority |
|
||
| SREG-18b | happy | updateBound geojson | region addresses rebalanced from coords; outside → null; backfill flag unchanged |
|
||
| SREG-19 | error | duplicate priority | 409 |
|
||
| SREG-20 | error | unknown | 404 |
|
||
| SREG-21 | happy | deleteBound | success/remaining bounds |
|
||
| SREG-22 | error | only bound | 409 |
|
||
| SREG-23 | error | bound used by addresses | 409 |
|
||
| SREG-24 | error | unknown | 404 |
|
||
| SREG-25 | edge | deleted bound KV key removed | essentialConsts old bound 404 |
|
||
| SREG-26 | happy | boundSettings | list |
|
||
| SREG-27 | happy | updateBoundSettings | counts; KV refresh |
|
||
| SREG-28 | error | wrong-scope key | BAD_REQUEST |
|
||
| SREG-29 | edge | null deletes | removed |
|
||
| SREG-30 | happy | getRegionConstants | list |
|
||
| SREG-31 | happy | updateRegionConstants | counts; KV refresh |
|
||
| SREG-32 | error | wrong-scope key | BAD_REQUEST |
|
||
| SREG-33 | edge | tagsOrder | cache rebuild |
|
||
| SREG-34 | happy | effectiveSettings | lowest-priority bound |
|
||
| SREG-35 | error | no bound | 422 |
|
||
| SREG-36 | edge | cross-region cache | new region files isolated |
|
||
| SREG-37 | error | no token/staff/user | 401 |
|
||
|
||
### 8.4 `superadmin.staff`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SSTAFF-01 | happy | list | staff + region/role |
|
||
| SSTAFF-02 | happy | roles | roles |
|
||
| SSTAFF-03 | happy | create | staff created with region |
|
||
| SSTAFF-04 | error | duplicate name | 409 |
|
||
| SSTAFF-05 | error | password <6 | BAD_REQUEST |
|
||
| SSTAFF-06 | error | invalid role | 400 |
|
||
| SSTAFF-07 | error | invalid region | 400 |
|
||
| SSTAFF-08 | happy | update region | moved |
|
||
| SSTAFF-09 | error | unknown staff | 404 |
|
||
| SSTAFF-10 | error | invalid region | 400 |
|
||
| SSTAFF-11 | happy | remove | success |
|
||
| SSTAFF-12 | error | unknown | 404 |
|
||
| SSTAFF-13 | error | owns store | 409 |
|
||
| SSTAFF-14 | error | created coupons | 409 |
|
||
| SSTAFF-15 | error | created reserved coupons | 409 |
|
||
| SSTAFF-16 | happy | sendAdminNotification | queued count |
|
||
| SSTAFF-17 | error | empty title/text | BAD_REQUEST |
|
||
| SSTAFF-18 | edge | no admin tokens | 0 success |
|
||
| SSTAFF-19 | edge | queue failure | logged |
|
||
| SSTAFF-20 | error | staff/user token | 401 |
|
||
|
||
### 8.5 `superadmin.globalProducts`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SGPROD-01 | happy | list | global products |
|
||
| SGPROD-02 | happy | get | product/SKUs |
|
||
| SGPROD-03 | error | unknown | 404 |
|
||
| SGPROD-04 | happy | create | product/SKUs; schedule all-region cache |
|
||
| SGPROD-05 | error | invalid name/price/feature | BAD_REQUEST |
|
||
| SGPROD-06 | error | no SKUs | BAD_REQUEST |
|
||
| SGPROD-07 | edge | multiple SKUs/combo | stored |
|
||
| SGPROD-08 | happy | update | fields/SKUs; IDs preserved for existing |
|
||
| SGPROD-09 | error | unknown | 404 |
|
||
| SGPROD-10 | edge | update adds/removes SKUs | current semantics |
|
||
| SGPROD-11 | happy | delete | deleted; schedule all-region |
|
||
| SGPROD-12 | error | unknown | 404 |
|
||
| SGPROD-13 | edge | product assigned to region | visible in region caches after sync |
|
||
| SGPROD-14 | error | no token/staff/user | 401 |
|
||
| SGPROD-16 | edge | create with >=12 regions | market rows seeded via chunked insert |
|
||
| SGPROD-17 | edge | update adds a SKU with >=12 regions | new SKU's market rows seeded |
|
||
| SGPROD-15 | cache | global create/update/delete | all regions rebuild (no narrowing) |
|
||
|
||
### 8.6 `superadmin.globalStores`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SGSTORE-01 | happy | list | global stores with image URLs |
|
||
| SGSTORE-02 | happy | get | store |
|
||
| SGSTORE-03 | error | unknown | 404 |
|
||
| SGSTORE-04 | happy | create | store; schedule cache |
|
||
| SGSTORE-05 | error | name empty | BAD_REQUEST |
|
||
| SGSTORE-06 | edge | image key extraction | stored key |
|
||
| SGSTORE-07 | happy | update | name/description/image |
|
||
| SGSTORE-08 | error | unknown | current behavior (null/500); assert |
|
||
| SGSTORE-09 | happy | delete | result; schedule cache |
|
||
| SGSTORE-10 | edge | delete store with products | current FK behavior |
|
||
| SGSTORE-11 | cache | writes | all-region rebuild |
|
||
| SGSTORE-12 | error | no token | 401 |
|
||
|
||
### 8.7 `superadmin.globalCoupons`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SGCOUP-01 | happy | list | global coupons |
|
||
| SGCOUP-02 | happy | get | coupon |
|
||
| SGCOUP-03 | error | unknown | 404 |
|
||
| SGCOUP-04 | happy | create flat/percent | coupons array |
|
||
| SGCOUP-05 | error | both/neither | 400 |
|
||
| SGCOUP-06 | error | user-based no users | 400 |
|
||
| SGCOUP-07 | error | user-based + apply-all | 400 |
|
||
| SGCOUP-08 | error | invalid users | 400 |
|
||
| SGCOUP-09 | error | duplicate code | 400 |
|
||
| SGCOUP-10 | edge | no code | generated |
|
||
| SGCOUP-11 | happy | update partial | fields preserved/updated |
|
||
| SGCOUP-12 | error | both discount types | 400 |
|
||
| SGCOUP-13 | error | unknown | 404 |
|
||
| SGCOUP-14 | happy | delete | invalidated |
|
||
| SGCOUP-15 | error | unknown | 404 |
|
||
| SGCOUP-16 | edge | user getEligible sees global coupon | after refresh |
|
||
| SGCOUP-17 | error | no token | 401 |
|
||
|
||
### 8.8 `superadmin.products` / `superadmin.stores`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SPROD-01 | happy | products.list default | 20 rows |
|
||
| SPROD-02 | edge | regionId filter | only region |
|
||
| SPROD-03 | edge | search by name | matching |
|
||
| SPROD-04 | edge | limit 1–100 | works; 0/101 BAD_REQUEST |
|
||
| SPROD-05 | edge | offset | pagination |
|
||
| SPROD-06 | happy | elevate product | global product attached to global store |
|
||
| SPROD-07 | error | unknown product | 404 |
|
||
| SPROD-08 | error | invalid/global store | 400 |
|
||
| SPROD-09 | cache | elevate | all-region rebuild |
|
||
| SPROD-10 | happy | stores.list region | regional stores |
|
||
| SPROD-11 | happy | elevate store | global store |
|
||
| SPROD-12 | error | unknown store | 400/404 |
|
||
| SPROD-13 | cache | elevate | all-region rebuild |
|
||
| SPROD-14 | error | no token | 401 |
|
||
| SPROD-15 | edge | elevationDependents | regional combo components listed |
|
||
| SPROD-16 | happy | elevate combo | components elevated; market rows seeded |
|
||
|
||
### 8.9 `superadmin.complaint`
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| SCOMP-01 | happy | getAll | all-region complaints |
|
||
| SCOMP-02 | edge | pagination | nextCursor |
|
||
| SCOMP-03 | edge | empty | [] |
|
||
| SCOMP-04 | edge | status/images/region | mapped/signed |
|
||
| SCOMP-05 | edge | no token | 401 |
|
||
| SCOMP-06 | edge | staff/user token | 401 |
|
||
|
||
---
|
||
|
||
## 9. Upload/S3 suite
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| UPL-01 | happy | presign product image | PUT bytes; public GET returns exact bytes/sha256 |
|
||
| UPL-02 | happy | two folders in separate calls | distinct keys/objects |
|
||
| UPL-03 | edge | png and jpeg in one call | extension per mime |
|
||
| UPL-04 | edge | unknown mime | `.jpg` |
|
||
| UPL-05 | edge | empty mime list | no URLs |
|
||
| UPL-06 | edge | presigned URL query signature | PUT without R2 credentials |
|
||
| UPL-07 | edge | Content-Type unsigned | any content type accepted (current) |
|
||
| UPL-08 | edge | URL expiry | after 180s PUT fails |
|
||
| UPL-09 | edge | object never uploaded | public GET 404 |
|
||
| UPL-10 | edge | re-upload same key | overwrite/current |
|
||
| UPL-11 | edge | pending status row | created per presign |
|
||
| UPL-12 | edge | claim once | success |
|
||
| UPL-13 | edge | claim unknown | `Failed to claim upload URL` |
|
||
| UPL-14 | edge | claim already claimed | error |
|
||
| UPL-15 | happy | create product with claimed images | images stored |
|
||
| UPL-16 | error | create product with unclaimed/fake image | rejected before DB write |
|
||
| UPL-17 | happy | update product with new claimed image | stored |
|
||
| UPL-18 | error | update with another product's image | rejected as not newly referenced |
|
||
| UPL-19 | edge | deleteImageUtil removes object | GET 404 |
|
||
| UPL-20 | edge | tag image replacement | old deleted best-effort, new claimed |
|
||
| UPL-21 | edge | review response images | claim/validate |
|
||
| UPL-22 | edge | review image lenient | invalid URL logged, review still created |
|
||
| UPL-23 | edge | store image replacement | old deleted after update |
|
||
| UPL-24 | edge | same-millisecond same-mime collision | assert current; do not depend |
|
||
| UPL-25 | error | S3 presign failure | 500, no partial row? assert |
|
||
| UPL-26 | edge | upload bytes mismatch | object holds supplied bytes, not original |
|
||
| UPL-27 | edge | path traversal key | normalized/safe |
|
||
| UPL-28 | edge | public asset URL from key | `scaffoldAssetUrl` correct |
|
||
|
||
---
|
||
|
||
## 10. Notifications, queues and jobs
|
||
|
||
Visible through API responses; queue side effects are asserted through the backend’s queue binding
|
||
or by observing notification state where exposed.
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| NOTIF-01 | happy | admin send to all | batches of 5; queued count |
|
||
| NOTIF-02 | happy | admin send to selected | only selected tokens |
|
||
| NOTIF-03 | edge | duplicate tokens | no duplicate job? assert current |
|
||
| NOTIF-04 | edge | >5 tokens | multiple queue messages |
|
||
| NOTIF-05 | edge | no tokens | 0 success |
|
||
| NOTIF-06 | error | queue push failure for one batch | other batches continue; count excludes failure |
|
||
| NOTIF-07 | happy | complaint resolve | response notification queued |
|
||
| NOTIF-08 | happy | order packaged | packaged notification |
|
||
| NOTIF-09 | happy | order delivered | delivered notification |
|
||
| NOTIF-10 | happy | cancellation | cancellation queue |
|
||
| NOTIF-11 | edge | user with no token | no notification, mutation succeeds |
|
||
| NOTIF-12 | edge | unlogged token included for broadcast | yes |
|
||
| NOTIF-13 | edge | push token region follows address | assert token payload/DB |
|
||
| NOTIF-14 | edge | tracked location does not move token | current rule |
|
||
| NOTIF-15 | edge | notification permission denied | no token registration |
|
||
| NOTIF-16 | edge | queue consumer order-by-name | correct handler |
|
||
| NOTIF-17 | edge | flash cron | toggles flash at scheduled time (if testable) |
|
||
| NOTIF-18 | edge | order publish failure | order still created; logged |
|
||
|
||
---
|
||
|
||
## 11. Cross-cutting invariants
|
||
|
||
### 11.1 Tenant / region isolation
|
||
|
||
For every region-scoped read and write, assert a second region cannot see or mutate the first’s
|
||
data. Minimum matrix:
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ISO-01 | invariant | admin store/product/slot/user/order/banner/tag/coupon reads | only staff region |
|
||
| ISO-02 | invariant | user product/slot/store/cache reads | only requested region |
|
||
| ISO-03 | invariant | address/store/product/slot/order writes with foreign region id | reject or not visible |
|
||
| ISO-04 | invariant | cache files | no foreign ids |
|
||
| ISO-05 | invariant | notifications | token follows address region, not browsing region |
|
||
| ISO-06 | invariant | global product/store | visible in every region’s cache |
|
||
| ISO-07 | invariant | superadmin complaint/products | explicitly global |
|
||
|
||
### 11.2 Transactions and partial failure
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| TX-01 | edge | product create fails on image claim | no product/SKU rows |
|
||
| TX-02 | edge | product update fails on claim | no delete, no update |
|
||
| TX-03 | edge | tag create fails on upload claim | no tag/mapping |
|
||
| TX-04 | edge | coupon create with one duplicate code | no partial coupons? assert current |
|
||
| TX-05 | edge | order place fails on item insert | no order/order items/coupon usage |
|
||
| TX-06 | edge | cancel fails mid-transaction | status/reason unchanged |
|
||
| TX-07 | edge | address create fails after default clear | previous default restored? assert |
|
||
| TX-08 | edge | address update fails after default clear | previous default restored? assert |
|
||
| TX-09 | edge | staff delete blocked by relation | no partial delete |
|
||
| TX-10 | edge | region create with duplicate priority | no region/bounds |
|
||
| TX-11 | edge | slot create with invalid product | no slot relations |
|
||
| TX-12 | edge | order publish/queue failure | DB order remains committed |
|
||
|
||
### 11.3 Concurrency
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| CONC-01 | edge | two orders same slot near capacity | capacity respected; no overbook |
|
||
| CONC-02 | edge | two orders same SKU stock 1 | one succeeds/one rejects |
|
||
| CONC-03 | edge | two coupon redemptions same code | one success |
|
||
| CONC-04 | edge | two staff updates same product | last write wins; no corrupt SKU list |
|
||
| CONC-05 | edge | cache creator regional + global schedules | global not narrowed |
|
||
| CONC-06 | edge | duplicate staff name concurrent | one 409 |
|
||
| CONC-07 | edge | duplicate product name concurrent | one 400/409 |
|
||
| CONC-08 | edge | duplicate tag name concurrent | one 400 |
|
||
| CONC-09 | edge | same push token concurrent | upsert, no duplicate rows |
|
||
| CONC-10 | edge | same address default updates concurrent | exactly one default |
|
||
|
||
### 11.4 Pagination, search and sorting
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| PAGE-01 | edge | limit default per procedure | matches schema |
|
||
| PAGE-02 | edge | limit max | 400 above |
|
||
| PAGE-03 | edge | cursor first/last | no duplicates/missing |
|
||
| PAGE-04 | edge | empty result nextCursor | undefined |
|
||
| PAGE-05 | edge | search case-insensitive | expected |
|
||
| PAGE-06 | edge | search partial mobile/code/name | expected |
|
||
| PAGE-07 | edge | search `%`/`_` | literal, no wildcard injection |
|
||
| PAGE-08 | edge | stable ordering | deterministic tie-break |
|
||
| PAGE-09 | edge | soft-deleted/invalidated rows | excluded/included per procedure |
|
||
| PAGE-10 | edge | region filter combined with search | both applied |
|
||
|
||
### 11.5 Status/error contract
|
||
|
||
| ID | Type | Case | Assert |
|
||
| --- | --- | --- | --- |
|
||
| ERR-01 | edge | ApiError 400 | HTTP 400/BAD_REQUEST |
|
||
| ERR-02 | edge | ApiError 401 | UNAUTHORIZED |
|
||
| ERR-03 | edge | ApiError 403 | FORBIDDEN |
|
||
| ERR-04 | edge | ApiError 404 | NOT_FOUND |
|
||
| ERR-05 | edge | ApiError 409 | CONFLICT |
|
||
| ERR-06 | edge | ApiError 422 | UNPROCESSABLE_CONTENT |
|
||
| ERR-07 | edge | unknown error | INTERNAL_SERVER_ERROR, no SQL details |
|
||
| ERR-08 | edge | raw `Error('Order not found')` | current 500; assert until converted to ApiError |
|
||
| ERR-09 | edge | zod error | BAD_REQUEST with path |
|
||
| ERR-10 | edge | error logger | logs path/type/user but not secrets |
|
||
|
||
---
|
||
|
||
## 12. Procedure coverage checklist
|
||
|
||
Every procedure must have at least one happy test and one auth test; mutations also need validation
|
||
and side-effect tests. Use this table as the completion gate.
|
||
|
||
| Router | Procedure | Case IDs |
|
||
| --- | --- | --- |
|
||
| common.product | getAllProductsSummary | COMMON-01..10 |
|
||
| common.product | getAllSkusSummary | COMMON-11..18 |
|
||
| common | getStoresSummary | COMMON-17..21 |
|
||
| common | checkLocationInPolygon | COMMON-22..29 |
|
||
| common | generateUploadUrls | COMMON-30..45, UPL-01..28 |
|
||
| common | healthCheck | COMMON-46..48, HTTP-01 |
|
||
| common | listRegions | COMMON-49..52 |
|
||
| common | resolveRegionByLocation | COMMON-53..58 |
|
||
| common | resolveBound | COMMON-59..64 |
|
||
| common | regionSettings | COMMON-65..67 |
|
||
| common | activeBound | COMMON-68..73 |
|
||
| common | essentialConsts | CACHE-01..24, COMMON-74..78 |
|
||
| user.auth | login | UAUTH-01..15 |
|
||
| user.auth | register | UREG-01..13 |
|
||
| user.auth | sendOtp | UOTP-01..03 |
|
||
| user.auth | verifyOtp | UOTP-04..12 |
|
||
| user.auth | updatePassword | UPASS-01..06 |
|
||
| user.auth | updateProfile | UPROF-01..13 |
|
||
| user.auth | deleteAccount | UDEL-01..09 |
|
||
| user.address | getDefaultAddress | UADDR-14 |
|
||
| user.address | getUserAddresses | UADDR-15 |
|
||
| user.address | createAddress | UADDR-01..13 |
|
||
| user.address | updateAddress | UADDR-16..22 |
|
||
| user.address | deleteAddress | UADDR-23..30 |
|
||
| user.cart | getCartSlots | UCART-01..08 |
|
||
| user.complaint | getAll | UCOMP-08..09 |
|
||
| user.complaint | raise | UCOMP-01..07, 10..11 |
|
||
| user.coupon | getEligible | UCOUP-01..07 |
|
||
| user.coupon | getMyCoupons | UCOUP-08..12 |
|
||
| user.coupon | redeemReservedCoupon | UCOUP-13..20 |
|
||
| user.fileUpload | generateUploadUrls | UUP-01..10 |
|
||
| user.order | placeOrder | UORD-01..70 |
|
||
| user.order | getOrders | UORD-71..84 |
|
||
| user.order | getOrderById | UORD-85..92 |
|
||
| user.order | cancelOrder | UORD-98..108 |
|
||
| user.order | updateUserNotes | UORD-93..97 |
|
||
| user.product | getProductDetails | UPROD-01..10 |
|
||
| user.product | getProductReviews | UPROD-11..14 |
|
||
| user.product | createReview | UPROD-15..24 |
|
||
| user.slots | getSlots | USLOT-01..10 |
|
||
| user.user | getSelfData | UUSER-01..05 |
|
||
| user.user | savePushToken | UUSER-06..13 |
|
||
| user.user | recordTrackedRegion | UUSER-14..17 |
|
||
| admin.staffUser | login | ASTAFF-01..04 |
|
||
| admin.staffUser | me | ASTAFF-05..07 |
|
||
| admin.staffUser | getStaff | ASTAFF-08..09 |
|
||
| admin.staffUser | createStaffUser | ASTAFF-11..15 |
|
||
| admin.staffUser | getRoles | ASTAFF-10 |
|
||
| admin.staffUser | savePushToken | ASTAFF-16..17 |
|
||
| admin.staffUser | sendAdminNotification | ASTAFF-18..22, NOTIF-01..06 |
|
||
| admin.banner | getBanners | ABAN-01..03 |
|
||
| admin.banner | getBanner | ABAN-04..06 |
|
||
| admin.banner | createBanner | ABAN-07..13 |
|
||
| admin.banner | updateBanner | ABAN-14..17 |
|
||
| admin.banner | deleteBanner | ABAN-18..21 |
|
||
| admin.complaint | getAll | ACOMP-01..05 |
|
||
| admin.complaint | resolve | ACOMP-06..12 |
|
||
| admin.product | getProducts | APROD-01..04 |
|
||
| admin.product | getProductById | APROD-05..08 |
|
||
| admin.product | deleteProduct | APROD-43..45 |
|
||
| admin.product | toggleOutOfStock | APROD-46..50 |
|
||
| admin.product | createProduct | APROD-17..33, 82 |
|
||
| admin.product | updateProduct | APROD-34..42, 78..81 |
|
||
| admin.product | getProductReviews | APROD-09..12 |
|
||
| admin.product | respondToReview | APROD-73..77 |
|
||
| admin.product | getGroups | APROD-13 |
|
||
| admin.product | createGroup | APROD-56 |
|
||
| admin.product | updateGroup | APROD-57..58 |
|
||
| admin.product | deleteGroup | APROD-59..60 |
|
||
| admin.product | updateProductPrices | APROD-51..55 |
|
||
| admin.product | getProductTags | APROD-14 |
|
||
| admin.product | getProductTagById | APROD-15..16 |
|
||
| admin.product | createProductTag | APROD-61..66 |
|
||
| admin.product | updateProductTag | APROD-67..69 |
|
||
| admin.product | deleteProductTag | APROD-70..72 |
|
||
| admin.order | updateNotes | AORD-10..12 |
|
||
| admin.order | getOrderDetails | AORD-07..09 |
|
||
| admin.order | updatePackaged | AORD-13..15 |
|
||
| admin.order | updateDelivered | AORD-16..17 |
|
||
| admin.order | updateOrderItemPackaging | AORD-18..20 |
|
||
| admin.order | removeDeliveryCharge | AORD-21..22 |
|
||
| admin.order | getSlotOrders | AORD-23..25 |
|
||
| admin.order | updateAddressCoords | AORD-26..28 |
|
||
| admin.order | getAll | AORD-01..06 |
|
||
| admin.order | rebalanceSlots | AORD-29..30 |
|
||
| admin.order | cancelOrder | AORD-31..38 |
|
||
| admin.coupon | create | ACOUP-01..13 |
|
||
| admin.coupon | getAll | ACOUP-14 |
|
||
| admin.coupon | getById | ACOUP-15, 15B, 16 |
|
||
| admin.coupon | update | ACOUP-17..21 |
|
||
| admin.coupon | delete | ACOUP-22..24 |
|
||
| admin.coupon | getReservedCoupons | ACOUP-25 |
|
||
| admin.coupon | createReservedCoupon | ACOUP-26..28 |
|
||
| admin.coupon | getUsersMiniInfo | ACOUP-29..30 |
|
||
| admin.coupon | createCoupon | ACOUP-31..35 |
|
||
| admin.region | current | AREG-01 |
|
||
| admin.region | bounds | AREG-02 |
|
||
| admin.region | effective | AREG-03..04 |
|
||
| admin.region | getRegionConstants | AREG-05 |
|
||
| admin.region | updateRegionConstants | AREG-06..10, 18 |
|
||
| admin.region | getBoundSettings | AREG-11..12 |
|
||
| admin.region | updateBoundSettings | AREG-13..18 |
|
||
| admin.slots | getAll | ASLOT-01..02 |
|
||
| admin.slots | createSlot | ASLOT-03..10 |
|
||
| admin.slots | getSlotById | ASLOT-11..12 |
|
||
| admin.slots | updateSlot | ASLOT-13..15 |
|
||
| admin.slots | getDeliverySequence | ASLOT-16..17 |
|
||
| admin.slots | updateDeliverySequence | ASLOT-18..19 |
|
||
| admin.slots | updateSlotCapacity | ASLOT-20..24 |
|
||
| admin.store | getStores | ASTORE-01..02 |
|
||
| admin.store | getStoreById | ASTORE-03..05 |
|
||
| admin.store | createStore | ASTORE-06..10, 19 |
|
||
| admin.store | updateStore | ASTORE-11..14, 19 |
|
||
| admin.store | deleteStore | ASTORE-15..19 |
|
||
| admin.user | getEssentials | AUSER-01 |
|
||
| admin.user | getAllUsers | AUSER-02..05 |
|
||
| admin.user | getUserDetails | AUSER-06..09 |
|
||
| admin.user | updateUserSuspension | AUSER-10..12 |
|
||
| admin.user | getUsersForNotification | AUSER-13..14 |
|
||
| admin.user | sendNotification | AUSER-15..19, NOTIF-01..06 |
|
||
| admin.user | getUserIncidents | AUSER-20..21 |
|
||
| admin.user | addUserIncident | AUSER-22..26 |
|
||
| superadmin.auth | login | SAUTH-01..04 |
|
||
| superadmin.auth | me | SAUTH-05..09 |
|
||
| superadmin.const | getGlobalConstants | SCONST-01 |
|
||
| superadmin.const | updateGlobalConstants | SCONST-02..04, 09 |
|
||
| superadmin.const | getLegacyConstants | SCONST-05 |
|
||
| superadmin.const | updateLegacyConstants | SCONST-06..10 |
|
||
| superadmin.regions | list | SREG-01 |
|
||
| superadmin.regions | get | SREG-02..03 |
|
||
| superadmin.regions | create | SREG-04..11 |
|
||
| superadmin.regions | update | SREG-12..13 |
|
||
| superadmin.regions | bounds | SREG-14 |
|
||
| superadmin.regions | createBound | SREG-15..17 |
|
||
| superadmin.regions | updateBound | SREG-18..20 |
|
||
| superadmin.regions | deleteBound | SREG-21..25 |
|
||
| superadmin.regions | boundSettings | SREG-26 |
|
||
| superadmin.regions | updateBoundSettings | SREG-27..29 |
|
||
| superadmin.regions | getRegionConstants | SREG-30 |
|
||
| superadmin.regions | updateRegionConstants | SREG-31..33 |
|
||
| superadmin.regions | effectiveSettings | SREG-34..37 |
|
||
| superadmin.staff | sendAdminNotification | SSTAFF-16..20 |
|
||
| superadmin.staff | list | SSTAFF-01 |
|
||
| superadmin.staff | roles | SSTAFF-02 |
|
||
| superadmin.staff | create | SSTAFF-03..07 |
|
||
| superadmin.staff | update | SSTAFF-08..10 |
|
||
| superadmin.staff | remove | SSTAFF-11..15 |
|
||
| superadmin.globalProducts | list | SGPROD-01 |
|
||
| superadmin.globalProducts | get | SGPROD-02..03 |
|
||
| superadmin.globalProducts | create | SGPROD-04..07, 16 |
|
||
| superadmin.globalProducts | update | SGPROD-08..10, 17 |
|
||
| superadmin.globalProducts | delete | SGPROD-11..15 |
|
||
| superadmin.globalStores | list | SGSTORE-01 |
|
||
| superadmin.globalStores | get | SGSTORE-02..03 |
|
||
| superadmin.globalStores | create | SGSTORE-04..06 |
|
||
| superadmin.globalStores | update | SGSTORE-07..08 |
|
||
| superadmin.globalStores | delete | SGSTORE-09..12 |
|
||
| superadmin.globalCoupons | list | SGCOUP-01 |
|
||
| superadmin.globalCoupons | get | SGCOUP-02..03 |
|
||
| superadmin.globalCoupons | create | SGCOUP-04..10 |
|
||
| superadmin.globalCoupons | update | SGCOUP-11..13 |
|
||
| superadmin.globalCoupons | delete | SGCOUP-14..17 |
|
||
| superadmin.products | list | SPROD-01..05 |
|
||
| superadmin.products | elevate | SPROD-06..09, 16 |
|
||
| superadmin.products | elevationDependents | SPROD-15 |
|
||
| superadmin.stores | list | SPROD-10 |
|
||
| superadmin.stores | elevate | SPROD-11..14 |
|
||
| superadmin.complaint | getAll | SCOMP-01..06 |
|
||
|
||
---
|
||
|
||
## 13. Known current gaps to pin explicitly
|
||
|
||
These are intentionally written as “current” cases until the underlying defect is fixed:
|
||
|
||
1. Admin `protectedProcedure` reads/writes are callable with a user token.
|
||
2. `admin.order.getAll` swallows errors and returns `undefined`.
|
||
3. `admin.order.getOrderDetails`/`updateNotes`/`removeDeliveryCharge` throw raw `Error`, producing a 500 instead of 404.
|
||
4. `admin.slots.updateSlot` masks all failures as `Unable to Update Slot`.
|
||
5. `admin.user.getUserDetails`/`getAllUsers` build an unchunked `IN (...)` and fail on long histories.
|
||
6. `admin.product.deleteProduct` fails on products with SKUs (FK/raw error).
|
||
7. `placeOrder` has no idempotency key and no quantity upper bound.
|
||
8. Empty `selectedItems` falls through to a raw DB error.
|
||
9. A user can raise a complaint against another user’s order id.
|
||
11. Suspended-user handling in `createContext` swallows the `TRPCError`, so requests look anonymous rather than 403.
|
||
12. `getOrderById`/`cancelOrder`/`updateUserNotes` accept only numeric-string ids; `ORD` display ids fail.
|
||
13. Cart/checkout area identity uses address coordinates; a stale client `regionId` must not win.
|
||
14. Cache rebuilds are non-atomic and eventual; every cache test must poll, never sleep once.
|
||
15. `cacheVersion`/`slotsVersionNum`/`availabilityVersionNum` are old names; use
|
||
`products_version_num`/`slots_version_num`/`availability_version_num`.
|
||
16. `common.essentialConsts` accepts an optional `boundId`; a missing input is a temporary
|
||
backwards-compatibility path that falls back to bound 1 (region 1).
|
||
|
||
---
|
||
|
||
## 14. Suggested execution order
|
||
|
||
1. Harness + auth + HTTP routes.
|
||
2. Golden E2E-01..25 (catalog + cache).
|
||
3. Common router.
|
||
4. User auth/address/cart.
|
||
5. User order + product + coupon.
|
||
6. Admin product/store/slot/banner/tag.
|
||
7. Admin order/coupon/user.
|
||
8. Superadmin.
|
||
9. Uploads/S3.
|
||
10. Cache invariants + concurrency + cross-region isolation.
|
||
|
||
Run serially (`--runInBand`). Cache tests may take several minutes; keep them in their own Jest
|
||
project or a `describe` with `jest.setTimeout(240000)`.
|