25 KiB
Freshyo E2E — failed test cases (detailed)
Companion to docs/e2e-sanity-test-plan.md (the plan) and
docs/test reports/e2e-sanity-test-results-2026-10-10-1310.md (all results). This
file expands only the FAIL cases with reproduction steps, evidence, root cause,
and a suggested fix.
All evidence was produced on 2026-10-10 against the local stack:
backend http://localhost:8787 (/api/trpc), disposable local D1, iOS
simulator com.freshyotrial.app / in.freshyo.adminui, Chromium superadmin
http://localhost:4175.
Legend: Severity — Critical / High / Medium / Low. Case IDs match the plan.
FC-01 — SEC-01: customer token can mutate global configuration
- Status: ✅ Fixed (2026-10-10) —
admin.const.*now requires a staff token (staffProcedure);updateConstantsadditionally rejects global-scope keys (globals are superadmin-only); the redundantgetGlobalConstants/updateGlobalConstants/getLegacyConstants/updateLegacyConstantsprocedures were removed (no production UI caller). Regression test:apps/backend/tests/api/authorization-matrix.test.ts(staff-guarded block). - Severity: Critical
- Case: SEC-01
- Symptom: A signed-in customer can call the staff/admin global-config mutation and change app-wide constants.
- Steps to reproduce:
user.auth.login {identifier:"e2e_u2@test.com", password:"Pass@12345"}→ customer token.admin.const.updateGlobalConstants {constants:[{key:"versionNum",value:"1.2.0"}]}with that token.
- Expected: Rejected (staff-only).
- Actual:
200 {success:true, updatedCount:1}. - Evidence: Response body from step 2; anonymous
admin.product.getProducts→ 401, customeradmin.product.getProducts→ 500 (Cannot read properties of null (reading 'regionId')). - Root cause:
apps/backend/src/trpc/apis/admin-apis/apis/const.ts—updateGlobalConstantsusesprotectedProcedure(allows any authenticated user or staff) and never touchesctx.staffUser.protectedProcedureis defined inapps/backend/src/trpc/trpc-index.ts. - Suggested fix: Change the global-config procedures (
getGlobalConstants,updateGlobalConstants, legacy ones) tosuperadminProcedure(global scope) or at minimumstaffProcedure; remove the legacy admin global mutation or gate it behind superadmin.
FC-02 — SEC-04: order accepts a SKU from another region
- Status: ✅ Fixed (2026-10-10) —
placeOrderUtilnow rejects an item whose productregionId≠ the order region (409 "… is not available in this region"). - Severity: High
- Case: SEC-04
- Symptom: A region-1 order can include a region-2 SKU.
- Steps to reproduce:
- U2 with a region-1 address (877).
user.order.placeOrder {regionId:1, addressId:877, paymentMethod:"cod", selectedItems:[{skuId:157 /* region-2 product */, quantity:1, slotId:2012}]}.
- Expected: Rejected (SKU not in the ordering region).
- Actual:
200, order 2456 created withregionId:1and sku 157, priced at region-2's ₹149 + ₹20 delivery. - Evidence: Order 2456 in
orders/order_items. - Root cause:
apps/backend/src/trpc/apis/user-apis/apis/order.ts→placeOrderUtilresolves items viagetOrderProductById(item.skuId)with no region filter. Address region is checked, but SKU/slot/bound region coherence is not. - Suggested fix: Validate each SKU's
regionId(and its product's region) equals the order region; reject otherwise.
FC-03 — SEC-05: order accepts unassigned / out-of-stock / closed-slot items
- Status: ✅ Fixed (2026-10-10) —
placeOrderUtilnow rejectsisDeleted/isOutOfStock/isSuspendeditems (400), requires a non-null slotId for scheduled orders, and validates each slot: exists, region match (409),isActive,freezeTime/deliveryTimein the future, and every orderedskuIdpresent inslot.skuIds(400). - Severity: High
- Case: SEC-05
- Symptom: The backend accepts items it should reject.
- Steps to reproduce:
- (a) Unassigned SKU:
placeOrder {regionId:1, selectedItems:[{skuId:1, quantity:1, slotId:2012}]}where sku 1 is not in slot 2012 → 200, order 2457. - (b) Out-of-stock:
admin.product.toggleOutOfStock{id:155}→placeOrder {skuId:155, slotId:2012}→ 200, order 2458 (stock restored afterward).
- (a) Unassigned SKU:
- Expected: Both rejected.
- Actual: Both create orders.
- Evidence: Orders 2457, 2458; schema still rejects non-positive/non-integer quantity.
- Root cause:
placeOrderUtil(order.ts) never checksisOutOfStock/isSuspended/isDeleted, nor that the SKU is a member of the selected slot, nor slot active/frozen state (only capacity is checked). - Suggested fix: In
placeOrderUtil, for each item assert: SKU exists, belongs to region, not OOS/suspended/deleted, is assigned to the chosen slot, and the slot is active and not frozen.
FC-04 — SEC-06: user-based coupon is not restricted to its user
- Status: ✅ Fixed (2026-10-10) —
validateAndGetCouponnow loadsapplicableUsersand rejects a user-based coupon for anyone not listed (unlessisApplyForAll):This coupon is not applicable to your account. - Severity: High
- Case: SEC-06
- Symptom: A coupon created for U1 can be applied by U2.
- Steps to reproduce:
- Admin:
coupon.create {couponCode:"E2EU1ONLY", discountPercent:10, isUserBased:true, applicableUsers:[388], maxLimitForUser:3}. - U2:
placeOrder {…, couponId:46}.
- Admin:
- Expected: Rejected (coupon is for user 388 only).
- Actual:
200, order 2463 discounted. - Evidence: Order 2463; coupon 46 has
isUserBased:true. - Root cause:
packages/db_helper_sqlite/src/user-apis/coupon.ts→validateAndGetUserCoupondoes not consultapplicableUsers. (Expiry is enforced.) - Suggested fix: Reject when
coupon.isUserBased && !applicableUsers.includes(userId).
FC-05 — SEC-07: public vendor packaging mutation + expired-snippet leak
- Severity: High
- Case: SEC-07
- Symptom: Anyone can toggle order-item packaging; expired snippets still list orders.
- Steps to reproduce:
- Admin creates a vendor snippet for slot 2012 (
E2ESNIP). - Anonymous
admin.vendorSnippets.updateOrderItemPackaging {orderItemId:8237, is_packaged:true}→ 200 (toggled U1's order item). - Admin creates an expired snippet (
validTill:"2020-01-01"); anonymousadmin.vendorSnippets.getOrdersBySnippetAndSlot {snippetCode:"E2ESNIPEXP", slotId:2012}→ 200 with customer names + orders.
- Admin creates a vendor snippet for slot 2012 (
- Expected: Packaging edits require vendor authority; expired snippets return nothing.
- Actual: Anonymous mutation succeeds; expired snippet leaks orders.
- Evidence: Both responses above (item 8237 toggled true→false).
- Root cause:
apps/backend/src/trpc/apis/admin-apis/apis/vendor-snippets.ts—updateOrderItemPackagingispublicProcedurewith the auth check commented out;getOrdersBySnippetAndSlotnever checksvalidTill(unlikegetOrdersBySnippet). - Suggested fix: Require a valid
snippetCode(unexpired) and authorize the mutation against the order's slot/snippet; enforce expiry in the slot-variant query too.
FC-06 — BL-02: minRegularOrderValue is not a real minimum
- Status: ✅ Resolved (2026-10-10) — the constant was removed. It was never a hard minimum (nothing enforced it) and is no longer used as the delivery threshold, so it was dead. Removed from both const registries, the essential-consts payload, the web-ui hook, the admin/superadmin bound editors, the seeds, and the tests. No minimum-order rule is enforced (matching the customer app).
- Severity: Medium
- Case: BL-02
- Symptom: Orders below the configured minimum are accepted.
- Steps to reproduce:
placeOrderwith subtotal ₹199 while bound A1minRegularOrderValue:300. - Expected: Blocked if it is a hard minimum (policy needs confirmation).
- Actual:
200(orders 2457/2458). - Evidence: Orders below 300 accepted.
- Root cause:
placeOrderUtilusesminRegularOrderValueonly as the free-delivery threshold, never as a minimum-order gate; the client usesfreeDeliveryThresholdinstead. - Suggested fix: Decide the contract (minimum vs informational). If a minimum, enforce it in
placeOrderand surface it in the cart; if not, rename/document it and stop using it as the fee threshold.
FC-07 — BL-03 / BL-06: client and backend delivery-fee formulas diverge
- Status: ✅ Fixed (2026-10-10) — the backend now uses the customer app's
model: threshold key
freeDeliveryThreshold(notminRegularOrderValue) and the post-discount basis (finalTotal = subtotal − discount; delivery = finalTotal < threshold ? charge : 0). - Severity: High
- Cases: BL-03, BL-06
- Symptom: The amount the customer sees differs from what the backend saves.
- Steps to reproduce:
- BL-06 (different keys): bound A2
min=300, free=800, charge=200; subtotal ₹548. Backend order 2459 →totalAmount:548, deliveryCharge:0; client preview →548<800→ ₹200 delivery → ₹748. - BL-03 (different discount basis): bound A1
threshold 300; subtotal ₹349, flat ₹100 coupon. Backend order 2461 →totalAmount:249, deliveryCharge:0; client preview → post-coupon 249<300 → ₹20 → ₹269.
- BL-06 (different keys): bound A2
- Expected: Identical rule in cart, checkout, persisted order, and admin.
- Actual: ₹200 / ₹20 discrepancies.
- Evidence: Orders 2459, 2461.
- Root cause:
apps/user-ui/components/cart-page.tsxusesdeliveryCharge = (subtotal − discount) < freeDeliveryThreshold ? charge : 0.placeOrderUtil(order.ts) usesexpectedDeliveryCharge = subtotal(pre-discount) < minRegularOrderValue ? charge : 0. Different key and different discount basis. - Suggested fix: One shared pricing function (server-authoritative). Use the same threshold key and the same pre/post-discount basis on both sides; ideally the client renders the server quote.
FC-08 — D10: percentage discount is applied to subtotal + delivery fee
- Status: ✅ Fixed (2026-10-10) — the coupon discount is now computed on the cart subtotal only; delivery is decided afterwards and added on top (no longer discounted).
- Severity: High
- Case: BL-05 (and visible in SEC-06 order 2463)
- Symptom: A % coupon discounts the delivery fee too.
- Steps to reproduce: subtotal ₹199 + delivery ₹20, 10% coupon → order 2463
totalAmount:197.1. - Expected: Discount on the item subtotal only → ₹199×0.9 + ₹20 = ₹199.1.
- Actual: (199+20)×0.9 = ₹197.1.
- Evidence: Order 2463; also 15% case 2480 (₹186.15 = 219×0.85).
- Root cause:
placeOrderUtilpassessubOrderTotalWithDeliveryintoapplyDiscountToUserOrderfor the first suborder. - Suggested fix: Apply the coupon to the item subtotal, then add delivery; keep the same order on the client.
FC-09 — CP-05: SKU-restricted coupon is not enforced
- Status: ⚪ Not a defect for now (2026-10-10) — SKU-specific coupons are not
created today; coupons are intended to apply to all SKUs.
skuIdsis deliberately left unenforced. (Revisit if SKU-scoped coupons are ever introduced.) - Severity: High
- Case: CP-05
- Symptom: A coupon limited to sku 155 discounts a cart containing only sku 156.
- Steps to reproduce:
coupon.create {couponCode:"E2ESKU155", discountPercent:10, skuIds:[155]}→placeOrderwith only sku 156 → 200, order 2474 (10% off 349). - Expected: Rejected.
- Actual: Applied.
- Evidence: Order 2474.
- Root cause:
validateAndGetUserCoupondoes not enforceskuIds/ applicable products. - Suggested fix: Validate cart items against the coupon's product/SKU scope server-side.
FC-10 — CP-11: coupons are not region-scoped
- Status: ⚪ Not a defect for now (2026-10-10) — region-scoped coupons are not wanted; coupons are global. No region filter is added. (Revisit if regional coupons are ever required.)
- Severity: High
- Case: CP-11
- Symptom: A region-1 coupon discounts a region-2 order.
- Steps to reproduce: U2 region-2 address (883) + region-2 sku 157 + region-1 coupon 45 → 200, order 2477 total ₹79.
- Expected: Per region policy (reject if region-scoped).
- Actual: Applied.
- Evidence: Order 2477.
- Root cause: coupon storage/validation (
coupons,validateAndGetUserCoupon, user coupon fetches) carries no region filter. - Suggested fix: Decide global-vs-regional coupon policy; if regional, store
region_idand filter both retrieval and validation.
FC-11 — PD-13: deleting a store orphans its products
- Status: ✅ Fixed (2026-10-10) —
deleteStorenow counts the store's products and refuses to delete while any exist (plain error: "Cannot delete a store that still has products…"); thestore_id → NULLstep was removed, so products can no longer be orphaned. - Severity: High
- Case: PD-13
- Symptom:
deleteStoresucceeds even when the store has products. - Steps to reproduce:
admin.store.deleteStore {storeId:1}(store 1 had 41 products) → 200 "Store deleted successfully". - Expected: Blocked (or products reassigned).
- Actual: 41 products left with
store_id = NULL. - Evidence: DB count of
product_info where store_id is nulljumped to 41 (restored manually). - Root cause:
apps/backend/src/trpc/apis/admin-apis/apis/store.tsdeleteStoreandpackages/db_helper_sqlitedeleteStoreFromDbhave no dependency guard/reassignment. - Suggested fix: Reject deletion when products reference the store, or require an explicit reassignment target; never leave products with a null store.
FC-12 — DS-02: deleting a product tag fails (FK)
- Status: ✅ Fixed (2026-10-10) —
deleteProductTagnow deletes theproduct_tagsjunction rows first (in a transaction) before the tag row, so a tag with products deletes cleanly. No FK-cascade migration needed. - Severity: High
- Case: DS-02
- Symptom: Tag delete throws a raw DB error when the tag has products.
- Steps to reproduce: create tag 12 with products 155/156 →
admin.product.deleteProductTag {id:12}. - Expected: Tag + junction rows removed.
- Actual:
500Failed query: delete from "product_tag_info" …. - Evidence:
product_tagsstill had row (product 155 → tag 12); FKON DELETE no action. - Root cause:
deleteProductTagInDbdeletesproduct_tag_infowithout first deletingproduct_tagsjunction rows. - Suggested fix: Delete junction rows (or use
ON DELETE CASCADE) before the tag row.
FC-13 — SL-04: closed (frozen) slot is accepted by placeOrder
- Status: ✅ Fixed (2026-10-10) — the slot validation added for FC-03 rejects
a slot whose
freezeTime(ordeliveryTime) has passed (400). - Severity: High
- Case: SL-04
- Symptom: An order can be placed into a slot whose freeze time has passed.
- Steps to reproduce: create slot 2015 with
freezeTime:"2020-01-01"→placeOrder {skuId:155, slotId:2015}→ 200, order 2469. - Expected: Rejected (orders closed).
- Actual: Accepted.
- Evidence: Order 2469.
- Root cause:
placeOrderchecks capacity (getUserSlotCapacityStatus) but not slot active/freeze state; the client only filters slots. - Suggested fix: Server-side reject when
slot.freezeTime <= nowor!slot.isActive.
FC-14 — CT-07: cart does not reflect an out-of-stock item
- Status: ⚪ Not a defect (false flag) (2026-10-10) — reproduced and disproven. The cart
does implement the CT-07 behavior:
cart-page.tsxrenders an "Out of Stock" badge (:962), filters OOS lines out of the checkout payload (:1247), and blocks checkout with "Items Unavailable" when every line is OOS (:1264). The E2E only observed the pre-propagation window: aftertoggleOutOfStockthe app keeps the previousavailability_version_numuntil itsessentialConstsrefetchInterval(60 s) fires, so the cart shows the line normally for up to ~1 minute, then correctly shows "Out of Stock". The report's stated root cause (cart-pageignoresisOutOfStock) was inaccurate. - Severity: High
- Case: CT-07
- Repro (2026-10-10): cart held sku 155 ("E2E Chicken 500 g", qty 6, ₹1194);
toggleOutOfStock{id:155}bumped availabilityav-17 → av-18(publishedav-18showsisOutOfStock:true);stopApp→launchApp→ open cart → line normal; ~70 s later (the refetch interval) → red "Out of Stock" badge. Stock restored afterwards. - Evidence (original E2E): Published
availability.jsonfor region 1av-15showed sku 155isOutOfStock:true; the cart screenshot was taken inside the staleness window. - Residual (out of scope, by decision): the ~60 s propagation delay is cache-refresh latency, not a cart-logic bug.
FC-15 — AU-07: profile update is broken (ctx.req.header)
- Status: ✅ Fixed (2026-10-10) —
Context.reqis now typed as the fetchRequestthe adapter passes, andupdateProfilereadsctx.req.headers.get('authorization'). The optional email was relaxed too: an empty email means "no change", and the client only requires it when registering. - Severity: High
- Case: AU-07
- Symptom:
updateProfilealways errors. - Steps to reproduce:
user.auth.updateProfile {name:"E2E U2 Renamed", bio:"hello bio"}with a valid token. - Expected: Profile updated.
- Actual:
500 "ctx.req.header is not a function". - Evidence: Response above; UI Edit Profile also blocked earlier by a required-email validation.
- Root cause:
apps/backend/src/trpc/apis/user-apis/apis/auth.tsline ~342 callsctx.req.header('authorization'), butctx.reqis a fetchRequest(only.headers.get). - Suggested fix: Read the header via
ctx.req.headers.get('authorization')(or drop the token echo). Relax the client's email requirement if email is optional.
FC-16 — AU-08: password change has no effect (duplicate creds row)
- Status: ✅ Fixed (2026-10-10) —
upsertUserPasswordnow selects then updates-or-inserts (updating all rows for the user, repairing existing duplicates), and auniqueIndexonuser_creds.user_idwas added to the schema. Existing duplicate rows (users 379, 908, 1311) must be deduped before the index migration is applied. - Severity: High
- Case: AU-08
- Symptom: After
updatePassword, the old password still works and the new one fails. - Steps to reproduce: fresh user U5 →
user.auth.updatePassword {password:"NewPass@456"}→ login with old (works) / new (fails). - Expected: New password works, old fails.
- Actual: Old logs in (200), new fails (500).
- Evidence:
user_credsfor the user contains two rows (ids 26, 27) after the change. - Root cause:
upsertUserAuthPasswordInDbinserts a new row instead of updating the existing one; login reads the stale row. - Suggested fix: Update the existing
user_credsrow (unique onuser_id) rather than inserting; add a unique constraint if missing.
FC-17 — OR-12: no order idempotency (duplicate submits)
- Status: 🟡 Mitigated client-side (2026-10-10) — the Place Order button is
disabled while a submit is in flight, and
handlePlaceOrderearly-returns via a synchronoususeRefguard (plusisPending), so an accidental double-tap cannot submit twice. Server-side idempotency was intentionally deferred:placeOrderstill has no idempotency key, so a direct API replay or network retry can still create duplicates. - Severity: Medium
- Case: OR-12
- Symptom: Retrying/submitting twice creates duplicate orders.
- Steps to reproduce: call the same
placeOrdertwice with identical params. - Expected: One order group (idempotent) or a clear dedupe.
- Actual: Two calls created 4 orders (2465–2468).
- Evidence: Order ids above.
- Root cause:
placeOrderhas no idempotency key; only the client has a loading lock. - Suggested fix: Accept a client-generated idempotency key and short-circuit duplicate submissions.
FC-18 — AD-06: address region/bound coherence not validated
- Severity: Medium
- Case: AD-06
- Symptom: An address can reference a bound from a different region.
- Steps to reproduce:
user.address.createAddress {regionId:2, boundId:1}(bound 1 is region 1's) → 200, address 882 stored region 2 / bound 1. - Expected: Rejected (bound must belong to the region).
- Actual: Accepted.
- Evidence: Address 882.
- Root cause:
apps/backend/src/trpc/apis/user-apis/apis/address.tscreate/update do not check thatboundIdbelongs toregionId. Compounding this,AddressFormsubmits the current browsing bound, so the client can send an incoherent pair. - Suggested fix: Validate
bound.regionId === regionIdserver-side; haveAddressFormderive the bound from the chosen address region, not the browsing region.
FC-19 — RG-02: region creation is not atomic on D1
- Status: ✅ Fixed (2026-10-10) —
createRegionWithBoundsnow validates the bounds before touching the DB (≥1 bound, unique priorities) so a bad payload never reaches the inserts, and wraps the post-region inserts in a try/catch that deletes the region + its child rows if anything fails. Reproduced (leftover region 5), then re-verified: the duplicate-priority create now leaves no region behind. - Severity: Medium
- Case: RG-02
- Symptom: A failed region create leaves a half-created region.
- Steps to reproduce:
superadmin.regions.createwith two bounds at priority1. - Expected: Error, no region persisted.
- Actual:
500 "Each bound priority must be unique…"and regionE2E-DupPriorityexists with 0 bounds / 0 consts. - Evidence: Region row 4 with no bounds (removed manually).
- Root cause:
packages/db_helper_sqlite/src/superadmin-apis/regions.tscreateRegionWithBoundswraps inserts indb.transaction, but on D1 the region insert is not rolled back when the bound insert violates the unique priority index. - Suggested fix: Validate bounds (unique priorities, valid geometry) before inserting, or use an atomic D1 batch that fails as a unit.
FC-20 — AU-03 (and D8): error statuses flattened to HTTP 500
- Severity: Low
- Case: AU-03 (same class as the cross-region
getProductById500) - Symptom: Auth/validation/not-found failures return 500 instead of 4xx.
- Steps to reproduce:
user.auth.loginwith a wrong password →500; unknown user →500;admin.product.getProductByIdcross-region →500 "Product not found". - Expected: 401 / 404 respectively.
- Actual: 500.
- Evidence: Response statuses above.
- Root cause:
ApiErrorcarries an HTTP status butapps/backend/src/app.tsonError/ the tRPC error mapping only mapsTRPCErrorcodes, soApiErrorfalls through to 500. - Suggested fix: Translate
ApiError(and thrownErrorwith a status) to the matching HTTP status in the global error handler / tRPC error formatter.
Summary
| Ref | Case | Severity | One-line |
|---|---|---|---|
| FC-01 | SEC-01 | Critical | Customer token mutates global consts — ✅ fixed |
| FC-02 | SEC-04 | High | Cross-region SKU accepted — ✅ fixed |
| FC-03 | SEC-05 | High | Unassigned / OOS / closed-slot items accepted — ✅ fixed |
| FC-04 | SEC-06 | High | User-based coupon used by another user — ✅ fixed |
| FC-05 | SEC-07 | High | Public packaging mutation + expired-snippet leak |
| FC-06 | BL-02 | Medium | Minimum order not enforced — ✅ resolved (constant removed) |
| FC-07 | BL-03/06 | High | Client vs backend delivery-fee divergence — ✅ fixed |
| FC-08 | BL-05 | High | % coupon discounts the delivery fee — ✅ fixed |
| FC-09 | CP-05 | High | SKU-restricted coupon not enforced — ⚪ not a defect for now |
| FC-10 | CP-11 | High | Coupons not region-scoped — ⚪ not a defect for now |
| FC-11 | PD-13 | High | Store delete orphans products — ✅ fixed |
| FC-12 | DS-02 | High | Tag delete fails (FK) — ✅ fixed |
| FC-13 | SL-04 | High | Frozen slot accepted — ✅ fixed |
| FC-14 | CT-07 | High | Cart ignores out-of-stock — ⚪ not a defect (false flag) |
| FC-15 | AU-07 | High | Profile update broken — ✅ fixed |
| FC-16 | AU-08 | High | Password change ineffective — ✅ fixed |
| FC-17 | OR-12 | Medium | No order idempotency — 🟡 client-side guard (server deferred) |
| FC-18 | AD-06 | Medium | Incoherent address region/bound |
| FC-19 | RG-02 | Medium | Non-atomic region create — ✅ fixed |
| FC-20 | AU-03 | Low | Errors return 500 instead of 4xx |
Suggested fix order: FC-01 → FC-02/03/13 (order validation) → FC-07/08 (pricing) → FC-04/09/10 (coupons) → FC-05 (vendor auth) → FC-16/15 (account) → FC-11/12/19 → FC-17/18/20. (FC-09/FC-10/FC-14 closed as false flags.)