enh
This commit is contained in:
parent
eb4d844317
commit
0d3301f3aa
9 changed files with 2411 additions and 704 deletions
|
|
@ -48,7 +48,7 @@ react-native. They are available in the common-ui as MyText, MyTextInput, MyTouc
|
|||
- Database: Drizzle ORM with PostgreSQL
|
||||
|
||||
## Important Notes
|
||||
- Don't do anything with git. Don't do git add or git commit. That will be managed entirely by the user
|
||||
- Don't do anything with git unless the user explicitly asks for. Don't do git add or git commit. That will be managed entirely by the user.
|
||||
|
||||
## Change Log
|
||||
- there should be a change log file. unless explicitly specified, assume change-log.txt as the name of the log file. Ensure the file exists. If it doesn't exist create it. Before changing any file which is not a md file or txt file write the change to that file exactly. Write the diff to it and then start making changes. for every change add the current time stamp.
|
||||
|
|
|
|||
558
docs/full-product-validation-manual-testing-guide.html
Normal file
558
docs/full-product-validation-manual-testing-guide.html
Normal file
|
|
@ -0,0 +1,558 @@
|
|||
<!doctype html>
|
||||
<!-- Generated from docs/full-product-validation-manual-testing-guide.md. Edit the Markdown and regenerate this file. -->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Freshyo manual testing guide</title>
|
||||
<style>
|
||||
:root{--fg:#1f2937;--line:#e5e7eb;--accent:#0f766e;--code-bg:#f3f4f6}
|
||||
*{box-sizing:border-box}
|
||||
html{scroll-behavior:smooth}
|
||||
body{margin:0;background:#f8fafc;color:var(--fg);font:16px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
||||
main{max-width:1000px;margin:0 auto;padding:36px 24px 80px;background:#fff;border-left:1px solid var(--line);border-right:1px solid var(--line)}
|
||||
h1{font-size:2rem;line-height:1.2;margin:0 0 .75rem}
|
||||
h2{font-size:1.4rem;line-height:1.3;margin:2.75rem 0 .75rem;padding-top:1.1rem;border-top:1px solid var(--line)}
|
||||
h3{font-size:1.12rem;line-height:1.35;margin:2rem 0 .5rem}
|
||||
p{margin:.65rem 0}
|
||||
a{color:var(--accent);text-decoration:none}
|
||||
a:hover{text-decoration:underline}
|
||||
code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:var(--code-bg);padding:.12em .35em;border-radius:4px;font-size:.9em}
|
||||
pre{background:#0f172a;color:#e2e8f0;padding:16px;border-radius:8px;overflow:auto;line-height:1.5}
|
||||
pre code{background:none;color:inherit;padding:0;font-size:.88em}
|
||||
table{width:100%;border-collapse:collapse;margin:1rem 0;font-size:.92rem}
|
||||
th,td{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top}
|
||||
th{background:#f1f5f9;font-weight:600}
|
||||
tbody tr:nth-child(even){background:#fafafa}
|
||||
hr{border:0;border-top:1px solid var(--line);margin:2.25rem 0}
|
||||
ol,ul{padding-left:1.55rem;margin:.7rem 0}
|
||||
li{margin:.35rem 0}
|
||||
strong{font-weight:650}
|
||||
.toc{margin:1.5rem 0 0;padding:14px 18px;border:1px solid var(--line);border-radius:8px;background:#f8fafc}
|
||||
.toc ol{margin:.4rem 0 0;padding-left:1.4rem}
|
||||
.toc li{margin:.15rem 0}
|
||||
.top{text-align:right;margin-top:3rem;font-size:.9rem}
|
||||
@media(max-width:720px){body{font-size:15px}main{padding:22px 14px 60px;border:0}table{font-size:.84rem}th,td{padding:6px 7px}h1{font-size:1.6rem}h2{font-size:1.25rem}}
|
||||
@media print{body{background:#fff}main{max-width:none;border:0;padding:0}a{color:inherit}pre{white-space:pre-wrap}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1 id="freshyo-manual-testing-guide">Freshyo manual testing guide</h1>
|
||||
<p>This guide is for someone testing Freshyo by using the apps — no technical knowledge needed. You only need to use the screens, buttons and test accounts described here. If the app shows it, you can test it.</p>
|
||||
<p>The reference numbers such as <code>CUST-31</code>, <code>ADM-05</code> or <code>BR-14</code> are only for writing down what you tested and reporting a problem. You can ignore them while testing.</p>
|
||||
<p><strong>What this guide covers:</strong> the customer app (mobile and web), the admin app (mobile and web), the superadmin website, and the cross-app journeys between them.</p>
|
||||
<p><strong>What it does not cover:</strong> checks that are not visible in the apps. Those are handled separately.</p>
|
||||
<hr>
|
||||
<nav class="toc"><strong>Contents</strong><ol><li><a href="#before-you-test">Before you test</a></li><li><a href="#1-customer-app-mobile-and-web">1. Customer app — mobile and web</a></li><li><a href="#2-admin-app-mobile-and-web">2. Admin app — mobile and web</a></li><li><a href="#3-superadmin-website">3. Superadmin website</a></li><li><a href="#4-cross-app-journeys">4. Cross-app journeys</a></li><li><a href="#5-special-regression-checks">5. Special regression checks</a></li><li><a href="#6-other-screens-only-if-your-coordinator-says-they-are-active">6. Other screens (only if your coordinator says they are active)</a></li><li><a href="#7-known-issues">7. Known issues</a></li><li><a href="#8-reporting-a-problem">8. Reporting a problem</a></li></ol></nav>
|
||||
<h2 id="before-you-test">Before you test</h2>
|
||||
<h3 id="what-you-need">What you need</h3>
|
||||
<p>Ask your test coordinator for:</p>
|
||||
<ul><li><strong>Test accounts</strong> — a customer account, a second customer account, a brand-new customer account, an admin account for each test area, and a superadmin account.</li><li><strong>Sample data</strong> — two delivery areas (called A and B in this guide), products, delivery slots, and coupons.</li><li><strong>A test phone or browser</strong> — the mobile app on a test phone, and the web apps in a browser.</li><li><strong>A way to take screenshots</strong> — for any failure.</li></ul>
|
||||
<p>Do not use a real customer's account, phone number, address, or payment details. Use only the test accounts and test area given to you.</p>
|
||||
<h3 id="names-used-in-this-guide">Names used in this guide</h3>
|
||||
<p>These are just labels for the test data. Your coordinator may use different names; if so, use theirs.</p>
|
||||
<table>
|
||||
<thead><tr><th>Name</th><th>What it means</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>Customer 1</td><td>The main test customer, with saved addresses in area A</td></tr>
|
||||
<tr><td>Customer 2</td><td>A second customer, with an address in area B</td></tr>
|
||||
<tr><td>New Customer</td><td>A customer with no saved address and no orders</td></tr>
|
||||
<tr><td>Admin A / Admin B</td><td>Staff accounts for area A and area B</td></tr>
|
||||
<tr><td>Superadmin</td><td>The account that manages areas, staff and global products</td></tr>
|
||||
<tr><td>Area A / Area B</td><td>The two delivery areas used for testing</td></tr>
|
||||
<tr><td>Product P / Q / G</td><td>Test products: P in A, Q in B, G available in both</td></tr>
|
||||
<tr><td>Slot S1 / S2</td><td>Future delivery time slots in area A</td></tr>
|
||||
<tr><td>Coupon 10% / Coupon ₹100</td><td>Test coupons used for money checks</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="how-to-write-down-a-result">How to write down a result</h3>
|
||||
<p>For each check, note:</p>
|
||||
<ol><li>What you did.</li><li>What you expected to see.</li><li>What you actually saw.</li><li>A screenshot, if it failed.</li></ol>
|
||||
<p>Use the reference number from this guide so the team can find the check quickly.</p>
|
||||
<h3 id="if-you-get-stuck">If you get stuck</h3>
|
||||
<ul><li>If a screen is loading forever, wait up to one minute, then note the screen and try again once.</li><li>If data is missing (no products, no slots, no coupons), ask your coordinator; do not change real customer data.</li><li>If a test changes money, orders, or customer data, use only the test accounts.</li></ul>
|
||||
<hr>
|
||||
<h2 id="1-customer-app-mobile-and-web">1. Customer app — mobile and web</h2>
|
||||
<p>Use the same steps on the mobile app and on the website unless a step says otherwise.</p>
|
||||
<h3 id="1-1-sign-in-create-an-account-and-manage-your-profile">1.1 Sign in, create an account and manage your profile</h3>
|
||||
<p><strong>What this tests:</strong> signing in, creating an account, staying signed in, signing out, changing details, and what happens when an account is suspended.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open the customer app without signing in.</li><li>Open <strong>Cart</strong> and <strong>Me</strong>. Check that you are asked to sign in, and that you can still browse the Home page.</li><li>From the Cart sign-in prompt, sign in as Customer 1. Add a product before signing in to check that the cart is still there afterwards.</li><li>Sign out, then try a wrong password. Sign in correctly.</li><li>Create a new account with the <strong>New Customer</strong> details.</li><li>Try creating an account with an existing mobile/email and with missing fields.</li><li>Close and reopen the app. Check that you are still signed in.</li><li>Open <strong>Me</strong> → edit your name/profile photo → save → reopen the app.</li><li>Change your password, sign out, and try the old and new passwords.</li><li>Sign in as Customer 2. Check that Customer 1's orders, addresses and coupons are not visible.</li><li>Ask the admin to suspend Customer 1, then try to place an order. Ask the admin to unsuspend and try again.</li><li>On a disposable test account, use <strong>Delete Me and My Data</strong> and try a wrong confirmation first, then the correct one.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-09</code></td><td>Browsing works signed out; Cart and Me ask you to sign in.</td></tr>
|
||||
<tr><td><code>CUST-10</code></td><td>You return to the screen you came from; the cart survives sign-in; errors are clear.</td></tr>
|
||||
<tr><td><code>CUST-11</code></td><td>A wrong password does not sign you in; Customer 2 cannot see Customer 1's data.</td></tr>
|
||||
<tr><td><code>CUST-12</code></td><td>You stay signed in after reopening; an expired sign-in asks you to sign in again safely.</td></tr>
|
||||
<tr><td><code>CUST-13</code></td><td>Your name/photo are saved and match what the admin sees.</td></tr>
|
||||
<tr><td><code>CUST-14</code></td><td>The new password works and the old one does not.</td></tr>
|
||||
<tr><td><code>CUST-15</code></td><td>Wrong confirmation is rejected; correct confirmation removes access.</td></tr>
|
||||
<tr><td><code>CUST-16</code></td><td>A suspended customer cannot order; unsuspending allows ordering again.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-2-choose-the-delivery-area">1.2 Choose the delivery area</h3>
|
||||
<p><strong>What this tests:</strong> the app finding the right delivery area, asking you when it cannot, and keeping the right products and cart when you switch areas.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open the app in area A. Allow location access if asked.</li><li>Check the delivery area/address shown on Home.</li><li>Close and reopen the app with location denied, location off, and a point outside the service area.</li><li>Open the area/address chooser and select area B manually. If a location request arrives late, check that it does not change your choice.</li><li>Sign in as Customer 1 and switch between the saved addresses in A1 and A2.</li><li>Add products to the regular cart and the 1-hour cart. Switch to B; cancel the switch, then confirm it.</li><li>Switch back to A and check the cart.</li><li>Close the app with a cart and reopen it.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-01</code></td><td>The correct area loads once; products and slots appear.</td></tr>
|
||||
<tr><td><code>CUST-02</code></td><td>A saved address is used when location is unavailable; otherwise a chooser explains the problem.</td></tr>
|
||||
<tr><td><code>CUST-03</code></td><td>A late location result does not override your manual choice.</td></tr>
|
||||
<tr><td><code>CUST-04</code></td><td>The selected address decides the delivery zone and charges; another area's address is ignored.</td></tr>
|
||||
<tr><td><code>CUST-05</code></td><td>Cancel keeps everything; confirm clears area A selections and loads B.</td></tr>
|
||||
<tr><td><code>CUST-06</code></td><td>Each area keeps its own cart; switching back restores it.</td></tr>
|
||||
<tr><td><code>CUST-07</code></td><td>A cart is not wiped just because the app picks the first area on launch.</td></tr>
|
||||
<tr><td><code>CUST-08</code></td><td>An empty area shows a friendly empty state, not an error.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-3-home-search-stores-and-product-details">1.3 Home, search, stores and product details</h3>
|
||||
<p><strong>What this tests:</strong> that area A and area B show the right products, stores, offers and prices, and that product details and add-to-cart work from every entry point.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open Home in area A. Note the products, offers, stores and delivery slots.</li><li>Switch to area B and compare.</li><li>Use <strong>Search</strong> for a product name, an offer/tag, and a store name. Also search for something that does not exist.</li><li>Open <strong>Stores</strong> → a store → a product. Open the global test product G.</li><li>Open a product with variants, a combo, and a 1-hour product.</li><li>Add the same product from Home, Search, a store and the product page.</li><li>Open the quantity selector and try the smallest, largest and an out-of-stock item.</li><li>Tap an offer, tag or banner and follow where it goes.</li><li>Open the delivery address/area bar and change the address.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-17</code></td><td>Area A shows A + global products; area B shows B + global products; no cross-area products or prices.</td></tr>
|
||||
<tr><td><code>CUST-18</code></td><td>Loading, empty, error and refresh states make sense; Retry works.</td></tr>
|
||||
<tr><td><code>CUST-19</code></td><td>Search returns only products/stores for the chosen area; no results shows a clear empty state.</td></tr>
|
||||
<tr><td><code>CUST-20</code></td><td>Store lists and store pages show the right products; the global store appears in both areas.</td></tr>
|
||||
<tr><td><code>CUST-21</code></td><td>Product page shows the correct price, variants, stock, combo contents and 1-hour availability.</td></tr>
|
||||
<tr><td><code>CUST-22</code></td><td>The same product added from different screens gives the same item, quantity and price.</td></tr>
|
||||
<tr><td><code>CUST-23</code></td><td>You cannot add more than allowed; out-of-stock items cannot be added.</td></tr>
|
||||
<tr><td><code>CUST-24</code></td><td>Tapping an offer/banner opens the intended product or store.</td></tr>
|
||||
<tr><td><code>CUST-25</code></td><td>The current address is shown; changing it updates the delivery area and prices.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-4-cart">1.4 Cart</h3>
|
||||
<p><strong>What this tests:</strong> adding, changing and removing items, saving the cart, notes, delivery slots, and what happens when an item becomes unavailable.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Add a product. Add it again from the product page.</li><li>Increase and decrease the quantity. Remove a line and cancel the removal; then remove it for real.</li><li>Close and reopen the app with items in the regular cart and the 1-hour cart.</li><li>Assign a delivery slot to each item. Leave the cart, come back, and reopen the app.</li><li>Add a note for the order. Go to checkout, come back, and change the note.</li><li>Ask your coordinator to mark one test product out of stock or unavailable. Refresh the cart.</li><li>Close and reopen with an old saved cart.</li><li>Sign out and sign in as Customer 2 with Customer 1's cart still saved.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-26</code></td><td>Adding again merges correctly; changing quantity replaces it; removing affects only that line.</td></tr>
|
||||
<tr><td><code>CUST-27</code></td><td>Regular and 1-hour carts both come back after reopening.</td></tr>
|
||||
<tr><td><code>CUST-28</code></td><td>Your slot choice is still there after leaving and returning.</td></tr>
|
||||
<tr><td><code>CUST-29</code></td><td>Unavailable items are shown clearly and cannot be ordered; if all items are unavailable, checkout is blocked.</td></tr>
|
||||
<tr><td><code>CUST-30</code></td><td>The latest note is the one shown at checkout and saved with the order.</td></tr>
|
||||
<tr><td><code>CUST-37</code></td><td>A damaged/old saved cart does not create a fake product or a wrong price.</td></tr>
|
||||
<tr><td><code>CUST-38</code></td><td>Another customer cannot see or use your cart, address or notes.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-5-coupons">1.5 Coupons</h3>
|
||||
<p><strong>What this tests:</strong> which coupons you can see, why some are disabled, and how multiple coupons change the bill.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open the cart with several items and open the coupon list.</li><li>Look for eligible coupons, a coupon for the other area, a first-order coupon, a minimum-spend coupon, a product-specific coupon, an expired coupon, a used coupon and another customer's coupon.</li><li>Apply a 10% coupon, then a ₹100 coupon. Remove them and apply them in the opposite order.</li><li>Change a quantity and check that the discount recalculates.</li><li>Try a coupon that gives 100% off and a coupon whose discount is bigger than the cart.</li><li>Check the <strong>Products discount</strong> line in the bill.</li><li>Open <strong>Me → Coupons</strong> and compare the labels with the cart.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-31</code></td><td>Expired, invalid or used-up coupons are not shown. Other coupons show a clear reason when disabled.</td></tr>
|
||||
<tr><td><code>CUST-32</code></td><td>The bill and each coupon's saving update when you add, remove or change items.</td></tr>
|
||||
<tr><td><code>CUST-33</code></td><td>Applying the same coupons in a different order can give a different total; the total never goes below zero.</td></tr>
|
||||
<tr><td><code>CUST-34</code></td><td>The Products discount line appears only when there is a product saving; coupon lines are separate.</td></tr>
|
||||
<tr><td><code>CUST-36</code></td><td>The cart total, checkout total and saved order total match.</td></tr>
|
||||
<tr><td><code>CUST-57</code></td><td>The Coupons page agrees with the cart: available, used and expired are labelled correctly.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-6-checkout-and-placing-an-order">1.6 Checkout and placing an order</h3>
|
||||
<p><strong>What this tests:</strong> choosing an address and slot, applying coupons, paying by cash on delivery, and the safeguards that stop a wrong or duplicate order.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open the cart, select a saved address in area A, assign slots, and tap <strong>Checkout</strong>.</li><li>Check the address, items, slot, coupon, delivery charge and total.</li><li>Look at the payment methods. <strong>Cash on Delivery</strong> should be selected; <strong>Pay Online (Coming Soon)</strong> should be disabled.</li><li>Go back to the cart, change the address, slot, coupon or note, and return to checkout.</li><li>Tap <strong>Place Order</strong> twice quickly.</li><li>Place a valid order.</li><li>Note the order number and total on the success screen.</li><li>Open <strong>My Orders</strong> and compare the order.</li><li>As the New Customer with no address, open Cart and Checkout.</li><li>Try checkout with an item that has no delivery slot.</li><li>Place a 1-hour order in area A. Then try the 1-hour flow in area B.</li><li>Use the back button, refresh the browser, and open the success/detail link again.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-39</code></td><td>The selected address decides the delivery charge and area.</td></tr>
|
||||
<tr><td><code>CUST-40</code></td><td>A customer with no address is asked to add one before checkout.</td></tr>
|
||||
<tr><td><code>CUST-41</code></td><td>Each item carries its own delivery slot; no item is sent without a slot.</td></tr>
|
||||
<tr><td><code>CUST-42</code></td><td>Only Cash on Delivery is usable; the online option is visibly disabled.</td></tr>
|
||||
<tr><td><code>CUST-43</code></td><td>The latest address/slot/coupon/note is shown at checkout.</td></tr>
|
||||
<tr><td><code>CUST-44</code></td><td>A fast double tap places only one order.</td></tr>
|
||||
<tr><td><code>CUST-45</code></td><td>A failed order shows an error, the button works again, and your cart is kept.</td></tr>
|
||||
<tr><td><code>CUST-46</code></td><td>If the response is lost, check My Orders before trying again.</td></tr>
|
||||
<tr><td><code>CUST-48</code></td><td>A multi-slot or zero-total order shows the correct order number and total.</td></tr>
|
||||
<tr><td><code>CUST-49</code></td><td>1-hour ordering works in A and is blocked in B.</td></tr>
|
||||
<tr><td><code>CUST-50</code></td><td>Back/refresh/deep links do not create a second order or show another order.</td></tr>
|
||||
<tr><td><code>CUST-35</code></td><td>An item with no slot, or a slot that has closed, blocks checkout; a 1-hour cart is not blocked by this rule.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-7-orders-cancellation-and-complaints">1.7 Orders, cancellation and complaints</h3>
|
||||
<p><strong>What this tests:</strong> finding orders, reading the bill, cancelling, ordering again, and raising a complaint.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Me → My Orders</strong>. Look at pending, delivered and cancelled orders.</li><li>Open an order. Check items, address, delivery time, bill, status and notes.</li><li>Cancel a new order. Enter a reason and confirm.</li><li>Try cancelling a delivered order.</li><li>On a cancelled/delivered order, use <strong>Order Again</strong>.</li><li>Ask the admin to delete or hide a product you ordered. Open the old order.</li><li>Tap <strong>Raise Complaint</strong>, add a message and an image, and submit.</li><li>Ask the admin to reply, then reopen the complaint.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-51</code></td><td>Orders are listed with the correct status and can be scrolled/paged.</td></tr>
|
||||
<tr><td><code>CUST-52</code></td><td>The order detail matches the bill and what the admin sees.</td></tr>
|
||||
<tr><td><code>CUST-53</code></td><td>A reason is required; cancelled/delivered orders follow the rules.</td></tr>
|
||||
<tr><td><code>CUST-54</code></td><td>Order Again adds the available items; unavailable items are handled clearly.</td></tr>
|
||||
<tr><td><code>CUST-55</code></td><td>The complaint is saved and the admin reply is visible.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-8-addresses">1.8 Addresses</h3>
|
||||
<p><strong>What this tests:</strong> adding, editing, making default and deleting addresses, and checking that the map location chooses the right delivery area.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Me → Addresses</strong>.</li><li>Add an address using the map and the test area.</li><li>Try an address outside the service area.</li><li>Add a second address and make it the default.</li><li>Edit the address details and move the map pin.</li><li>Delete an address that is being used by an open order, then a free address.</li><li>Delete the default address, then the last address.</li><li>Open the cart and checkout after deleting the last address.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-56</code></td><td>The map location picks the correct area/zone; an outside point is rejected; the first address becomes default; an address used by an open order cannot be deleted.</td></tr>
|
||||
<tr><td><code>CUST-40</code></td><td>With no address, the app asks you to add one before checkout.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="1-9-profile-coupons-and-notifications">1.9 Profile, coupons and notifications</h3>
|
||||
<p><strong>What this tests:</strong> the remaining customer screens and what happens when the connection is poor.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Me</strong> and visit each item: My Orders, Coupons, Addresses, Help & Complaints, Terms and profile settings.</li><li>Turn the phone/browser offline and open Home, cart and checkout.</li><li>Allow notifications, add an address, and open a notification link.</li><li>Use the app with a small screen/keyboard and check that buttons are reachable.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>CUST-58</code></td><td>Notification permission is handled; the link opens the right order/product.</td></tr>
|
||||
<tr><td><code>CUST-59</code></td><td>Offline screens show a clear error and Retry; no fake success.</td></tr>
|
||||
<tr><td><code>CUST-60</code></td><td>Keyboard/safe-area/back navigation work; important buttons are readable and reachable.</td></tr>
|
||||
</tbody></table>
|
||||
<hr>
|
||||
<h2 id="2-admin-app-mobile-and-web">2. Admin app — mobile and web</h2>
|
||||
<p>Use the same steps on the admin mobile app and the admin website. The website may ask you to sign in again after a refresh; that is part of the test.</p>
|
||||
<h3 id="2-1-sign-in-and-area-access">2.1 Sign in and area access</h3>
|
||||
<p><strong>What this tests:</strong> admin sign-in, staying signed in, and making sure an admin sees only their own area.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Sign in as Admin A. Open the Dashboard.</li><li>Refresh the page (web) or reopen the app (mobile).</li><li>Sign out and sign in as Admin B.</li><li>Use the browser/device back button to return to an Admin A screen.</li><li>Try to open an admin screen without signing in.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-01</code></td><td>Admin A signs in, stays signed in, and sees the correct area.</td></tr>
|
||||
<tr><td><code>ADM-02</code></td><td>Admin A and Admin B see only their own orders, products and counts.</td></tr>
|
||||
<tr><td><code>ADM-03</code></td><td>After switching to B, Admin A's data is gone and old links are blocked.</td></tr>
|
||||
<tr><td><code>ADM-04</code></td><td>Signed-out users cannot reach admin screens or actions.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="2-2-orders">2.2 Orders</h3>
|
||||
<p><strong>What this tests:</strong> finding orders, reading details, changing status, cancelling, changing the delivery charge, and arranging delivery order.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Manage Orders → Orders</strong>. Use the filters and search; scroll to the next page.</li><li>Ask Admin B to create several newer orders, then return to Admin A and page through A's orders.</li><li>Open an order. Compare the items, bill, address, notes and customer details.</li><li>Mark the order <strong>Packaged</strong>, then <strong>Delivered</strong>.</li><li>Open the customer app and check the status.</li><li>Cancel another order with a reason.</li><li>Open a delivered order and try to cancel it.</li><li>Remove the delivery charge from a test order.</li><li>Use <strong>Rebalance</strong> on a slot and compare the bill.</li><li>Open <strong>Delivery Sequences</strong>, change the order, and update one order's map location.</li><li>Add an admin note and check the customer note.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-05</code></td><td>Filters, search and pages show the right orders.</td></tr>
|
||||
<tr><td><code>ADM-06</code></td><td>Admin A sees all of A's orders even when other areas have newer orders.</td></tr>
|
||||
<tr><td><code>ADM-07</code></td><td>The order detail matches the customer's bill.</td></tr>
|
||||
<tr><td><code>ADM-08</code></td><td>Packaged/delivered changes are saved and visible to the customer.</td></tr>
|
||||
<tr><td><code>ADM-09</code></td><td>Cancellation needs a reason; a delivered order cannot be cancelled by the customer.</td></tr>
|
||||
<tr><td><code>ADM-10</code></td><td>Rebalancing keeps the total and discount correct.</td></tr>
|
||||
<tr><td><code>ADM-11</code></td><td>Delivery order and map changes affect only the intended order.</td></tr>
|
||||
<tr><td><code>ADM-12</code></td><td>Admin and customer notes appear in the right place.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="2-3-products-prices-and-stock">2.3 Products, prices and stock</h3>
|
||||
<p><strong>What this tests:</strong> creating and editing products, changing prices/stock, handling global products, and avoiding duplicate variants.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Products</strong>. Search for Product P and open its details.</li><li>Create a new test product with two variants, an image, features and tags.</li><li>Open the customer app in area A and find it.</li><li>Edit the product's price, stock, offer and 1-hour availability.</li><li>Edit the global product G's price/stock/suspension for area A.</li><li>Open the customer app in area B and compare.</li><li>Suspend a global product in A, reopen it, change only the price, and save.</li><li>Ask the superadmin to edit G's variants. Count the variants before and after.</li><li>Delete a product that has orders/variants; then delete a free test product.</li><li>Open <strong>Prices Overview</strong> and update a price.</li><li>Create/edit/delete a tag, group and combo; assign products.</li><li>Upload a product image.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-13</code></td><td>The products list and details show the right area and stock state.</td></tr>
|
||||
<tr><td><code>ADM-14</code></td><td>The new product is saved and appears only in A.</td></tr>
|
||||
<tr><td><code>ADM-15</code></td><td>Price/stock/offer changes are saved and visible to the customer.</td></tr>
|
||||
<tr><td><code>ADM-16</code></td><td>Editing a global product in A changes only A's price/stock.</td></tr>
|
||||
<tr><td><code>ADM-17</code></td><td>A suspended product stays suspended after an unrelated price change.</td></tr>
|
||||
<tr><td><code>ADM-18</code></td><td>A product with orders/variants cannot be deleted; a free one can.</td></tr>
|
||||
<tr><td><code>ADM-19</code></td><td>Price edits are saved and the customer sees the new price.</td></tr>
|
||||
<tr><td><code>ADM-20</code></td><td>Tags and their order match the customer app.</td></tr>
|
||||
<tr><td><code>ADM-21</code></td><td>Groups and slots keep the right products.</td></tr>
|
||||
<tr><td><code>ADM-22</code></td><td>A combo shows the right components and price.</td></tr>
|
||||
<tr><td><code>ADM-34</code></td><td>Uploaded images appear on the product.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="2-4-stores-and-delivery-slots">2.4 Stores and delivery slots</h3>
|
||||
<p><strong>What this tests:</strong> store details and the delivery slots customers can choose.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Stores</strong>. Create a store, edit it, and upload an image.</li><li>Open the global store and try to edit it.</li><li>Delete a store with products/orders, then a free store.</li><li>Open <strong>Slots</strong>. Create a future slot and assign products.</li><li>Edit its time, capacity and freeze time.</li><li>Fill or freeze the slot and open the customer cart.</li><li>Replicate or copy a slot.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-23</code></td><td>Regional stores are editable; the global store is read-only; images are safe.</td></tr>
|
||||
<tr><td><code>ADM-24</code></td><td>New/edited/full/frozen slots behave correctly for the customer.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="2-5-coupons-banners-and-home-layout">2.5 Coupons, banners and home layout</h3>
|
||||
<p><strong>What this tests:</strong> regional coupons, banners and the order of items on Home.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Coupons</strong>. Create a 10% coupon, a ₹100 coupon, one for selected products, and one for selected customers.</li><li>Use them in the customer app.</li><li>Edit and invalidate a coupon; try it again.</li><li>Open <strong>Banners</strong>. Create, edit, activate, deactivate and reorder banners.</li><li>Check the customer Home in A.</li><li>Open <strong>Customize App</strong> and change the Popular Items and All Items order.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-25</code></td><td>Coupons work only in the right area/for the right products/users.</td></tr>
|
||||
<tr><td><code>ADM-26</code></td><td>Only active banners appear, in the chosen order.</td></tr>
|
||||
<tr><td><code>ADM-27</code></td><td>The customer Home matches the chosen order.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="2-6-users-complaints-and-notifications">2.6 Users, complaints and notifications</h3>
|
||||
<p><strong>What this tests:</strong> finding customers, suspending them, adding incidents, replying to complaints and sending notifications.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>User Management</strong>. Search by Customer 1's name and mobile.</li><li>Sign in as Admin B and search for the same customer.</li><li>Open a customer. Suspend, unsuspend, and add an incident note.</li><li>Open <strong>Complaints</strong>, open a customer complaint, reply and resolve it.</li><li>Open the customer app and check the reply.</li><li>Open <strong>Send Notifications</strong>, select a test user, and send a test message.</li><li>Open <strong>Constants</strong> and change a test setting; check the customer app.</li><li>If <strong>Vendor Snippets</strong> is enabled for your test, open it, create a snippet, add a product, and open the slot picker. Refresh the website and try again.</li><li>Open a screen with no data (for example, a new area with no orders) and use the back/Retry buttons.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>ADM-28</code></td><td>Customer details are visible only to the right area.</td></tr>
|
||||
<tr><td><code>ADM-29</code></td><td>Admin B cannot find Admin A's customers by name or mobile.</td></tr>
|
||||
<tr><td><code>ADM-30</code></td><td>Suspension and incidents are saved; notifications go only to selected test users.</td></tr>
|
||||
<tr><td><code>ADM-31</code></td><td>Complaints are area-scoped and the customer sees the reply.</td></tr>
|
||||
<tr><td><code>ADM-32</code></td><td>Vendor snippets stay in your area and the slot picker still loads after a refresh.</td></tr>
|
||||
<tr><td><code>ADM-33</code></td><td>The changed setting appears for the customer; the other area is unchanged.</td></tr>
|
||||
<tr><td><code>ADM-35</code></td><td>Empty/loading/error screens show a clear message; Retry/back works.</td></tr>
|
||||
</tbody></table>
|
||||
<hr>
|
||||
<h2 id="3-superadmin-website">3. Superadmin website</h2>
|
||||
<p>The superadmin sets up areas, staff, global products and global coupons. Use only the test areas and test accounts given to you.</p>
|
||||
<h3 id="3-1-sign-in-and-delivery-areas">3.1 Sign in and delivery areas</h3>
|
||||
<p><strong>What this tests:</strong> superadmin access, area setup, and the map/zone used for delivery.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Sign in as Superadmin. Sign out, sign in again, and refresh.</li><li>Open <strong>Regions</strong>. Select area A.</li><li>Review the area name, delivery charge, free-delivery amount, 1-hour settings and support details.</li><li>If instructed, add a new test area with one delivery zone using the map.</li><li>Try to save an area without a zone, or with an invalid/duplicate zone.</li><li>Add, edit and delete a test zone. Try deleting the last zone.</li><li>Open the customer area chooser and check that the new/edited area appears.</li><li>Change an area's settings and check the customer app.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>SA-01</code></td><td>Superadmin signs in and stays signed in; staff/customer pages are not accessible.</td></tr>
|
||||
<tr><td><code>SA-02</code></td><td>A new area can be created and appears for customers.</td></tr>
|
||||
<tr><td><code>SA-03</code></td><td>Missing/invalid zones are rejected without creating a broken area.</td></tr>
|
||||
<tr><td><code>SA-04</code></td><td>A zone can be edited/deleted only when allowed.</td></tr>
|
||||
<tr><td><code>SA-05</code></td><td>A new area gets the right products and prices.</td></tr>
|
||||
<tr><td><code>SA-06</code></td><td>The new area's products and pages open normally.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="3-2-staff-and-global-stores">3.2 Staff and global stores</h3>
|
||||
<p><strong>What this tests:</strong> creating staff, assigning an area, and managing shared stores.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Admin Users</strong>. Add a test admin for area A and one for area B.</li><li>Change an admin's area/role, then sign in as that admin.</li><li>Remove a test admin and try to sign in.</li><li>Open <strong>Global stores</strong>. Create, edit and delete a test global store.</li><li>Check the store in both customer areas.</li><li>Sign in as Admin A and try to edit the global store.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>SA-07</code></td><td>Staff get the right area/role; removed staff cannot sign in.</td></tr>
|
||||
<tr><td><code>SA-08</code></td><td>A global store appears in both areas; regional admins cannot edit it.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="3-3-global-products">3.3 Global products</h3>
|
||||
<p><strong>What this tests:</strong> products shared by all areas, with different local prices.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Global products</strong>. Create a test global product with two variants.</li><li>Set different prices for area A and area B.</li><li>Check the product in both customer areas.</li><li>Edit the product, save, and save again without changes.</li><li>Count the variants in the admin/customer screens.</li><li>Open Create, then Edit, then Create again; check the form fields.</li><li>Suspend the product in one area and check the other.</li><li>Use <strong>Elevate</strong> on a regional product.</li><li>Upload a global product image.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>SA-09</code></td><td>The global product appears in both areas with the local price.</td></tr>
|
||||
<tr><td><code>SA-10</code></td><td>Editing does not create duplicate variants.</td></tr>
|
||||
<tr><td><code>SA-11</code></td><td>The form shows the selected product and resets when you start a new one.</td></tr>
|
||||
<tr><td><code>SA-12</code></td><td>Suspending in one area does not suspend it in the other.</td></tr>
|
||||
<tr><td><code>SA-13</code></td><td>An elevated product remains available in its original area.</td></tr>
|
||||
<tr><td><code>SA-21</code></td><td>The image appears in both areas.</td></tr>
|
||||
</tbody></table>
|
||||
<h3 id="3-4-global-coupons-settings-and-notifications">3.4 Global coupons, settings and notifications</h3>
|
||||
<p><strong>What this tests:</strong> coupons shared by all areas, global settings, and admin notifications.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Open <strong>Global coupons</strong>. Create a percentage coupon and a ₹ discount coupon.</li><li>Use them in both customer areas.</li><li>Edit a 20% coupon to ₹50 and save.</li><li>Use it again and check the discount.</li><li>Invalidate/delete the coupon and try it again.</li><li>Open <strong>Constants</strong>. Change a global test setting and compare both areas.</li><li>Open <strong>Complaints</strong> and reply to a test complaint.</li><li>Open <strong>Send Notifications → Admin Notifs</strong> and send a test message.</li><li>Switch between area tabs and refresh.</li><li>Open an empty screen and a delete confirmation; try Cancel and then Confirm on a disposable test item.</li></ol>
|
||||
<p><strong>What you should see:</strong></p>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>Expected result</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>SA-14</code></td><td>Global coupons work in both areas.</td></tr>
|
||||
<tr><td><code>SA-15</code></td><td>Switching from percentage to ₹ discount uses only the new discount.</td></tr>
|
||||
<tr><td><code>SA-16</code></td><td>Global settings apply everywhere; local settings still win.</td></tr>
|
||||
<tr><td><code>SA-17</code></td><td>Complaints show the right area and reply.</td></tr>
|
||||
<tr><td><code>SA-18</code></td><td>Admin Notifs sends successfully as superadmin.</td></tr>
|
||||
<tr><td><code>SA-19</code></td><td>Staff/customer accounts cannot open superadmin screens.</td></tr>
|
||||
<tr><td><code>SA-20</code></td><td>Empty/loading/error screens are clear; Cancel does not delete data.</td></tr>
|
||||
<tr><td><code>SA-22</code></td><td>Area tabs show the right area and refresh after a rename.</td></tr>
|
||||
<tr><td><code>SA-23</code></td><td>A global edit reaches all areas after a short wait.</td></tr>
|
||||
</tbody></table>
|
||||
<hr>
|
||||
<h2 id="4-cross-app-journeys">4. Cross-app journeys</h2>
|
||||
<p>These checks use more than one app. Keep the same test accounts and data.</p>
|
||||
<h3 id="4-1-full-order-journey">4.1 Full order journey</h3>
|
||||
<p><strong>What this tests:</strong> the complete path from setup to delivery.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Superadmin: confirm area A exists and create Admin A if needed.</li><li>Admin A: create a test store, product P, future slot S1 and a 10% coupon.</li><li>Customer 1: open area A, find P, add it, choose S1, apply the coupon and checkout.</li><li>Place the order with Cash on Delivery.</li><li>Admin A: find the order, compare the items and bill, mark Packaged, then Delivered.</li><li>Customer 1: open My Orders and check the status.</li><li>Compare the order number and total everywhere.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-01</code> — the same order and total appear at every step, and the status ends as Delivered.</p>
|
||||
<h3 id="4-2-global-product-in-two-areas">4.2 Global product in two areas</h3>
|
||||
<p><strong>What this tests:</strong> one shared product with different local prices.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Superadmin: create global product G with an A price and a B price.</li><li>Customer 1 in A: open G and note the price.</li><li>Customer 2 in B: open G and note the price.</li><li>Admin A: change the A price.</li><li>Admin B: change the B price.</li><li>Refresh both customer apps.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-02</code> — each area keeps its own price; changing A does not change B.</p>
|
||||
<h3 id="4-3-switching-areas-with-a-cart">4.3 Switching areas with a cart</h3>
|
||||
<p><strong>What this tests:</strong> that areas do not mix products or carts.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Customer 1: add a regular product and a 1-hour product in area A.</li><li>Switch to area B and cancel; check that A is still there.</li><li>Switch to B and confirm; add a B product.</li><li>Switch back to A; check the A cart.</li><li>Switch to B; check the B cart.</li><li>Repeat on the website.</li><li>Close and reopen the app.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-03</code> — no product or price from the other area appears; each cart comes back when you return to its area.</p>
|
||||
<h3 id="4-4-coupons-on-the-bill">4.4 Coupons on the bill</h3>
|
||||
<p><strong>What this tests:</strong> multiple coupons and the final payable amount.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Build a ₹1000 cart.</li><li>Apply 10% then ₹100; note the discount and total.</li><li>Reverse the order; note the difference.</li><li>Place the order.</li><li>Compare the cart, checkout, success screen, My Orders and Admin A's order.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-04</code> — the total is the same on every screen and never goes below zero.</p>
|
||||
<h3 id="4-5-1-hour-delivery">4.5 1-hour delivery</h3>
|
||||
<p><strong>What this tests:</strong> 1-hour products, prices and area availability.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>In area A, open the 1-hour section and add a 1-hour product.</li><li>Check the 1-hour price and delivery charge.</li><li>Place a Cash on Delivery order.</li><li>Admin A: open the order and confirm it is a 1-hour order.</li><li>Customer 2 in area B: try the 1-hour section for the same product.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-05</code> — A can order; B is blocked; the admin sees the right type of order.</p>
|
||||
<h3 id="4-6-two-delivery-slots-in-one-order">4.6 Two delivery slots in one order</h3>
|
||||
<p><strong>What this tests:</strong> one order split into two delivery times with one delivery fee.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Add a product for S1 and another for S2 in the same cart.</li><li>Checkout and place the order.</li><li>Admin A: open the order and check both slots.</li><li>Mark one part delivered, then the other.</li><li>Customer 1: check both statuses.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-06</code> — two delivery parts, one delivery fee, and the correct status for each part.</p>
|
||||
<h3 id="4-7-cancel-and-use-the-coupon-again">4.7 Cancel and use the coupon again</h3>
|
||||
<p><strong>What this tests:</strong> cancelling an order and releasing a one-time coupon.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>New Customer: place an order with a first-order coupon.</li><li>Cancel it with a reason.</li><li>Place a new order and use the same coupon.</li><li>Place a two-slot order with the coupon and cancel one part.</li><li>Cancel the other part.</li><li>Try the coupon again.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-07</code> — the coupon becomes usable again only when no part of the order remains.</p>
|
||||
<h3 id="4-8-website-checkout-with-two-slots">4.8 Website checkout with two slots</h3>
|
||||
<p><strong>What this tests:</strong> the website sends the chosen delivery slot for each item.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>On the website, add items for S1 and S2.</li><li>Choose both slots in the cart and open Checkout.</li><li>Place the order.</li><li>Open the order and check both slots.</li><li>Try again with one item that has no slot.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-08</code> — the order saves both slots; an item without a slot blocks checkout.</p>
|
||||
<h3 id="4-9-admin-search-by-area">4.9 Admin search by area</h3>
|
||||
<p><strong>What this tests:</strong> an admin can find only their own area's customers.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Customer 1 orders in A; Customer 2 orders in B.</li><li>Admin A searches for Customer 2's name and mobile.</li><li>Admin B searches for Customer 1's name and mobile.</li><li>Search for a name that exists in both areas.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-09</code> — each admin sees only their own area's customers and mobile numbers.</p>
|
||||
<h3 id="4-10-global-update-reaches-both-areas">4.10 Global update reaches both areas</h3>
|
||||
<p><strong>What this tests:</strong> a global product change appears everywhere.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Superadmin: change global product G.</li><li>Admin A: immediately change a banner or product in A.</li><li>Wait up to two minutes.</li><li>Refresh the customer apps in A and B.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-10</code> — both areas show the global change; A also shows its local change.</p>
|
||||
<h3 id="4-11-admin-website-refresh">4.11 Admin website refresh</h3>
|
||||
<p><strong>What this tests:</strong> an admin website refresh keeps you signed in and keeps the slot picker working.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Sign in to the admin website and open <strong>Vendor Snippets</strong>.</li><li>Refresh the browser.</li><li>Create/edit a snippet and open the slot picker.</li><li>Repeat after signing out and in as Admin B.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-11</code> — you stay signed in with the right area and the slots load.</p>
|
||||
<h3 id="4-12-superadmin-admin-notification">4.12 Superadmin admin notification</h3>
|
||||
<p><strong>What this tests:</strong> sending a notification to admins.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Sign in as Superadmin and open <strong>Send Notifications → Admin Notifs</strong>.</li><li>Enter a title and message and send.</li><li>Check the success message.</li><li>Ask an admin to check for the notification.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-12</code> — the message is queued/sent without an error.</p>
|
||||
<h3 id="4-13-different-roles-see-different-things">4.13 Different roles see different things</h3>
|
||||
<p><strong>What this tests:</strong> customers, admins and superadmins cannot use each other's screens.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Sign in as a customer and try to open an admin screen by typing its web address.</li><li>Sign in as an admin and try to open a superadmin screen.</li><li>Sign in as a superadmin and check that customer/admin-only screens are not available.</li><li>Use the back button after signing out.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-13</code> — each role sees only its own screens; old links do not work after sign-out.</p>
|
||||
<h3 id="4-14-deleted-product-in-old-orders">4.14 Deleted product in old orders</h3>
|
||||
<p><strong>What this tests:</strong> old orders still show a product after it is removed.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Place an order for a test product.</li><li>Admin A: delete or hide the product.</li><li>Refresh the customer catalog; the product is gone.</li><li>Open the old order as the customer and as Admin A.</li><li>Try Order Again.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-14</code> — the catalog hides it, but the old order keeps the name, quantity and price; reorder handles it as unavailable.</p>
|
||||
<h3 id="4-15-address-in-another-area">4.15 Address in another area</h3>
|
||||
<p><strong>What this tests:</strong> the delivery address decides the order's area.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Customer 1 is browsing area A.</li><li>Add/select an address inside area B.</li><li>Build a cart and open checkout.</li><li>Check the delivery charge and place the order.</li><li>Admin B: find the order.</li><li>Admin A: confirm the order is not there.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-15</code> — the order belongs to B and uses B's charges.</p>
|
||||
<h3 id="4-16-delivered-cancelled-messages">4.16 Delivered/cancelled messages</h3>
|
||||
<p><strong>What this tests:</strong> status changes and notification links.</p>
|
||||
<p><strong>Steps:</strong></p>
|
||||
<ol><li>Place an order and note its number.</li><li>Admin A: mark it delivered.</li><li>Open the customer notification/link.</li><li>Cancel another order with a reason.</li><li>Open that notification/link.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>E2E-16</code> — each link opens the correct order with the correct status.</p>
|
||||
<hr>
|
||||
<h2 id="5-special-regression-checks">5. Special regression checks</h2>
|
||||
<p>These are the checks that previously found bugs. Run them before the wider testing if you can.</p>
|
||||
<h3 id="br-01-customer-search-stays-inside-an-area">BR-01 — Customer search stays inside an area</h3>
|
||||
<ol><li>Customer 1 orders in A; Customer 2 orders in B.</li><li>Sign in as Admin A and search for Customer 2 by name and mobile.</li><li>Sign in as Admin B and search for Customer 1.</li><li>Search a name used in both areas.</li></ol>
|
||||
<p><strong>Expected:</strong> each admin sees only their own area's customers.</p>
|
||||
<h3 id="br-02-website-loads-after-choosing-an-area">BR-02 — Website loads after choosing an area</h3>
|
||||
<ol><li>On the website, choose area A.</li><li>Check that products, slots and delivery charges load.</li><li>Switch to area B and check again.</li></ol>
|
||||
<p><strong>Expected:</strong> the page loads normally; no error or blank catalog.</p>
|
||||
<h3 id="br-03-editing-a-global-product-does-not-duplicate-variants">BR-03 — Editing a global product does not duplicate variants</h3>
|
||||
<ol><li>Superadmin: open a global product with two variants.</li><li>Change a price and save.</li><li>Save again without changes.</li><li>Count the variants.</li></ol>
|
||||
<p><strong>Expected:</strong> still two variants; no duplicate appears.</p>
|
||||
<h3 id="br-04-global-store-image-stays-after-a-rejected-edit">BR-04 — Global store image stays after a rejected edit</h3>
|
||||
<ol><li>Superadmin: open a global store with an image; note the image.</li><li>Admin A: try to edit the global store.</li><li>Refresh the store in both apps.</li></ol>
|
||||
<p><strong>Expected:</strong> the edit is rejected and the image is still there.</p>
|
||||
<h3 id="br-05-global-change-plus-local-change">BR-05 — Global change plus local change</h3>
|
||||
<ol><li>Superadmin: change a global product.</li><li>Within 30 seconds, Admin A: change a banner or product in A.</li><li>Wait up to two minutes; refresh both areas.</li></ol>
|
||||
<p><strong>Expected:</strong> both areas show the global change and A also shows its local change.</p>
|
||||
<h3 id="br-06-website-checkout-sends-slots">BR-06 — Website checkout sends slots</h3>
|
||||
<ol><li>Website: add items for S1 and S2.</li><li>Choose both slots and place the order.</li><li>Check the order detail.</li></ol>
|
||||
<p><strong>Expected:</strong> both slots are saved; no "slot required" error.</p>
|
||||
<h3 id="br-07-new-area-is-usable">BR-07 — New area is usable</h3>
|
||||
<ol><li>Superadmin: create a test area with a zone.</li><li>Open the customer area chooser and select it.</li><li>Check products/slots/delivery charges.</li></ol>
|
||||
<p><strong>Expected:</strong> the area is listed and its pages load.</p>
|
||||
<h3 id="br-08-global-product-form-does-not-keep-an-old-draft">BR-08 — Global product form does not keep an old draft</h3>
|
||||
<ol><li>Superadmin: Global products → Create; type a name but do not save.</li><li>Click Edit on another product.</li><li>Click Create again.</li></ol>
|
||||
<p><strong>Expected:</strong> Edit shows the selected product; Create is empty.</p>
|
||||
<h3 id="br-09-old-orders-in-a-quiet-area">BR-09 — Old orders in a quiet area</h3>
|
||||
<ol><li>Area A has several old orders; Area B creates many new orders.</li><li>Admin A: open Manage Orders and page through.</li></ol>
|
||||
<p><strong>Expected:</strong> all A orders appear; the list is not empty.</p>
|
||||
<h3 id="br-10-cart-survives-the-first-area-choice-known-issue">BR-10 — Cart survives the first area choice (known issue)</h3>
|
||||
<ol><li>Add a product to the cart.</li><li>Close and reopen the app; let it choose the first area.</li><li>Open the cart.</li></ol>
|
||||
<p><strong>Expected:</strong> the cart is still there. If it is empty, record it as <code>BR-10</code> (known issue).</p>
|
||||
<h3 id="br-11-suspension-stays-after-a-price-change">BR-11 — Suspension stays after a price change</h3>
|
||||
<ol><li>Admin A: suspend a global product in A.</li><li>Reopen it, change only the price, and save.</li><li>Check the customer app in A and B.</li></ol>
|
||||
<p><strong>Expected:</strong> it is still suspended in A; B is unchanged.</p>
|
||||
<h3 id="br-12-coupons-never-make-a-total-negative">BR-12 — Coupons never make a total negative</h3>
|
||||
<ol><li>Build two cart parts of ₹101 each.</li><li>Apply two ₹101 coupons.</li><li>Place the order.</li></ol>
|
||||
<p><strong>Expected:</strong> each part shows ₹0, not a negative amount; the bill adds up.</p>
|
||||
<h3 id="br-13-old-orders-and-discounts-accepted">BR-13 — Old orders and discounts (accepted)</h3>
|
||||
<ol><li>Open an old order that used a coupon.</li><li>Check the discount line in the customer and admin views.</li></ol>
|
||||
<p><strong>Expected:</strong> the discount may show ₹0 for very old orders. This is accepted for now; do not report it as a new bug.</p>
|
||||
<h3 id="br-14-changing-a-global-coupon-type-known-issue">BR-14 — Changing a global coupon type (known issue)</h3>
|
||||
<ol><li>Superadmin: create a 20% global coupon.</li><li>Edit it to ₹50 and save.</li><li>Use it in the customer app.</li></ol>
|
||||
<p><strong>Expected:</strong> the discount should be ₹50 only. If 20% is still applied, record it as <code>BR-14</code> (known issue).</p>
|
||||
<h3 id="br-15-admin-website-after-refresh">BR-15 — Admin website after refresh</h3>
|
||||
<ol><li>Sign in to the admin website.</li><li>Refresh the page.</li><li>Open Vendor Snippets and the slot picker.</li></ol>
|
||||
<p><strong>Expected:</strong> you stay signed in and the slots load.</p>
|
||||
<h3 id="br-16-superadmin-admin-notification">BR-16 — Superadmin admin notification</h3>
|
||||
<ol><li>Superadmin: Send Notifications → Admin Notifs.</li><li>Send a test message.</li><li>Check the result.</li></ol>
|
||||
<p><strong>Expected:</strong> the message sends successfully; no error.</p>
|
||||
<h3 id="br-17-only-cash-on-delivery">BR-17 — Only Cash on Delivery</h3>
|
||||
<ol><li>Open checkout.</li><li>Look at the payment methods.</li><li>Place a test order.</li></ol>
|
||||
<p><strong>Expected:</strong> Cash on Delivery is the only usable method; the online option is disabled.</p>
|
||||
<h3 id="br-18-no-delivery-slot">BR-18 — No delivery slot</h3>
|
||||
<ol><li>Add an item and do not choose a slot.</li><li>Try to check out.</li></ol>
|
||||
<p><strong>Expected:</strong> checkout is blocked with a clear message.</p>
|
||||
<h3 id="br-19-address-decides-the-area">BR-19 — Address decides the area</h3>
|
||||
<ol><li>Browse area A, then select an address in area B.</li><li>Place an order.</li><li>Check Admin A and Admin B order lists.</li></ol>
|
||||
<p><strong>Expected:</strong> the order appears in B with B's charges, not in A.</p>
|
||||
<h3 id="br-20-order-pages-stay-stable">BR-20 — Order pages stay stable</h3>
|
||||
<ol><li>Create orders in A and B.</li><li>Admin A: page through the order list.</li><li>Admin B: do the same.</li></ol>
|
||||
<p><strong>Expected:</strong> every order appears once; pages do not skip or repeat orders.</p>
|
||||
<hr>
|
||||
<h2 id="6-other-screens-only-if-your-coordinator-says-they-are-active">6. Other screens (only if your coordinator says they are active)</h2>
|
||||
<p>Some screens are not part of normal testing. Test them only if your coordinator confirms they are in use for this release.</p>
|
||||
<h3 id="6-1-vendor-page">6.1 Vendor page</h3>
|
||||
<ol><li>Open the vendor page link and sign in with the provided test code.</li><li>Open the order list and choose an order.</li><li>Mark an item packaged and verified.</li><li>Try a different/incorrect test code.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>COND-01</code> — the vendor sees only their orders and can package them; a wrong code is rejected.</p>
|
||||
<h3 id="6-2-reviews">6.2 Reviews</h3>
|
||||
<ol><li>As a customer, open a delivered order or product and write a review with an image.</li><li>As an admin, open <strong>Reviews</strong> and reply.</li><li>Check the customer can see the reply.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>COND-02</code> — the review and reply are saved and visible. If reviews are not active, skip this check.</p>
|
||||
<h3 id="6-3-one-time-password-otp-sign-in">6.3 One-time password (OTP) sign-in</h3>
|
||||
<ol><li>Use the test mobile number and the test code provided by your coordinator.</li><li>Request the code and sign in.</li><li>Try a wrong/expired code, then the correct one.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>COND-03</code> — one account is created/signed in, and a wrong code is rejected. Never use a real customer's phone number.</p>
|
||||
<h3 id="6-4-older-fallback-pages">6.4 Older fallback pages</h3>
|
||||
<ol><li>Open the older login/home/order-details links provided by your coordinator.</li><li>Check only the pages your coordinator says are still supported.</li><li>Note any page that looks like a demo or is no longer used.</li></ol>
|
||||
<p><strong>What you should see:</strong> <code>COND-04</code> — supported pages work; unsupported pages are recorded as "not applicable" with a reason.</p>
|
||||
<hr>
|
||||
<h2 id="7-known-issues">7. Known issues</h2>
|
||||
<table>
|
||||
<thead><tr><th>Check</th><th>What to expect</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><code>BR-10</code></td><td>A cart may be cleared when the app chooses the first area on launch. Record it; it is known.</td></tr>
|
||||
<tr><td><code>BR-14</code></td><td>A global coupon changed from 20% to ₹50 may still apply 20% in the current build. Record it; it is known.</td></tr>
|
||||
<tr><td><code>BR-13</code></td><td>Very old orders may show a ₹0 discount. This is accepted; do not report it as new.</td></tr>
|
||||
</tbody></table>
|
||||
<hr>
|
||||
<h2 id="8-reporting-a-problem">8. Reporting a problem</h2>
|
||||
<p>Use this simple format:</p>
|
||||
<pre><code class="language-text">What I was testing:
|
||||
Reference number (for example CUST-31):
|
||||
Account used (Customer 1 / Admin A / Superadmin):
|
||||
Area (A or B):
|
||||
Steps I took:
|
||||
What I expected:
|
||||
What actually happened:
|
||||
Screenshot:
|
||||
Date and time:</code></pre>
|
||||
<p>If the problem involves money, write down the item total, discount, delivery charge and final total. If it involves an order, include the order number.</p>
|
||||
<p class="top"><a href="#freshyo-manual-testing-guide">Back to top</a></p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
1143
docs/full-product-validation-manual-testing-guide.md
Normal file
1143
docs/full-product-validation-manual-testing-guide.md
Normal file
File diff suppressed because it is too large
Load diff
709
docs/full-product-validation-test-plan.md
Normal file
709
docs/full-product-validation-test-plan.md
Normal file
|
|
@ -0,0 +1,709 @@
|
|||
# Freshyo full-product validation test plan
|
||||
|
||||
Status: proposed — **not executed**.
|
||||
Branch: `MULTI_REGION_I2` (48 commits ahead of `main`).
|
||||
Scope: backend tRPC/API, customer native + web, admin native + web, superadmin web, cache/jobs, and the cross-app order journey.
|
||||
|
||||
This is the automation-focused master plan: **311 cases** across seven layers.
|
||||
The exhaustive per-feature edge-case catalog lives in
|
||||
[`docs/test-cases/`](test-cases/README.md); this file lists the cases that must be
|
||||
automated and run for release. A test case is a user journey, an API contract, or
|
||||
a cross-app invariant — **not** a component render or prop unit test.
|
||||
|
||||
For human reproduction of the app-visible cases, use the companion
|
||||
[`full-product-validation-manual-testing-guide.md`](full-product-validation-manual-testing-guide.md)
|
||||
or its [self-contained HTML version](full-product-validation-manual-testing-guide.html).
|
||||
The manual guide is written for non-technical testers and intentionally excludes
|
||||
the backend/API, security, database and cache procedures.
|
||||
|
||||
---
|
||||
|
||||
## 1. Goals and boundaries
|
||||
|
||||
### Must validate
|
||||
|
||||
1. Every authorization boundary: anonymous, customer, staff A, staff B, superadmin.
|
||||
2. Every money path: cart preview → checkout → persisted order → customer detail → admin detail.
|
||||
3. Region/bound isolation: catalog, prices, stock, slots, orders, staff, caches.
|
||||
4. Global entities (stores/products/coupons) in every region, with independent market data.
|
||||
5. Cache publication: regional vs global regeneration, debounce, versions, bound discovery.
|
||||
6. COD-only checkout and the absence of online-payment routes/UI.
|
||||
7. The operational chain: superadmin setup → admin catalog/slots → customer order → admin fulfillment → customer status.
|
||||
8. Recovery: expired sessions, stale caches, offline, retries, double submits, failed mutations.
|
||||
|
||||
### Explicitly out of scope
|
||||
|
||||
- Component-level unit tests, prop tests, renderer snapshots, and pure-helper tests
|
||||
(the shared pricing helpers are validated through API/UI money cases).
|
||||
- Styling, animation, icon, and layout snapshots.
|
||||
- Third-party internals (Expo, Cloudflare, D1, KV, R2, Maestro/Playwright drivers).
|
||||
- Live SMS/OTP, real push broadcasts, real object-storage deletes outside staging,
|
||||
and online payment gateways.
|
||||
- Drizzle migrations. **Never run migrations as test setup.** The user applies them.
|
||||
- Production mutation tests. All mutation/notification cases use staging only.
|
||||
- `apps/info-site` is a static marketing site: manual link/uptime smoke only, not part of this suite.
|
||||
|
||||
### Definition of a valid case
|
||||
|
||||
A case passes only when the observable result is confirmed from the authoritative
|
||||
surface, not from a toast:
|
||||
|
||||
- Money: `goods − stored discount + delivery = payable`, per sub-order and in total.
|
||||
- Cache: DB value, served version and elapsed time all agree within the deadline.
|
||||
- Mutations: the intended rows exist **and** no unintended rows/assets changed.
|
||||
- Rejections: correct 4xx contract **and** no partial writes.
|
||||
- UI: the expected screen was actually open; a success toast alone is not evidence.
|
||||
|
||||
---
|
||||
|
||||
## 2. Automation layers
|
||||
|
||||
| Layer | Tool | What is real | Network | Location |
|
||||
|---|---|---|---|---|
|
||||
| L1 Backend API | Jest + `ts-jest` + tRPC HTTP client | Backend worker, D1/KV/R2/DO | Real local HTTP | `apps/backend/tests/api/` |
|
||||
| L2 Customer UI | Jest + `jest-expo` + React Native Testing Library | Screen, router, providers, stores, storage | Mocked tRPC/axios boundary | `apps/user-ui/tests/flows/` |
|
||||
| L3 Admin UI | Jest + `jest-expo` + RNTL | Screen, router, providers, stores | Mocked tRPC/axios boundary | `apps/admin-ui/tests/flows/` |
|
||||
| L4 Customer web | Jest + jsdom + React Testing Library | Route, router, providers, localStorage | Mocked tRPC link | `apps/web-ui/tests/flows/` |
|
||||
| L5 Admin web | Jest + jsdom + React Testing Library | Route, router, providers, localStorage | Mocked tRPC link | `apps/admin-web/tests/flows/` |
|
||||
| L6 Superadmin | Vitest + jsdom + React Testing Library (already configured; the same cases run under Jest if the repo standardizes) | Route, router, providers | Mocked tRPC link | `apps/superadmin-ui/src/**/*.test.tsx` |
|
||||
| L7 Cross-app E2E | Maestro (native) + Playwright (web) | Real backend, DB, cache, storage | Real | `tests/e2e/`, `tests/e2e-web/` |
|
||||
|
||||
Rules for L2–L6:
|
||||
|
||||
- Mount the **route/screen**, not an isolated component.
|
||||
- Exercise real navigation, state stores, query invalidation and persisted storage.
|
||||
- Mock only the network boundary; keep the app's validation, guards and rendering real.
|
||||
- Prefer `testID` / accessible roles over text that changes with copy.
|
||||
- One test = one user-visible outcome, not one assertion per element.
|
||||
- No shallow rendering, no component prop matrices, no snapshots.
|
||||
|
||||
Rules for L1:
|
||||
|
||||
- Talk to a running backend over HTTP, exactly like the apps.
|
||||
- Create fixtures through the API; add a sanctioned fixture/reset path only if API
|
||||
setup becomes too slow.
|
||||
- Tests share data; run serially and use unique name/mobile prefixes.
|
||||
- Never point a mutation test at production.
|
||||
|
||||
Rules for L7:
|
||||
|
||||
- Only the critical journeys below. Do not re-implement the full API suite in E2E.
|
||||
- Native: Maestro flows with stable IDs; Web: Playwright Chromium.
|
||||
- A coordinator carries region/product/SKU/slot/order IDs between apps.
|
||||
- Assert persisted state through the UI plus one authoritative API read.
|
||||
|
||||
---
|
||||
|
||||
## 3. Environment and fixtures
|
||||
|
||||
### Environment
|
||||
|
||||
- Isolated staging backend with its own D1/KV/R2/queue/DO namespace and object store.
|
||||
- Local commands (for the future test harness; **do not run while authoring**):
|
||||
- backend: `cd apps/backend && bun run dev` (wrangler dev on `:8787`)
|
||||
- backend suite: `cd apps/backend && bun run test:api`
|
||||
- native suites: `cd apps/user-ui && bun run test`, `cd apps/admin-ui && bun run test`
|
||||
- web suites: add `bun test` scripts to `apps/web-ui`, `apps/admin-web`, `apps/superadmin-ui`
|
||||
- E2E: `tests/e2e/run.sh` (Maestro) and `npx playwright test` (web)
|
||||
- Web/native unit suites must point at the same staging API version as the backend suite.
|
||||
|
||||
### Shared fixtures
|
||||
|
||||
| Fixture | Required setup |
|
||||
|---|---|
|
||||
| Regions | A and B. A has bounds A1/A2 (priority 1/2, different fees); B has B1. Include interior, edge, overlap and outside points. |
|
||||
| Identities | anonymous, U1 (addresses in A1/A2), U2 (B1), U0 (new, zero addresses), suspended user, staff A, staff B, superadmin. |
|
||||
| Catalog | A-only product P with two SKUs; B-only Q; global G with independent A/B market rows; regular-only R; flash F; combo C with combo-only component K; deleted/OOS/suspended variants. |
|
||||
| Stores | regional store A, regional store B, global store GS. |
|
||||
| Slots | future S1/S2 in A, B slot; inactive, frozen, full, past and midnight-boundary slots. |
|
||||
| Money | per-bound free-delivery threshold T and fee D; flash threshold/fee; T−0.01/T/T+0.01. |
|
||||
| Coupons | regional A/B, global, percent, flat, targeted, whole-cart, capped, min-spend, exclusive, first-order, limited-use, personal, expired, invalidated, reserved. |
|
||||
| Orders | pending COD, packaged, verified, delivered, cancelled, multi-slot group, flash, historical product-deleted. |
|
||||
| Content | tags, groups, banners, upload assets, complaints, notifications, vendor snippets (conditional). |
|
||||
| Notifications | sandbox queue and approved test recipients only. |
|
||||
|
||||
### Data rules
|
||||
|
||||
- Unique run prefix for every created name/mobile/email/code.
|
||||
- Never delete a region; neutralize throwaway regions by renaming/shrinking instead.
|
||||
- Bounds are deletable only when the region has another bound and no addresses reference them.
|
||||
- Product deletion is soft; order history must keep the original name and amount.
|
||||
- Clean up only approved disposable rows/assets; keep failing fixtures for diagnosis.
|
||||
- Record region/bound IDs, product/SKU IDs, slot IDs and order IDs in the run report.
|
||||
|
||||
---
|
||||
|
||||
## 4. Priorities and release gates
|
||||
|
||||
| Priority | Meaning | Gate |
|
||||
|---|---|---|
|
||||
| P0 | Authorization, money integrity, core purchasing, region isolation, data loss | Every P0 must pass before any release. |
|
||||
| P1 | Normal feature behaviour, important edge cases, parity | Every P1 must pass or be explicitly waived. |
|
||||
| P2 | Resilience, presentation, conditional/legacy coverage | Run before major releases; document N/A reasons. |
|
||||
|
||||
Release gate:
|
||||
|
||||
1. `typecheck` clean for touched apps/packages.
|
||||
2. All P0 backend + frontend cases pass on the release candidate.
|
||||
3. All P1 cases pass or have a signed waiver.
|
||||
4. E2E critical journeys pass against staging.
|
||||
5. No P0/P1 open defect without a documented workaround.
|
||||
|
||||
---
|
||||
|
||||
## 5. Current-branch delta → required coverage
|
||||
|
||||
The branch changes are concentrated in multi-region support, global entities,
|
||||
bound-based discovery/pricing, cache publication and the COD-only conversion.
|
||||
Each change below has dedicated cases in §7.
|
||||
|
||||
| # | Change / fixed defect | Regression cases |
|
||||
|---|---|---|
|
||||
| 1 | Admin customer search must be region-scoped (`or()` grouping) | `BR-01`, `BE-ADMIN-15` |
|
||||
| 2 | Web discovery must request `essentialConsts({ boundId })` | `BR-02`, `CUST-01` |
|
||||
| 3 | Global-product edit must preserve SKU IDs | `BR-03`, `BE-SA-09` |
|
||||
| 4 | Regional edit of a global store must not delete its image | `BR-04`, `BE-ADMIN-08` |
|
||||
| 5 | Global cache request must not be narrowed by a regional request | `BR-05`, `BE-CACHE-04` |
|
||||
| 6 | Web scheduled checkout must send each line's slot ID | `BR-06`, `CUST-41` |
|
||||
| 7 | New-region cache generation must be awaited | `BR-07`, `BE-SA-05` |
|
||||
| 8 | Global-product edit form must reset between create/edit | `BR-08`, `SA-12` |
|
||||
| 9 | Regional order list must paginate its own rows, not a global ID window | `BR-09`, `BE-ORDER-23`, `ADM-06` |
|
||||
| 10 | Startup region adoption must not wipe a persisted cart | `BR-10` (known open) |
|
||||
| 11 | Unrelated market edits must preserve regional suspension | `BR-11`, `BE-ADMIN-05` |
|
||||
| 12 | Coupon allocation must never make a sub-order negative | `BR-12`, `CUST-33`, `BE-COUP-15` |
|
||||
| 13 | Historical `discount_amount` backfill | `BR-13` (accepted limitation) |
|
||||
| 14 | Switching a global coupon from percent to flat must clear percent | `BR-14` (known open) |
|
||||
| 15 | Admin-web reload must restore staff identity/region | `BR-15`, `ADM-01`, `ADM-32` |
|
||||
| 16 | Superadmin "Admin Notifs" must use a superadmin-guarded endpoint | `BR-16`, `SA-18` |
|
||||
| 17 | COD-only conversion (no online-payment routes/UI) | `BR-17`, `BE-ORDER-01`, `CUST-42` |
|
||||
| 18 | Per-slot web checkout validation (`slotId` non-null for scheduled) | `BR-18`, `BE-ORDER-08` |
|
||||
| 19 | Bound-based pricing from the address, not the client region | `BR-19`, `BE-ORDER-11`, `CUST-39` |
|
||||
| 20 | Search/order pagination keyset stability | `BR-20`, `BE-ORDER-23` |
|
||||
|
||||
---
|
||||
|
||||
## 6. Master case inventory
|
||||
|
||||
### 6.1 Backend API (L1)
|
||||
|
||||
#### Common discovery, regions and bounds
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-COM-01 | P0 | `GET /api/health` and `common.healthCheck`. | 200/ok; no secrets. |
|
||||
| BE-COM-02 | P0 | `common.listRegions` as anonymous. | Regions with public discovery metadata only; no staff/account data. |
|
||||
| BE-COM-03 | P0 | `resolveRegionByLocation` for A1, A2, B1, overlap, polygon edge. | Correct region/bound; priority wins on overlap; edge follows documented rule. |
|
||||
| BE-COM-04 | P0 | `resolveRegionByLocation` outside every polygon and invalid coordinates. | Outside → `null`; invalid → 400. |
|
||||
| BE-COM-05 | P0 | `resolveBound` for a valid A point, an outside-A point, and a B point with `regionId=A`. | A point → A bound; outside/foreign → 422; no cross-region fallback. |
|
||||
| BE-COM-06 | P1 | `activeBound` signed-out, U1 with A1/A2, U1 with B-only addresses, U0 with none. | Signed-out → effective bound; U1 → lowest-priority A bound; B addresses ignored; U0 → effective bound. |
|
||||
| BE-COM-07 | P1 | `regionSettings` for A; region with no bounds; unknown region. | Effective bound settings; 422 for no bounds; 422/404 for unknown. |
|
||||
| BE-COM-08 | P0 | `essentialConsts` with `boundId`, missing `boundId`, unknown `boundId`. | Merged global/region/bound payload for the bound; validation error when missing; 404 unknown. |
|
||||
| BE-COM-09 | P2 | `essentialConsts` on a `raw`/`mf` host. | Stale-client notice fields present and non-closable; normal hosts omit it. |
|
||||
| BE-COM-10 | P1 | `checkLocationInPolygon` inside/outside/invalid. | Boolean for valid points; validation error for invalid. |
|
||||
| BE-COM-11 | P0 | `getStoresSummary` as staff A, staff B, customer. | Staff A only A stores; staff B only B; customer denied. |
|
||||
|
||||
#### Customer authentication and profile
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-AUTH-01 | P0 | Register a new customer, then log in by mobile and by email. | One user row; both identifiers authenticate; token works. |
|
||||
| BE-AUTH-02 | P0 | Duplicate mobile, duplicate email, malformed mobile/email, weak password. | Rejected; no partial user/credential rows. |
|
||||
| BE-AUTH-03 | P1 | Login with wrong password/unknown identifier and retry correctly. | Rejected then succeeds; no session from the failure. |
|
||||
| BE-AUTH-04 | P0 | Expired, tampered and malformed JWT on a protected query. | 401; no fallback identity/region. |
|
||||
| BE-AUTH-05 | P1 | `getSelfData`, `updateProfile`, avatar change, relaunch/read-back. | Values persist; no other user's data. |
|
||||
| BE-AUTH-06 | P1 | `updatePassword` with wrong old password, then correct; login old/new. | Wrong rejected; new works; old fails. |
|
||||
| BE-AUTH-07 | P1 | `deleteAccount` with wrong confirmation, then correct. | Wrong rejected; correct deletes/revokes access. |
|
||||
| BE-AUTH-08 | P0 | Suspended customer places an order with an existing token; unsuspend; retry. | Blocked while suspended; allowed after unsuspend. |
|
||||
| BE-AUTH-09 | P0 | User token calls admin/superadmin mutations; staff token calls user/superadmin. | Denied at the procedure; no writes. |
|
||||
| BE-AUTH-10 | P0 | Two customers U1/U2 probe each other's profile/address/order/coupon IDs. | Ownership enforced on every surface. |
|
||||
| BE-AUTH-11 | P0 | Customer with zero addresses attempts to place an order. | Rejected with a meaningful address error; no order. |
|
||||
|
||||
#### Addresses and region/bound attachment
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-ADDR-01 | P0 | Create an address with coordinates inside A1 and inside A2. | Correct region + derived bound; coordinates stored. |
|
||||
| BE-ADDR-02 | P0 | Create with coordinates outside every A bound. | 422; no address row. |
|
||||
| BE-ADDR-03 | P1 | Create without coordinates (legacy web) and with a Google Maps URL. | Fallback to region effective bound; URL coords parsed when present. |
|
||||
| BE-ADDR-04 | P1 | Invalid phone (9 digits, starts 5), missing name/line/city/state. | Validation errors; no row. |
|
||||
| BE-ADDR-05 | P1 | First address, then second address with `isDefault=false`, then set it default. | First is default; setting default unsets the previous one. |
|
||||
| BE-ADDR-06 | P0 | Update another user's address ID. | Not found/forbidden; no change. |
|
||||
| BE-ADDR-07 | P1 | Update coordinates from A1 to A2; update region to B with B coordinates. | Bound re-derived; region/bound/address consistent. |
|
||||
| BE-ADDR-08 | P1 | Delete an address used by an ongoing order vs a free address. | Ongoing-order address refused; free address deleted. |
|
||||
| BE-ADDR-09 | P1 | Delete the default address while another exists; delete the last address. | Default policy remains coherent; address gate appears for zero addresses. |
|
||||
| BE-ADDR-10 | P1 | Create/update address and inspect `user_regions` and notification credentials. | Association inserted/reconciled; token region follows the address region. |
|
||||
| BE-ADDR-11 | P0 | Cart/checkout and order use an address whose coordinates are in B while browsing A. | Order is scoped/priced by the address's B region/bound; browsing region unchanged. |
|
||||
| BE-ADDR-12 | P1 | `getDefaultAddress` / `getUserAddresses` for U1 and U2. | Only the caller's addresses; default flag correct. |
|
||||
|
||||
#### Catalog, stores, search, combos and slots
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-CAT-01 | P0 | Read A catalog containing A-only P, B-only Q and global G. | P and G only; Q absent; G uses A market data. |
|
||||
| BE-CAT-02 | P0 | Read B catalog for the same fixture. | Q and G only; P absent; G uses B market data. |
|
||||
| BE-CAT-03 | P1 | Product detail for P, Q, G in A and B. | Correct region/market price, flags and variants; foreign product not purchasable. |
|
||||
| BE-CAT-04 | P1 | Search by name/tag/store in A. | Only A + global matches; no B results; case/whitespace behaviour documented. |
|
||||
| BE-CAT-05 | P1 | Product list with deleted, OOS, globally suspended and regionally suspended SKUs. | Deleted hidden; OOS/suspended flags correct; no orderable invalid SKU. |
|
||||
| BE-CAT-06 | P1 | Stores list/detail in A and B, including global store GS. | Regional isolation; GS visible in both; product counts/assets coherent. |
|
||||
| BE-CAT-07 | P1 | Banners and tags in A/B. | Region-correct order/visibility; no foreign content. |
|
||||
| BE-CAT-08 | P0 | `getSlots` without `regionId`, for A, for B. | Missing → validation error; A/B return only future active slots for that region. |
|
||||
| BE-CAT-09 | P1 | Slots that are full, frozen, past, inactive. | Excluded from customer lists; capacity/status correct. |
|
||||
| BE-CAT-10 | P1 | Slot membership: SKU not assigned to a slot. | Not orderable into that slot; checkout rejects. |
|
||||
| BE-CAT-11 | P1 | Combo C with component K; K unavailable/out of stock. | Combo composition/pricing correct; unavailable component prevents purchase. |
|
||||
| BE-CAT-12 | P0 | Flash product F in A (enabled) and B (disabled). | Flash list/price only where enabled; disabled region cannot order. |
|
||||
| BE-CAT-13 | P1 | Global product with different A/B market prices and suspension. | Each region sees its own price/stock/suspension only. |
|
||||
| BE-CAT-14 | P1 | Product tags/group ordering and popular-items ordering. | Order matches admin configuration; region-scoped. |
|
||||
| BE-CAT-15 | P2 | Empty region with no stores/products/slots. | Intentional empty payloads; no crash or cross-region fallback. |
|
||||
| BE-CAT-16 | P0 | Catalog response inspection. | No customer/staff private data, addresses, tokens or internal notes. |
|
||||
|
||||
#### Coupons and pricing
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-COUP-01 | P0 | Eligible coupon list for U1 in A with regional/global/personal/expired/invalidated/used-up coupons. | Only visible eligible-or-disabled candidates; expired/invalidated/used-up/other-user hidden. |
|
||||
| BE-COUP-02 | P0 | Apply a regional A coupon while ordering in B. | Rejected; no usage recorded. |
|
||||
| BE-COUP-03 | P0 | First-order-only coupon for U0 and for U1 with an order. | U0 accepted; U1 rejected with the documented message. |
|
||||
| BE-COUP-04 | P0 | `minOrder` below, equal and above the eligible subtotal. | Below rejected; equal accepted; reason uses the eligible subtotal. |
|
||||
| BE-COUP-05 | P0 | Targeted coupon whose SKUs are present, partially present and absent. | Discount only on targets; absent → no-applicable-items error. |
|
||||
| BE-COUP-06 | P0 | Coupon at the per-user usage limit and one below it. | Limit enforced; one-time usage recorded. |
|
||||
| BE-COUP-07 | P0 | Exclusive coupon combined with another coupon. | Combination rejected; exclusive alone works. |
|
||||
| BE-COUP-08 | P0 | Stack 10% then ₹100 on ₹1000; reverse order. | 200 (800 payable) vs 190 (810 payable); order-sensitive result. |
|
||||
| BE-COUP-09 | P0 | 15% on ₹999; 12.5% on ₹1000; exact `.5` rounding. | Discounts round to nearest rupee consistently client/server. |
|
||||
| BE-COUP-10 | P1 | Percentage with `maxValue` after a prior coupon; flat above remaining. | Cap applies to its own reduced base; discount clamped to remaining. |
|
||||
| BE-COUP-11 | P0 | 100% and 150% coupons. | Goods never below zero; delivery may remain; no negative totals. |
|
||||
| BE-COUP-12 | P0 | Delivery with a coupon that crosses the free-delivery threshold. | Coupon base excludes delivery; fee uses the defined post-discount goods subtotal. |
|
||||
| BE-COUP-13 | P1 | Targeted + whole-cart coupons across two slots. | Per-sub-order discounts sum exactly; no unrelated goods discounted. |
|
||||
| BE-COUP-14 | P0 | Coupon usage persists once per order group; cancellation restores it. | Usage row/one-time invariants correct; cancel frees usage when no sibling remains. |
|
||||
| BE-COUP-15 | P0 | ₹101 sub-order ×2 with two ₹101 stackable coupons. | Per-sub-order discounts ≤ goods; totals never negative; exact reconciliation. |
|
||||
| BE-COUP-16 | P1 | Coupon invalidated/deleted after being selected but before submit. | Submit rejects; no silently discounted order. |
|
||||
| BE-COUP-17 | P1 | Global coupon authored by superadmin used in A and B. | Applies in both; regional coupon does not leak. |
|
||||
| BE-COUP-18 | P1 | Global coupon switched from 20% to ₹50 in the superadmin form. | Percentage is cleared; pricing uses ₹50 only (`BR-14`, known open). |
|
||||
|
||||
#### Orders, cancellation and fulfillment
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-ORDER-01 | P0 | Valid scheduled COD order with address, slot, notes and coupon. | Correct rows/SKUs/qty/region/amount; COD only; no payment-gateway fields. |
|
||||
| BE-ORDER-02 | P0 | Items assigned to S1 and S2 in one checkout. | One sub-order per slot in one group; one delivery fee on the primary; totals sum. |
|
||||
| BE-ORDER-03 | P0 | Persisted order read back by customer and admin. | Same items, discount, delivery, total, region and status on both surfaces. |
|
||||
| BE-ORDER-04 | P0 | Empty items, unknown SKU, invalid/negative/fractional quantity, duplicate lines. | No empty/invalid order; quantity/duplicate policy enforced. |
|
||||
| BE-ORDER-05 | P0 | Foreign-region SKU, slot or address-bound pairing. | Rejected; no cross-region order or fee manipulation. |
|
||||
| BE-ORDER-06 | P0 | Deleted, OOS, globally suspended and regionally suspended SKU. | Rejected server-side even with a stale client payload. |
|
||||
| BE-ORDER-07 | P0 | Full, frozen, past, inactive or wrong-region slot. | Rejected with the appropriate 4xx; no order. |
|
||||
| BE-ORDER-08 | P0 | Scheduled order with `slotId: null` (the old web bug). | Rejected with "slot required"; valid per-line slot IDs succeed. |
|
||||
| BE-ORDER-09 | P0 | Slot does not carry one of the ordered SKUs. | Rejected; no partial order. |
|
||||
| BE-ORDER-10 | P0 | Address coordinates in B while the client sends `regionId=A`. | Server derives B from coordinates; B pricing/slot/region used. |
|
||||
| BE-ORDER-11 | P0 | Bound A1 vs A2 selected address with different fee/threshold. | Address bound drives the fee/threshold; client bound is ignored. |
|
||||
| BE-ORDER-12 | P0 | Coupon becomes ineligible between selection and submit. | Server revalidates; rejection or documented repricing; no false success. |
|
||||
| BE-ORDER-13 | P1 | User notes and admin notes round-trip. | Persisted and visible on the correct surfaces. |
|
||||
| BE-ORDER-14 | P0 | Flash order with a flash price and null slot. | Flash price/flag/fee; no scheduled slot; admin sees flash order. |
|
||||
| BE-ORDER-15 | P0 | Flash disabled in the address bound but enabled in the browsing region. | Rejected server-side. |
|
||||
| BE-ORDER-16 | P1 | Rapid double tap / duplicate in-app submit. | One in-app request; no duplicate order. |
|
||||
| BE-ORDER-17 | P1 | Raw concurrent API submits (characterization). | Record whether two orders are created; known lack of server idempotency is explicit. |
|
||||
| BE-ORDER-18 | P1 | Historical order after product/variant/store soft delete. | History keeps original name, quantity and charged amount. |
|
||||
| BE-ORDER-19 | P1 | Customer order list pagination and order detail by numeric ID. | Stable order; no duplicates/skips; readable ID rejected if not supported. |
|
||||
| BE-ORDER-20 | P0 | U2 reads/cancels/notes U1's order; staff B reads A's order. | Denied; no private payload. |
|
||||
| BE-ORDER-21 | P0 | Cancel with reason, without reason, by user and by staff. | Reason required; actor/status correct; coupon usage restoration correct. |
|
||||
| BE-ORDER-22 | P1 | Cancel a delivered order; deliver a cancelled order; revert delivered. | Customer cancellation of a delivered order is rejected; staff transitions follow the approved policy. Current gaps (cancelled→delivered, delivered→undelivered) are pinned until the policy changes. |
|
||||
| BE-ORDER-23 | P0 | Quiet region A with old orders while B creates many newer orders; page A. | A returns all its rows and a valid cursor; no global-ID window starvation. |
|
||||
| BE-ORDER-24 | P1 | Admin marks packaged/verified/delivered; customer detail reflects it. | Status and timestamps agree; no partial item/order state. |
|
||||
| BE-ORDER-25 | P1 | Admin removes the delivery charge; rebalances slots/items. | Totals reconcile; historic discount preserved; no duplicate fee. |
|
||||
| BE-ORDER-26 | P1 | Admin delivery sequence for a slot and coordinate override. | Sequence/order correct; coordinates update the intended order only. |
|
||||
| BE-ORDER-27 | P2 | Order-detail money after migration/backfill. | New orders store discount; historical rows may show 0 (accepted; see `BR-13`). |
|
||||
|
||||
#### Admin API and isolation
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-ADMIN-01 | P0 | Staff A/B login, `me`, region-scoped dashboard. | Correct staff/region; no cross-region counters. |
|
||||
| BE-ADMIN-02 | P0 | Staff B reads/writes A product, store, slot, tag, group, banner, coupon IDs. | Denied/not found; no writes. |
|
||||
| BE-ADMIN-03 | P0 | Regional product CRUD and customer publication. | Created/updated product visible in A only; B unchanged. |
|
||||
| BE-ADMIN-04 | P0 | Regional edit of a global product: price, stock, flash, suspension. | Only market rows for A change; global structure and B market untouched. |
|
||||
| BE-ADMIN-05 | P0 | Suspend a global SKU in A, reopen/edit an unrelated price, save. | Suspension remains in A; B unaffected (`BR-11`). |
|
||||
| BE-ADMIN-06 | P0 | Regional admin edits a global SKU's market data; superadmin edits the structure. | Existing SKU IDs preserved; no duplicate variants; market scope is A only. |
|
||||
| BE-ADMIN-07 | P0 | Regional staff edits a global store. | Rejected; regional write never mutates global store data. |
|
||||
| BE-ADMIN-08 | P0 | Failed regional edit of a global store with an old image. | Image is not deleted; object storage unchanged (`BR-04`). |
|
||||
| BE-ADMIN-09 | P0 | Delete a product/store with dependent rows; delete a free one. | Protected deletes rejected; free deletes soft-delete/hide correctly. |
|
||||
| BE-ADMIN-10 | P1 | Product SKU create/edit/delete, features, images, tags, groups, combos. | Correct relations; no orphan rows; duplicate SKU IDs not created. |
|
||||
| BE-ADMIN-11 | P1 | Banner CRUD and active/order state; customer sees only active A banners. | Regional isolation and ordering. |
|
||||
| BE-ADMIN-12 | P1 | Regional coupon CRUD, targeting, user targeting, invalidation. | Region/targets enforced; invalid coupon rejected for use. |
|
||||
| BE-ADMIN-13 | P1 | Slot CRUD, SKU assignment, capacity, freeze/edit. | Customer discovery/checkout reflects changes; full slots disabled. |
|
||||
| BE-ADMIN-14 | P1 | Product tags/groups/customize-app ordering in A. | Persisted order and popular/all-items output. |
|
||||
| BE-ADMIN-15 | P0 | Search customers by name/mobile in A; same search in B. | Only customers with A/B orders respectively; no cross-region mobile leakage (`BR-01`). |
|
||||
| BE-ADMIN-16 | P1 | Customer detail, order history, suspension/unsuspension, incidents. | Region-scoped; suspension blocks ordering; incident audit correct. |
|
||||
| BE-ADMIN-17 | P0 | `sendAdminNotification` as staff, customer, anonymous. | Staff allowed; customer/anonymous denied; no queue write on denial. |
|
||||
| BE-ADMIN-18 | P1 | Vendor snippet CRUD, order/slot reads, packaging (conditional). | Scoped to staff region; unauthorized IDs denied. |
|
||||
| BE-ADMIN-19 | P1 | Complaints list/reply/resolve in A; B complaint invisible. | Region isolation; customer sees the reply. |
|
||||
| BE-ADMIN-20 | P1 | Region constants edit and propagation to A bounds. | A customer discovery/pricing changes; B unchanged. |
|
||||
| BE-ADMIN-21 | P0 | `getStaff`, `createStaffUser`, `getRoles`, `savePushToken` as customer. | Denied (protectedProcedure is not a staff guard — regression check). |
|
||||
| BE-ADMIN-22 | P1 | Image upload URL generation and object round-trip. | Authorized contexts only; stored bytes match; no arbitrary-key delete. |
|
||||
|
||||
#### Superadmin API
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-SA-01 | P0 | Superadmin login/me; direct protected route access. | Correct principal; no staff/customer escalation. |
|
||||
| BE-SA-02 | P0 | Staff/customer/anonymous calls every superadmin mutation. | Denied before DB/job writes. |
|
||||
| BE-SA-03 | P0 | Region list/create/update; duplicate name/invalid bounds. | Valid region; clear conflict; no orphan rows. |
|
||||
| BE-SA-04 | P1 | Bound create/update/delete: last bound, referenced bound, valid bound. | Last/referenced refused; valid delete succeeds. |
|
||||
| BE-SA-05 | P0 | Create a region with global products present; inspect cache files. | Per-region market rows seeded; cache generation awaited and files exist (`BR-07`). |
|
||||
| BE-SA-06 | P1 | Staff list/create/update/remove/roles and region assignment. | Region/role changes effective on next auth; removed staff denied. |
|
||||
| BE-SA-07 | P1 | Global store CRUD and customer visibility in all regions. | Shared store visible; regional admin cannot edit it. |
|
||||
| BE-SA-08 | P0 | Global product create/edit/delete with two SKUs. | Per-region market rows; customer sees it in A/B. |
|
||||
| BE-SA-09 | P0 | Edit an existing global product's SKUs and save. | IDs preserved; no duplicate variants; suspension state coherent (`BR-03`). |
|
||||
| BE-SA-10 | P1 | Elevate a regional product to global. | Region becomes null; market rows exist; former region keeps selling. |
|
||||
| BE-SA-11 | P0 | Global product suspension/market edits. | Global structural suspension applies where intended; regional overrides independent. |
|
||||
| BE-SA-12 | P1 | Global coupon create/edit/delete with percent, flat, targets, users. | Valid coupon; one discount type; superadmin-only. |
|
||||
| BE-SA-13 | P1 | Global constants edit; customer discovery in A/B. | Global values propagate; regional/bound overrides win. |
|
||||
| BE-SA-14 | P1 | Superadmin complaints list/reply. | Cross-region visibility per policy; no customer-private leakage beyond scope. |
|
||||
| BE-SA-15 | P0 | `superadmin.staff.sendAdminNotification` as superadmin/staff/customer. | Superadmin allowed; staff/customer denied; queue write only on success (`BR-16`). |
|
||||
| BE-SA-16 | P1 | Region cache files after create/update; served version matches. | Files exist for the new region; no undefined/version-0 paths. |
|
||||
| BE-SA-17 | P1 | Staff role/permission checks for global authoring. | Only intended roles can author; server-side enforcement. |
|
||||
| BE-SA-18 | P2 | Region rename/priority changes while customers browse. | IDs stable; discovery refreshes within deadline; no data moves. |
|
||||
|
||||
#### Cache, jobs and health
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| BE-CACHE-01 | P0 | Regional product/store/tag/banner change in A. | A cache files/version advance; B unchanged. |
|
||||
| BE-CACHE-02 | P0 | Price/stock/offer/suspension edit in A. | Availability version/data correct; no stale orderable SKU. |
|
||||
| BE-CACHE-03 | P0 | Slot create/update/full/freeze. | Slots/next-delivery/cart choices converge within 120s. |
|
||||
| BE-CACHE-04 | P0 | Global change followed by a regional change in the debounce window. | All regions regenerate; regional request cannot narrow (`BR-05`). |
|
||||
| BE-CACHE-05 | P1 | Rapid A/B edits in the same window. | Both pending regions publish; final write not lost. |
|
||||
| BE-CACHE-06 | P1 | Several same-region writes while generation is running. | Final snapshot is current; no stale final write. |
|
||||
| BE-CACHE-07 | P1 | Missing/corrupt discovery KV for a bound. | Rebuilt for the correct bound; no foreign fallback. |
|
||||
| BE-CACHE-08 | P0 | Products file ready, availability old/missing/wrong region. | No unsafe zero-price/in-stock or mixed-region purchasable catalog. |
|
||||
| BE-CACHE-09 | P1 | Object-storage failure during generation. | Failure recorded; version not falsely complete; retry/repair coherent. |
|
||||
| BE-CACHE-10 | P1 | Fresh vs already-open client after publication. | Both converge; no restart/storage-clear requirement. |
|
||||
| BE-CACHE-11 | P1 | Product soft-deleted while generation pending. | Live surfaces omit it; order history unaffected. |
|
||||
| BE-CACHE-12 | P1 | Cache consistency: every availability entry maps to a product; slot products exist; store counts match. | All cross-file references valid. |
|
||||
| BE-JOB-01 | P1 | Store initializer/startup and flash schedule job in an isolated scheduler. | Stores ready; flash enablement boundaries correct; no production cron touched. |
|
||||
| BE-JOB-02 | P1 | Queue/notification job failure after order commit. | Order remains; job retryable; no duplicate order. |
|
||||
| BE-JOB-03 | P1 | Health check with DB/KV/storage failures. | Explicit degraded status, not false healthy. |
|
||||
| BE-UPL-01 | P1 | Upload URL contexts: review, product, store, complaint, profile, tags, notification. | Correct folder/key and MIME; no arbitrary path. |
|
||||
| BE-UPL-02 | P0 | Unauthorized upload URL request. | Denied; no signed URL returned. |
|
||||
| BE-UPL-03 | P2 | Unsupported MIME/context and oversized payload. | Validation error; no object written. |
|
||||
|
||||
### 6.2 Customer frontend flows (L2 native + L4 web)
|
||||
|
||||
Run each case on both `user-ui` and `web-ui` unless a platform note says otherwise.
|
||||
The expected outcome must match; platform-specific mechanics are noted.
|
||||
|
||||
#### Startup, location and region
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-01 | P0 | Cold start with GPS inside A; signed out, then signed in. | A resolves once; discovery/catalog/slots load; no bound/version errors. Web: saved region is validated against `listRegions`. |
|
||||
| CUST-02 | P0 | GPS denied, off, outside service and timed out; with and without a default address. | Default address used when available; otherwise a usable manual chooser with the correct reason; no eternal spinner. |
|
||||
| CUST-03 | P0 | Late GPS response after manually choosing B. | Manual choice wins; late response cannot overwrite it. |
|
||||
| CUST-04 | P1 | Signed-in U1 with addresses in A1/A2; remove one; select an address. | Active bound is the lowest-priority A address bound; B addresses ignored; checkout uses selected address bound. |
|
||||
| CUST-05 | P0 | Explicit region switch A→B: cancel, then confirm. | Cancel preserves region/carts; confirm clears A selections and loads B. |
|
||||
| CUST-06 | P1 | Switch A→B→A with populated regular and flash carts. | Each region's cart is restored independently; no cross-region lines/prices. |
|
||||
| CUST-07 | P1 | Cold-start adoption of the first region with a populated local cart. | Cart is preserved (known open if it is wiped — `BR-10`). |
|
||||
| CUST-08 | P2 | Empty region and region with no slots. | Intentional empty states; no crash or fallback to another region. |
|
||||
|
||||
#### Authentication and account
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-09 | P0 | Browse signed out, open Cart and Me. | Public browsing works; login walls shown without breaking other tabs. |
|
||||
| CUST-10 | P0 | Log in from the cart wall, then from the Me wall; register a new account. | Returns to the originating screen; cart survives login; validation errors are clear. |
|
||||
| CUST-11 | P0 | Wrong password/unknown identifier, then correct; logout and sign in as U2. | No session on failure; U2 cannot see U1 data; logout restores walls. |
|
||||
| CUST-12 | P1 | Session restore after relaunch; expired token during a request. | Valid session restores; expiry forces re-login safely, preserving allowed state. |
|
||||
| CUST-13 | P1 | Edit profile and avatar; relaunch; check admin customer detail. | Saved values/images agree. |
|
||||
| CUST-14 | P1 | Change password, sign out, old vs new password. | New works; old fails; account data intact. |
|
||||
| CUST-15 | P1 | Delete account with wrong/correct confirmation. | Wrong rejected; correct logs out and revokes access. |
|
||||
| CUST-16 | P0 | Suspended customer tries to order; admin unsuspends; retry. | Blocked then allowed; no misleading success. |
|
||||
|
||||
#### Home, search, stores and product detail
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-17 | P0 | Home in A vs B with regional/global products, tags, banners, stores and slots. | Only correct region + global content; no cross-region prices/assets. |
|
||||
| CUST-18 | P1 | Empty/loading/error/refresh states on Home; pull-to-refresh. | Meaningful states; retry works; no duplicate/stale content. |
|
||||
| CUST-19 | P1 | Search by product name/tag/store; no results. | Correct results for the region; clear empty state. |
|
||||
| CUST-20 | P1 | Stores list and store detail; global store in both regions. | Correct products/counts; global store visible; no foreign store. |
|
||||
| CUST-21 | P0 | Product detail P, Q, G, combo C, flash F. | Correct price/variants/stock/flags/composition; foreign product not reachable. |
|
||||
| CUST-22 | P1 | Add to cart from Home, search, store, product detail, order-again. | Same SKU/quantity/price on every entry point. |
|
||||
| CUST-23 | P1 | Variant/quantity dialog: minimum, increments, maximum, OOS. | Allowed quantities enforced; OOS cannot be added. |
|
||||
| CUST-24 | P1 | Offers/tags/banners deep link to the intended product/store. | Correct destination; no broken/foreign target. |
|
||||
| CUST-25 | P2 | Location bar / address switcher opening and closing. | Current location/address shown; selection updates the active bound. |
|
||||
|
||||
#### Cart and coupons
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-26 | P0 | Add, re-add, update quantity, remove, cancel removal. | Merge vs set-quantity semantics correct; only the selected line changes. |
|
||||
| CUST-27 | P0 | Populated cart cold start; regular and flash carts separately. | Both restore independently; no silent deletion or cross-cart leak. |
|
||||
| CUST-28 | P1 | Assign/change slots; leave/re-enter/relaunch. | Selection persists per policy; no quantity duplication. |
|
||||
| CUST-29 | P0 | One line becomes OOS/suspended/deleted; all lines invalid. | Invalid lines excluded from pricing/submit; all-invalid checkout blocked. |
|
||||
| CUST-30 | P1 | Notes entered, checkout, back, edit; latest note submitted. | Latest value survives and is persisted. |
|
||||
| CUST-31 | P0 | Coupon dropdown: eligible, wrong region, first-order-used, min-order short, no targets, expired, invalidated, used-up, personal. | Eligible first; disabled rows show the exact reason; hidden coupons never appear. |
|
||||
| CUST-32 | P0 | Apply/remove stacked coupons; change quantities. | Marginal savings and totals recompute; no stale invalid discount. |
|
||||
| CUST-33 | P0 | 10% then ₹100 vs ₹100 then 10%; 15% rounding; 100%+ coupon. | Order-sensitive totals; nearest-rupee rounding; no negative preview. |
|
||||
| CUST-34 | P1 | "Products discount" row shown/hidden at >₹1 vs ≤₹1; coupons separate. | Correct label/visibility; bill lines sum to total. |
|
||||
| CUST-35 | P0 | Checkout guard: item without slot, selected slot no longer offered, freeze passed, valid slots, flash cart. | Button disabled with the correct message for scheduled; flash exempt; recovery re-enables. |
|
||||
| CUST-36 | P0 | Cart preview vs checkout vs persisted order totals. | All three agree: goods − discount + delivery = payable. |
|
||||
| CUST-37 | P1 | Corrupt storage, storage full, slow price refresh. | Recoverable state; no phantom/zero-priced purchase; coherent loading. |
|
||||
| CUST-38 | P1 | Logout/login U2 with U1's cart; account switch. | Agreed cart-retention policy; no U1 address/coupon/notes leakage. |
|
||||
|
||||
#### Checkout and order placement
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-39 | P0 | Checkout with an address in A1 vs A2 vs B; inspect fee/threshold. | Selected address's bound/region drives pricing; browsing region does not override. |
|
||||
| CUST-40 | P0 | Customer with zero addresses opens cart/checkout. | First-address gate appears before cart, even when empty; after saving, cart renders. |
|
||||
| CUST-41 | P0 | Scheduled checkout with items assigned to S1/S2. | Each submitted line carries its own slot ID; no null scheduled slot (`BR-06`). |
|
||||
| CUST-42 | P0 | Valid COD checkout; inspect payment UI. | COD succeeds; online option is disabled "coming soon"; no gateway invocation. |
|
||||
| CUST-43 | P0 | Change coupons/address/slot/notes after returning from cart. | Latest state shown and submitted; no stale route params. |
|
||||
| CUST-44 | P0 | Double-tap Place Order; pending rerender. | Synchronous guard sends one in-app request. |
|
||||
| CUST-45 | P1 | Mutation fails, then retry; session expires mid-checkout. | Loading released, error shown, state preserved; login return safe. |
|
||||
| CUST-46 | P1 | Response lost after commit. | History checked before retry; no false claim of server deduplication. |
|
||||
| CUST-47 | P0 | Client tampers with price/discount/region/bound/slot. | Server ignores client money/region and uses authoritative values. |
|
||||
| CUST-48 | P1 | Multi-sub-order success and zero-total success. | Success references valid orders/group; authoritative totals/zero handled. |
|
||||
| CUST-49 | P1 | Flash checkout in A (enabled) vs B (disabled). | Flash price/fee/null slot in A; rejected in B even via direct route. |
|
||||
| CUST-50 | P1 | Android back/iOS swipe/browser refresh/deep link to success. | No duplicate order, lost notes or wrong-order detail. |
|
||||
|
||||
#### Orders, profile and support
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| CUST-51 | P0 | My Orders list: pending/delivered/cancelled, split group, pagination. | Correct rows/status/labels; no missing/duplicate pages. |
|
||||
| CUST-52 | P1 | Order detail: items, address, slots, bill, status timeline, notes. | Matches persisted order/admin view; discount/delivery/total reconcile. |
|
||||
| CUST-53 | P0 | Cancel a fresh order with a reason; cancel a delivered order. | Reason required; allowed/denied transitions correct; coupon restored when applicable. |
|
||||
| CUST-54 | P1 | Order again / reorder; historical deleted product. | Valid lines re-added; unavailable lines handled; history remains readable. |
|
||||
| CUST-55 | P1 | Raise a complaint with/without image; view admin reply. | Persisted, region-correct, visible reply; no cross-user access. |
|
||||
| CUST-56 | P1 | Addresses: add with map coords, edit/default/delete, outside-area point. | Bound/region derived; errors clear; default policy correct. |
|
||||
| CUST-57 | P1 | Coupons page: eligible/used/expired labels and empty state. | Agrees with eligibility rules; no hidden coupon shown as available. |
|
||||
| CUST-58 | P1 | Push permission/token registration; region sync after address add; notification deep link. | Token stored for the address region; link opens the intended order/product. |
|
||||
| CUST-59 | P2 | Offline/network failure on Home/cart/checkout. | Explicit error/retry; no false success; cart preserved. |
|
||||
| CUST-60 | P2 | Keyboard, safe area, back navigation and accessibility labels on checkout/cart. | Usable on small screens; no hidden action; controls have accessible names. |
|
||||
|
||||
### 6.3 Admin frontend flows (L3 native + L5 web)
|
||||
|
||||
Run each case on `admin-ui` and `admin-web`; note platform-specific reload/storage behaviour.
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| ADM-01 | P0 | Staff A login; reload; direct protected route. | Correct staff/region; session restores; no privileged flash before auth. |
|
||||
| ADM-02 | P0 | Staff A vs B dashboard/orders/products. | Only own-region data; no B counts/rows. |
|
||||
| ADM-03 | P0 | Logout, login as B; browser back to A route. | A data cleared; denied/redirected; no cached private content. |
|
||||
| ADM-04 | P0 | Customer/anonymous token on admin mutations. | Denied; UI hiding is not the only guard. |
|
||||
| ADM-05 | P0 | Orders list: filters, search, pagination, empty/error, delivered toggle. | Correct filtered rows and counts; keyset pagination stable. |
|
||||
| ADM-06 | P0 | Quiet region A with old orders while B has newer orders; load more. | A paginates its own rows; no empty list/starvation (`BR-09`). |
|
||||
| ADM-07 | P0 | Order detail: items, bill, address, notes, status, customer. | Matches persisted order; discount/delivery/total reconcile. |
|
||||
| ADM-08 | P0 | Mark packaged/verified/delivered; customer sees the change. | Status/timestamps persist; no partial item state. |
|
||||
| ADM-09 | P0 | Cancel with reason; cancel delivered; remove delivery charge. | Correct transitions; no duplicate fee; customer view reflects it. |
|
||||
| ADM-10 | P1 | Rebalance slots/items; verify pricing and discount preservation. | Items move; totals recompute; historic discount/delivery preserved. |
|
||||
| ADM-11 | P1 | Delivery sequence/map: order, coordinates, missing coords. | Stable sequence; coordinate edits scoped to the order. |
|
||||
| ADM-12 | P1 | Admin notes and customer notes. | Persist on the correct order; visible to the intended audience. |
|
||||
| ADM-13 | P0 | Products list/search/filter; open detail. | Region-correct products; OOS/suspended flags; no foreign items. |
|
||||
| ADM-14 | P0 | Create a regional product with two SKUs, features, images, tags. | Product/SKUs persist; customer sees it in A only. |
|
||||
| ADM-15 | P0 | Edit a regional product's SKU/price/stock/offer. | Updates one product; no duplicate SKUs; availability cache refreshes. |
|
||||
| ADM-16 | P0 | Edit a global product's market price/stock/flash/suspension in A. | Only A market changes; structure/B untouched. |
|
||||
| ADM-17 | P0 | Suspend a global SKU in A, reopen, change price, save. | Suspension preserved (`BR-11`). |
|
||||
| ADM-18 | P0 | Edit/delete a product with dependent rows. | Delete guards correct; image/asset lifecycle safe. |
|
||||
| ADM-19 | P1 | Prices overview and variant stock dialog. | Inline edits persist; invalid values rejected; cache updates. |
|
||||
| ADM-20 | P1 | Product tags: create/edit/delete/order; assign products. | Persisted ordering/membership; customer order matches. |
|
||||
| ADM-21 | P1 | Product groups: create/edit/delete/membership; assign to slot. | Group/slot semantics consistent; no orphan membership. |
|
||||
| ADM-22 | P1 | Combos: create combo and components; check customer detail. | Composition/pricing/flags correct. |
|
||||
| ADM-23 | P0 | Stores list/add/edit/delete; global store read-only. | Region isolation; global edit blocked; image preserved on failure. |
|
||||
| ADM-24 | P0 | Slots: create with SKUs, edit, capacity, freeze, detail. | Customer discovery/checkout reflects it; full slot blocked. |
|
||||
| ADM-25 | P1 | Coupons: list/create/edit/invalidate; targets/users. | Region/targets enforced; invalid coupon cannot be used. |
|
||||
| ADM-26 | P1 | Banners: create/edit/delete/order/active. | Customer sees only active A banners in order. |
|
||||
| ADM-27 | P1 | Customize app: popular items and all-items ordering. | Persisted order; customer home matches. |
|
||||
| ADM-28 | P1 | Users: list, search by name/mobile, detail, suspend/unsuspend. | Search region-scoped; suspension blocks ordering; no cross-region leakage (`BR-01`). |
|
||||
| ADM-29 | P0 | Search a U1 mobile from staff B; search same name with A/B customers. | B sees nothing/only B; A sees only A (`BR-01`). |
|
||||
| ADM-30 | P1 | User incidents and notifications to selected users. | Incident audit correct; notification queued only for allowed recipients. |
|
||||
| ADM-31 | P1 | Complaints list/reply/resolve. | Region-scoped; customer sees the reply. |
|
||||
| ADM-32 | P1 | Vendor snippets: create/edit/delete, order/slot reads. | Region-scoped; slot picker works after reload (web, `BR-15`). |
|
||||
| ADM-33 | P1 | Region constants edit. | A customer discovery/pricing changes; B unchanged. |
|
||||
| ADM-34 | P1 | Upload product/store/banner images. | Upload succeeds; URL persisted; replaced image cleanup safe. |
|
||||
| ADM-35 | P2 | Empty/loading/error states across dashboard routes. | Retry/back navigation works; no permanent spinner. |
|
||||
|
||||
### 6.4 Superadmin frontend flows (L6)
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| SA-01 | P0 | Login/logout, reload, direct protected route. | Session restores; logout clears; no staff/customer access. |
|
||||
| SA-02 | P0 | Regions list; create region with at least one bound. | Region appears; cache files generated; assignments possible. |
|
||||
| SA-03 | P0 | Create region without bounds, duplicate priorities, malformed GeoJSON. | Validation/conflict; no half-created region. |
|
||||
| SA-04 | P1 | Edit region name/metadata; add/edit/delete bounds. | Stable IDs; last/referenced bound refused; customers converge. |
|
||||
| SA-05 | P0 | Region creation with global products. | Per-region market rows seeded; no zero-price sale. |
|
||||
| SA-06 | P0 | Region cache generation on create/edit. | Files exist and are served; no `v-undefined` (`BR-07`). |
|
||||
| SA-07 | P1 | Staff list/create/update/remove/roles. | Region/role assignment effective; removed staff denied. |
|
||||
| SA-08 | P1 | Global stores CRUD. | Visible in all regions; regional admins read-only. |
|
||||
| SA-09 | P0 | Global products list/create/edit/delete; two SKUs. | Per-region markets; customer sees in A/B. |
|
||||
| SA-10 | P0 | Edit an existing global product; save twice. | SKU IDs preserved; no duplicate variants (`BR-03`). |
|
||||
| SA-11 | P0 | Switch create→edit and edit→create in the form. | Form state resets/keyed; no draft bleed (`BR-08`). |
|
||||
| SA-12 | P0 | Suspend/edit market data; regional admin view. | Global vs regional flags independent. |
|
||||
| SA-13 | P1 | Elevate a regional product. | Region null, market rows, still purchasable. |
|
||||
| SA-14 | P1 | Global coupons: create/edit/delete/targets/users. | Valid; one discount type; applies in both regions. |
|
||||
| SA-15 | P0 | Change a global coupon from percent to flat and save. | Percent cleared; pricing uses flat only (`BR-14`, known open). |
|
||||
| SA-16 | P1 | Global constants edit. | Propagates to A/B discovery; regional overrides win. |
|
||||
| SA-17 | P1 | Complaints list/reply; admin notifications. | Correct scope; no private leakage. |
|
||||
| SA-18 | P0 | "Admin Notifs": send as superadmin. | Success and queue write; no guard failure (`BR-16`). |
|
||||
| SA-19 | P0 | Staff/customer token calls superadmin routes. | Denied; no data. |
|
||||
| SA-20 | P1 | Empty/loading/error states and destructive confirmations. | No accidental delete; clear errors. |
|
||||
| SA-21 | P1 | Upload global store/product images. | URL persists; shared asset not deleted by regional failure. |
|
||||
| SA-22 | P2 | Region tabs and selected-region switching. | Correct context; stale labels refresh by ID. |
|
||||
| SA-23 | P1 | Cache status after global edit. | All regions publish within deadline; no regional narrowing. |
|
||||
|
||||
### 6.5 Conditional and legacy surfaces
|
||||
|
||||
Run only when product/operations confirms support. `N/A` requires a reason.
|
||||
|
||||
| ID | P | Case | Expected |
|
||||
|---|---|---|---|
|
||||
| COND-01 | P2 | Vendor snippet page: login, list orders, open packaging. | Scoped to the snippet/staff region; packaging correct. |
|
||||
| COND-02 | P2 | Reviews: create a review with image; admin response. | Persisted/visible if the feature is supported; otherwise N/A. |
|
||||
| COND-03 | P2 | OTP login in an isolated provider sandbox. | Account created/authenticated once; no real SMS; otherwise N/A. |
|
||||
| COND-04 | P2 | Legacy fallback login/home/order-details pages. | Only supported ownership paths are exercised; demos/unsupported pages are N/A with reason. |
|
||||
|
||||
### 6.6 Cross-app E2E journeys (L7)
|
||||
|
||||
Only these critical chains use the real backend and real clients.
|
||||
|
||||
| ID | P | Journey | Expected |
|
||||
|---|---|---|---|
|
||||
| E2E-01 | P0 | Superadmin creates region A + bound + staff → staff creates store/product/slot/coupon → customer U1 sees catalog and places COD order → staff packages/delivers → customer sees delivered. | Full chain; IDs and money agree at every step. |
|
||||
| E2E-02 | P0 | Superadmin creates global product G with A/B prices → customer sees G in A and B with different prices → regional admin edits A market price → A changes, B does not. | Global structure shared; market data isolated. |
|
||||
| E2E-03 | P0 | Customer switches A→B and back on native and web with populated carts. | Region content/carts isolated; explicit switch clears/restores correctly. |
|
||||
| E2E-04 | P0 | Coupon stack (10% + ₹100) across web/native checkout; verify persisted order/admin detail. | 200 discount on ₹1000; all surfaces agree; no negative totals. |
|
||||
| E2E-05 | P0 | Flash order in A (enabled) and blocked flash attempt in B. | Flash price/flag in A; server rejection in B. |
|
||||
| E2E-06 | P0 | Multi-slot order S1/S2 with one delivery fee; admin fulfills both. | One group, two sub-orders, one fee; statuses consistent. |
|
||||
| E2E-07 | P0 | Cancel an order using a first-order coupon; verify usage restoration and re-order. | Coupon usable again only when no sibling remains. |
|
||||
| E2E-08 | P0 | Web scheduled checkout with items in two slots. | No null-slot rejection; correct slots persisted (`BR-06`). |
|
||||
| E2E-09 | P0 | Staff B searches U1's name/mobile; staff A searches same. | B cannot see A customer; A can (`BR-01`). |
|
||||
| E2E-10 | P0 | Global product edit → both region caches refresh → customers in A/B see it. | All regions publish; regional edit does not narrow (`BR-05`). |
|
||||
| E2E-11 | P1 | Admin-web reload → vendor snippet slot picker. | Slots load; staff/region restored (`BR-15`). |
|
||||
| E2E-12 | P1 | Superadmin sends "Admin Notifs" to admins. | Queued, not UNAUTHORIZED (`BR-16`). |
|
||||
| E2E-13 | P0 | Authorization probe: customer token against admin/superadmin mutations; staff against superadmin. | Denied at every step; no writes. |
|
||||
| E2E-14 | P1 | Product soft-delete after an order; customer/admin order history. | Original name/amount render; catalog removes it. |
|
||||
| E2E-15 | P0 | Address with coordinates in B while browsing A; place order. | Order appears in B admin queue and B pricing; A unaffected. |
|
||||
| E2E-16 | P1 | Cancelled/delivered transitions and customer notification deep link. | Correct status/link; no duplicate order. |
|
||||
|
||||
---
|
||||
|
||||
## 7. Current-branch regression pack (release-blocking)
|
||||
|
||||
These cases must be automated first; they encode the defects found in the
|
||||
`MULTI_REGION_I2` review and the fixes applied during hardening.
|
||||
|
||||
| ID | P | Scenario | Expected | Automation |
|
||||
|---|---|---|---|---|
|
||||
| BR-01 | P0 | Staff A and B search customers by a name/mobile that exists in both regions. | A returns only customers with A orders; B only B; no cross-region mobile leakage. | `apps/backend/tests/api/admin-region-isolation.test.ts` |
|
||||
| BR-02 | P0 | Web customer selects region/bound; inspect `essentialConsts` request. | Request sends `{ boundId }`, never `{ regionId }`; catalog/slots enable. | `apps/web-ui/tests/flows/discovery.test.tsx` + E2E |
|
||||
| BR-03 | P0 | Superadmin edits a global product with two existing SKUs and saves twice. | SKU IDs preserved; SKU count unchanged; no suspended duplicate. | `apps/backend/tests/api/superadmin.test.ts` |
|
||||
| BR-04 | P0 | Regional staff edits a global store with an image; mutation rejected. | Image/object remains; no partial update. | `apps/backend/tests/api/admin-catalog.test.ts` |
|
||||
| BR-05 | P0 | Global product edit, then regional banner edit inside the debounce window; inspect caches. | `allRegionsPending` wins; every region regenerates. | `apps/backend/tests/api/cache-region.test.ts` |
|
||||
| BR-06 | P0 | Web scheduled checkout with items in S1/S2. | Each item sends its `slotId`; no `slotId: null`; order succeeds. | `apps/web-ui/tests/flows/checkout.test.tsx` + E2E-08 |
|
||||
| BR-07 | P0 | Superadmin creates a region with global products. | Cache files exist after the response; `createRegionCacheFiles` awaited. | `apps/backend/tests/api/regions.test.ts` |
|
||||
| BR-08 | P1 | Superadmin global products: open create, then edit, then create again. | Form resets/keyed; no draft bleed; submit targets the selected product. | `apps/superadmin-ui/src/routes/global-products.test.tsx` |
|
||||
| BR-09 | P0 | Region A has old orders; region B creates > limit + 5 newer orders; page A. | A returns its rows and a valid next cursor; no global-ID window starvation. | `apps/backend/tests/api/admin-orders.test.ts` |
|
||||
| BR-10 | P1 | Cold start adopts the first region with a populated persisted cart. | Cart preserved; only an explicit switch away clears it. | `apps/user-ui/tests/flows/region.test.tsx` + `apps/web-ui/tests/flows/cart.test.tsx` — **known open** |
|
||||
| BR-11 | P0 | Suspend a global SKU in A; reopen; change only price/stock; save. | Suspension remains `true` in A; B unchanged. | `apps/backend/tests/api/admin-catalog.test.ts` |
|
||||
| BR-12 | P0 | Two ₹101 sub-orders + two ₹101 stackable coupons. | Discounts `[101, 101]`; totals `[0, 0]`; no negative; delivery handled separately. | `apps/backend/tests/api/coupon-math.test.ts` + `packages/shared` via API |
|
||||
| BR-13 | P2 | Historical order with a coupon-implied discount after migration. | `discount_amount` is `0` (accepted): invoices show no discount; derivation is not required. | `apps/backend/tests/api/order-lifecycle.test.ts` — **accepted limitation** |
|
||||
| BR-14 | P1 | Change a global coupon 20% → ₹50 and save. | Percent is cleared; pricing uses ₹50. | `apps/backend/tests/api/coupons.test.ts` — **known open** |
|
||||
| BR-15 | P1 | Admin-web reload on the vendor snippet screen. | `admin.staffUser.me` restores staff/region; slots load. | `apps/admin-web/tests/flows/vendor-snippets.test.tsx` |
|
||||
| BR-16 | P0 | Superadmin sends an admin notification. | `superadmin.staff.sendAdminNotification` succeeds; staff endpoint still staff-guarded. | `apps/backend/tests/api/admin-ops.test.ts` |
|
||||
| BR-17 | P0 | Customer checkout and order detail. | COD only; no online-payment method/routes; disabled "coming soon" card if present. | `apps/backend/tests/api/order-flow.test.ts` + customer UI flows |
|
||||
| BR-18 | P0 | Scheduled order with one null slot and one valid slot. | Rejected; no partial order; valid per-line slots succeed. | `apps/backend/tests/api/place-order-edge-cases.test.ts` |
|
||||
| BR-19 | P0 | Address in B while client sends A; bound-specific fee. | Address region/bound wins; correct fee/region. | `apps/backend/tests/api/order-rules.test.ts` |
|
||||
| BR-20 | P1 | A/B order pagination with interleaved IDs. | Stable keyset pages for each region; no skipped duplicate rows. | `apps/backend/tests/api/admin-orders.test.ts` |
|
||||
|
||||
---
|
||||
|
||||
## 8. Existing coverage and gaps
|
||||
|
||||
### Reuse before writing new files
|
||||
|
||||
| Existing suite | Reuse/extend for |
|
||||
|---|---|
|
||||
| `apps/backend/tests/api/order-flow.test.ts`, `order-rules.test.ts`, `place-order-edge-cases.test.ts` | `BE-ORDER-01`–`BE-ORDER-15`, `BR-18`, `BR-19` |
|
||||
| `apps/backend/tests/api/coupon-math.test.ts`, `coupons.test.ts`, `coupon-ux.test.ts`, `order-lifecycle-gaps.test.ts` | `BE-COUP-01`–`BE-COUP-18`, `BR-12`, `BR-14` |
|
||||
| `apps/backend/tests/api/admin-orders.test.ts`, `admin-ops.test.ts`, `order-lifecycle.test.ts` | `BE-ORDER-20`–`BE-ORDER-26`, `BR-09`, `BR-20` |
|
||||
| `apps/backend/tests/api/authorization.test.ts`, `authorization-matrix.test.ts` | `BE-AUTH-09`, `BE-ADMIN-02`, `BE-ADMIN-21`, `BR-16` |
|
||||
| `apps/backend/tests/api/cache-*.test.ts` | `BE-CACHE-01`–`BE-CACHE-12`, `BR-05` |
|
||||
| `apps/user-ui/tests/screens/cart-*.test.tsx`, `checkout*.test.tsx`, `order-*.test.tsx` | `CUST-26`–`CUST-55` baseline; replace component assertions with flow assertions where needed |
|
||||
| `apps/admin-ui/tests/screens/*` | `ADM-05`–`ADM-35` baseline; add multi-region/global cases |
|
||||
| `apps/superadmin-ui/src/lib/bound-rules.test.ts` | Pure bound validation only; keep as-is, add route-level `SA-*` cases |
|
||||
|
||||
### Current coverage
|
||||
|
||||
| App / suite | Existing | Gaps to fill |
|
||||
|---|---|---|
|
||||
| `apps/backend/tests/api` | 35 Jest files (~192 describe/it entries), real HTTP, auth/order/coupon/cache/admin basics. | Multi-region/bounds, global products/stores, superadmin, region isolation, keyset pagination, store ownership/image, SKU ID preservation, cache all-regions flag, COD-only regression, web discovery contract, discount history. |
|
||||
| `apps/user-ui/tests` | 367 tests, mostly screen/component with mocked network. | Real screen-flow coverage for region adoption/switch, web parity, flash, checkout per-slot payload, account switching, startup cart preservation. |
|
||||
| `apps/admin-ui/tests` | 497 tests, screen/component with mocked network. | Multi-region/global market editing, region isolation, order keyset pagination, store image ownership, admin-web parity, cache-visible effects. |
|
||||
| `apps/web-ui` | None. | Full L4 route-level harness + flows: discovery, auth, catalog, cart, checkout, orders, profile, flash. |
|
||||
| `apps/admin-web` | None. | Full L5 route-level harness + flows; staff restore after reload; parity with admin-ui. |
|
||||
| `apps/superadmin-ui` | One unit test (`bound-rules.test.ts`). | L6 route tests for login, regions/bounds, staff, global stores/products/coupons, constants, notifications, cache. |
|
||||
| `tests/e2e` | 3 Maestro flows + subflows (add product, add slot, user order). | Region/global journeys, web checkout, coupon money, cancellation, authorization probes, cross-app chain. |
|
||||
| `tests/e2e-web` | None. | Playwright critical web journeys. |
|
||||
|
||||
Recommended new files:
|
||||
|
||||
- Backend: `regions-bounds.test.ts`, `global-catalog.test.ts`, `superadmin.test.ts`, `admin-region-isolation.test.ts`, `cache-region.test.ts`, `payments-removed.test.ts`, `discount-history.test.ts`.
|
||||
- Customer native: `tests/flows/region.test.tsx`, `cart-region.test.tsx`, `checkout-slots.test.tsx`, `flash.test.tsx`, `orders.test.tsx`.
|
||||
- Admin native: `tests/flows/region-scope.test.tsx`, `global-products.test.tsx`, `order-pagination.test.tsx`, `store-safety.test.tsx`.
|
||||
- Customer web: `tests/flows/discovery.test.tsx`, `cart.test.tsx`, `checkout.test.tsx`, `orders.test.tsx`, `auth.test.tsx`.
|
||||
- Admin web: `tests/flows/auth-restore.test.tsx`, `orders.test.tsx`, `products-global.test.tsx`, `vendor-snippets.test.tsx`.
|
||||
- Superadmin: `src/routes/regions.test.tsx`, `staff.test.tsx`, `global-products.test.tsx`, `global-coupons.test.tsx`, `send-notifications.test.tsx`.
|
||||
- E2E: `tests/e2e/multi-region-order.yaml`, `tests/e2e-web/critical-journeys.spec.ts`.
|
||||
|
||||
---
|
||||
|
||||
## 9. Recommended implementation order
|
||||
|
||||
1. **Harness first**: backend fixture helpers for regions/bounds/global entities; web Jest/jsdom config; superadmin Vitest/jsdom config.
|
||||
2. **P0 backend**: authorization matrix, region isolation, order placement/money, coupon math, cache all-regions, store/global SKU safety.
|
||||
3. **P0 web**: discovery `boundId`, scheduled checkout slots, admin-web reload, superadmin notifications.
|
||||
4. **P0 native**: region startup/switch, checkout slot payload, coupon stacking, order/cancel flows.
|
||||
5. **P1 backend/admin**: CRUD coverage, fulfillment, pagination, notifications, uploads.
|
||||
6. **P1 web/superadmin**: parity flows and global authoring.
|
||||
7. **E2E**: only the critical journeys in §6.6, after the lower layers are stable.
|
||||
8. **Full regression** before release; run P0 twice (fresh session and already-open session).
|
||||
|
||||
CI split:
|
||||
|
||||
- PR: typecheck + backend P0 + affected UI flow suites.
|
||||
- Nightly: all backend API + web/native flow suites.
|
||||
- Pre-release: all P0/P1 + E2E + security matrix + cache deadline checks.
|
||||
|
||||
---
|
||||
|
||||
## 10. Known open / accepted items
|
||||
|
||||
| Item | Status | Handling |
|
||||
|---|---|---|
|
||||
| Startup region adoption clears a persisted cart (`region-switch.ts`) | **Open** | `BR-10` is expected to fail until fixed; mark as known defect, not a test bug. |
|
||||
| Global coupon percent→flat keeps the old percent (`global-coupons.ts`) | **Open** | `BR-14`/`SA-15`/`BE-COUP-18` must fail until fixed. |
|
||||
| Historical `discount_amount = 0` backfill | **Accepted** | `BR-13` asserts the accepted behavior; do not block release on it. |
|
||||
| Server-side order idempotency | Deferred | Characterize concurrent submits; UI guard is required; do not assert deduplication. |
|
||||
| OTP login/SMS | Approval-only | Excluded from default regression; use an isolated provider sandbox. |
|
||||
| Reviews, vendor snippets, legacy fallback pages | Conditional | Run only if product/operations confirms support. |
|
||||
| Online payments | Removed | Assert COD-only; no gateway routes/UI. |
|
||||
| Admin `protectedProcedure` endpoints (`getStaff`, `createStaffUser`, `getRoles`, `savePushToken`) | **Pending decision** | `BE-ADMIN-21` encodes the staff-only expectation; if customers are intentionally allowed, document it and downgrade the case. |
|
||||
| No emulator/browser in the authoring environment | Process limitation | Cases are static proposals until a device/browser is available. |
|
||||
|
||||
---
|
||||
|
||||
## 11. Run report template
|
||||
|
||||
```text
|
||||
Run ID / date / code revision:
|
||||
Environment / verified API host / client build:
|
||||
Layer (L1–L7) / case ID / client / identity / region / bound:
|
||||
Fixture IDs and relevant pre-state:
|
||||
Actions and exact inputs:
|
||||
Expected / actual:
|
||||
Status: PASS | FAIL | BLOCKED | NOT RUN | N/A
|
||||
API status/body, persisted values, versions, timestamps:
|
||||
Screenshots/logs (redacted):
|
||||
Cleanup / retained evidence / linked defect:
|
||||
```
|
||||
|
||||
For every failure include the smallest reproduction, the authoritative data read,
|
||||
and whether any data was mutated. A `BLOCKED` harness result is never a pass.
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
# Global Stores & Products — Implementation Plans
|
||||
|
||||
Feature: **global stores and global products** that exist across every region, with
|
||||
**per-region market data** (price / stock / offer / region suspension) on
|
||||
`product_market_stats`.
|
||||
|
||||
Status: **planned, not started.** Do not begin Phase 2 until Phase 1 is verified.
|
||||
|
||||
## Confirmed decisions
|
||||
|
||||
| Decision | Choice |
|
||||
|---|---|
|
||||
| Global store admin access | **Read-only for regional admins.** Only superadmins create/edit/delete global stores. |
|
||||
| Global product defaults | Superadmin enters initial price/flags on create → **a market-stats row is seeded for every region** (and for future regions when created). |
|
||||
| Seeding a new region | On region create, **replicate the least-id region's global data** (its per-region market-stats rows for global SKUs) into the new region. |
|
||||
| Suspension | Global `is_suspended` lives on **`product_skus`** (superadmin only). Per-region `is_suspended_in_region` lives on **`product_market_stats`** (that region's admin). The admin "suspend" toggle moves to the region flag in Phase 2. |
|
||||
| "Global" representation | `store_info.is_global = 1` **and** `region_id = NULL`; a product is global iff its store is global. |
|
||||
| Rollout | **Phased:** backend → admin UI → superadmin UI. |
|
||||
| Global SKUs in slots/banners/tags/coupons | Allowed in every region (they resolve as "global"). |
|
||||
|
||||
## Phases
|
||||
|
||||
1. [Phase 1 — Per-region `product_market_stats`](./phase-1-per-region-market-stats.md)
|
||||
*Schema + migration + region-scoped read/write refactor. No "global" yet; existing
|
||||
regional behaviour must stay identical.*
|
||||
2. [Phase 2 — Global stores & products (backend)](./phase-2-global-stores-and-products-backend.md)
|
||||
*`is_global` + nullable region, superadmin routers + seeding, visibility, guards,
|
||||
per-region admin writes, cache regen.*
|
||||
3. [Phase 3 — Admin UI (RN + web)](./phase-3-admin-ui.md)
|
||||
*List global + regional products, separate read-only/global-edit component, read-only
|
||||
global stores.*
|
||||
4. [Phase 4 — Superadmin UI](./phase-4-superadmin-ui.md)
|
||||
*Global store + global product CRUD screens.*
|
||||
|
||||
## Cross-cutting ground rules
|
||||
|
||||
- **Do not run migrations.** All migration SQL is hand-written and applied by the user.
|
||||
Validate migration changes on a **fresh/copy DB** first.
|
||||
- **Do not run the test suites** unless asked. `tsc --noEmit` is fine.
|
||||
- Log every non-`.md`/`.txt` file change in `change-log.txt` (timestamp + diff) **before**
|
||||
editing.
|
||||
- Working tree is uncommitted; the user manages git.
|
||||
- Local D1 path (used for copies/probes):
|
||||
`apps/backend/.wrangler/state/v3/d1/miniflare-D1DatabaseObject/da3a80bd8d2cc8f1f070a313ef55c1800da50af994fa89a51c67a6d3e1f919f2.sqlite`
|
||||
|
||||
## Migration strategy — fold schema changes into the pending `0006`
|
||||
|
||||
`packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql` is **not applied yet** and
|
||||
already **rebuilds** `store_info`, `product_info`, `product_skus`, `product_market_stats`, and
|
||||
the rest of the region-ownership FK subgraph through `__new_*` tables.
|
||||
|
||||
So instead of writing separate recreate migrations (`0010`/`0011`), **edit `0006`'s `__new_*`
|
||||
DDL/copies directly**:
|
||||
- Phase 1 (per-region market stats) → edit `__new_product_market_stats`.
|
||||
- Phase 2 (global stores/products) → edit `__new_store_info` + `__new_product_info`.
|
||||
|
||||
This removes the risky standalone table recreates entirely: `0006` already rebuilds the whole
|
||||
connected subgraph in dependency order, so no FK-deferral juggling is needed. See each phase's
|
||||
§Migration for the exact edits.
|
||||
|
||||
> **Pending-migration set (after the `is_offer` fold).** `0007_addresses_bound_id` and
|
||||
> `0008_user_creds_unique_and_min_order_cleanup` are unrelated to these tables and stay as-is.
|
||||
> `0009_move_is_offer_to_market_stats` has been **folded into `0006` and deleted** — `0006` now
|
||||
> drops `is_offer` from `__new_product_skus` and adds it to `__new_product_market_stats`
|
||||
> (backfilled from the old `product_skus`).
|
||||
|
||||
> **Why Phases 1–2 are not folded yet.** Phase 1 makes `product_market_stats.region_id` `NOT NULL`;
|
||||
> until the Phase 1 write paths set it, the current code (`createProduct`/`updateProduct` insert
|
||||
> market stats without a region) would fail. Phase 2's `store_info`/`product_info` changes *are*
|
||||
> safe, but they're kept together with Phase 1's edit so the whole per-region/global schema lands
|
||||
> in one edit to `0006` when those phases are built.
|
||||
|
||||
> **DB state caveat:** the local dev D1 already contains `0006`'s *effects* (no
|
||||
> `d1_migrations` table — it was applied by hand). Editing `0006` means the local DB no longer
|
||||
> matches the file; validation requires **resetting local D1 and re-applying from `0000`**.
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
# Phase 1 — Per-region `product_market_stats`
|
||||
|
||||
Status: **✅ implemented 2026-10-10** (backend + sqlite helper; migration folded into `0006`).
|
||||
Depends on: nothing.
|
||||
Blocks: Phases 2–4.
|
||||
|
||||
> **Implementation notes**
|
||||
> - New `packages/db_helper_sqlite/src/lib/market-stats.ts` (`marketStatsForRegion`,
|
||||
> `isMarketStatsSuspended`).
|
||||
> - `productSkus.marketStats` is now a `many` relation; every `with: { marketStats: true }`
|
||||
> site picks the region row.
|
||||
> - `getProductDetailById` / `getProductById` (user + order) derive the region from the SKU's
|
||||
> product row; `getAllProductsWithUnits` picks per-SKU region.
|
||||
> - `getOrderProductById` now returns a single region-picked `marketStats` object; the order
|
||||
> path reads `product.isSuspended` (global) / `product.marketStats?.isSuspendedInRegion`.
|
||||
> - Suspension: a SKU is unavailable when `product_skus.is_suspended` (global) **or**
|
||||
> `product_market_stats.is_suspended_in_region` (per region) — helper `isSkuSuspended`. The
|
||||
> admin product write still sets the **global** `productSkus.isSuspended` in Phase 1; the
|
||||
> superadmin/region split lands in Phase 2.
|
||||
> - `getAvailabilityForCache` / `getProductAvailability` / `getSuspendedSkuIds` /
|
||||
> `updateProductPrices` / `toggleProductOutOfStock` / `updateProduct` / `createProduct` are
|
||||
> all region-filtered.
|
||||
> - The `0006` copy backfills every pre-existing market-stats row to the seeded region
|
||||
> (Mahabubnagar), matching the product backfill — so a fresh apply leaves regions 2+ empty
|
||||
> until products are created there (as before).
|
||||
> - Verified: `tsc --noEmit` backend/admin-ui/user-ui PASS (web-ui's 12 pre-existing errors
|
||||
> unchanged); `0000`→`0006` + data on a fresh DB yields `region_id=1`, `is_offer`,
|
||||
> `is_suspended_in_region` correctly.
|
||||
|
||||
## 1. Goal
|
||||
|
||||
Turn `product_market_stats` from **1 row per SKU** into **1 row per (SKU, region)** so that a
|
||||
region's price / stock / offer / suspension live in that region's own row. This phase does
|
||||
**not** introduce global products yet — it only makes the market data region-scoped.
|
||||
|
||||
**Success criterion:** after Phase 1, the customer caches (`products.json`,
|
||||
`availability.json`) and admin product screens for regions 1/2/3 are **identical to today**
|
||||
(same prices, stock, availability). No behaviour change for existing regional products.
|
||||
|
||||
## 2. Non-goals
|
||||
|
||||
- No `is_global`, no `store_info`/`product_info` changes, no superadmin UI.
|
||||
- No global products (that's Phase 2). The region a market-stats row belongs to is derived
|
||||
from the SKU's product row.
|
||||
|
||||
## 3. Data model
|
||||
|
||||
### `packages/db_helper_sqlite/src/db/schema.ts`
|
||||
|
||||
`productMarketStats` (currently lines ~204–214):
|
||||
|
||||
```ts
|
||||
export const productMarketStats = sqliteTable('product_market_stats', {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
skuId: integer('sku_id').notNull().references(() => productSkus.id),
|
||||
regionId: integer('region_id').notNull().references(() => regions.id),
|
||||
marketPrice: numericText('market_price'),
|
||||
ourPrice: numericText('our_price').notNull(),
|
||||
isFlashAvailable: integer('is_flash_available', { mode: 'boolean' }).notNull().default(false),
|
||||
flashPrice: numericText('flash_price'),
|
||||
isOutOfStock: integer('is_out_of_stock', { mode: 'boolean' }).notNull().default(false),
|
||||
isSuspendedInRegion: integer('is_suspended_in_region', { mode: 'boolean' }).notNull().default(false),
|
||||
isOffer: integer('is_offer', { mode: 'boolean' }).notNull().default(false),
|
||||
}, (t) => ({
|
||||
unq_sku_region: uniqueIndex('product_market_stats_sku_region').on(t.skuId, t.regionId),
|
||||
}))
|
||||
```
|
||||
|
||||
Changes vs today:
|
||||
- `skuId` loses `.unique()` (was 1:1).
|
||||
- **new** `regionId` (NOT NULL, FK `regions`).
|
||||
- **new** `isSuspendedInRegion` (bool, default false). The old market-stats
|
||||
`isSuspended` is **removed** — global suspension now lives on the SKU
|
||||
(`productSkus.isSuspended`), and its existing values are backfilled there.
|
||||
- **new** table-level unique index `(sku_id, region_id)`.
|
||||
- `productSkus` gains `isSuspended` (bool, default false) — the global
|
||||
(superadmin) kill-switch.
|
||||
|
||||
### Relations
|
||||
|
||||
- `productSkusRelations`: `marketStats: one(productMarketStats)` → **`many(productMarketStats)`**.
|
||||
- `productMarketStatsRelations`: add `region: one(regions, { fields: [productMarketStats.regionId], references: [regions.id] })`.
|
||||
|
||||
> A SKU now carries an **array** of market-stats rows. Every consumer must pick the row for
|
||||
> its `regionId` (helper below).
|
||||
|
||||
## 4. Schema change goes into `0006` (no new migration)
|
||||
|
||||
`packages/db_helper_sqlite/drizzle/0006_regions_and_superadmins.sql` is **not applied yet** and
|
||||
already rebuilds `product_market_stats` via `__new_product_market_stats`. Fold the per-region
|
||||
fields into that rebuild instead of a standalone `0010` recreate — `0006` already rebuilds the
|
||||
whole FK subgraph in dependency order, so no extra recreate is required.
|
||||
|
||||
### Edits to `0006_regions_and_superadmins.sql`
|
||||
|
||||
1. **`CREATE TABLE __new_product_market_stats`** — the `is_offer` column is already folded in
|
||||
(from `0009`, see README); now add the region column + FK and the region-suspension flag:
|
||||
```sql
|
||||
`region_id` integer NOT NULL,
|
||||
...
|
||||
`is_suspended_in_region` integer DEFAULT false NOT NULL,
|
||||
...
|
||||
FOREIGN KEY (`region_id`) REFERENCES `regions`(`id`) ON UPDATE no action ON DELETE no action
|
||||
```
|
||||
|
||||
2. **Its copy `INSERT INTO __new_product_market_stats … SELECT …`** — add `region_id` and
|
||||
`is_suspended_in_region` (the copy already selects `is_offer` and JOINs `product_skus` from the
|
||||
`0009` fold). All pre-existing rows are backfilled to Mahabubnagar:
|
||||
```sql
|
||||
INSERT INTO `__new_product_market_stats`
|
||||
(`id`,`sku_id`,`region_id`,`market_price`,`our_price`,`is_flash_available`,`flash_price`,`is_out_of_stock`,`is_suspended`,`is_suspended_in_region`,`is_offer`)
|
||||
SELECT
|
||||
ms.`id`, ms.`sku_id`, (SELECT `id` FROM `regions` WHERE `name` = 'Mahabubnagar'),
|
||||
ms.`market_price`, ms.`our_price`, ms.`is_flash_available`, ms.`flash_price`,
|
||||
ms.`is_out_of_stock`, ms.`is_suspended`, false, COALESCE(ps.`is_offer`, false)
|
||||
FROM `product_market_stats` ms
|
||||
JOIN `product_skus` ps ON ps.`id` = ms.`sku_id`;
|
||||
```
|
||||
- The `JOIN product_skus` (already present from the `0009` fold) prunes **orphan** market-stats
|
||||
rows whose SKU no longer exists.
|
||||
|
||||
3. **Replace the index** created at the end of `0006`:
|
||||
`CREATE UNIQUE INDEX product_market_stats_sku_id_unique ON product_market_stats (sku_id)`
|
||||
→ `CREATE UNIQUE INDEX product_market_stats_sku_region ON product_market_stats (sku_id, region_id)`.
|
||||
|
||||
**Validation:** apply the edited `0006` (from `0000`) to a **fresh** DB copy; confirm
|
||||
`pragma table_info(product_market_stats)` shows `region_id` + `is_suspended_in_region`, the new
|
||||
unique index exists, and there is exactly one row per SKU with `region_id` = the seeded region.
|
||||
|
||||
## 5. Region-aware access helper
|
||||
|
||||
Add a small shared helper (e.g. `packages/db_helper_sqlite/src/lib/market-stats.ts`):
|
||||
|
||||
```ts
|
||||
export type MarketStatsRow = InferSelectModel<typeof productMarketStats>
|
||||
export function marketStatsForRegion(stats: MarketStatsRow[] | undefined, regionId: number): MarketStatsRow | undefined {
|
||||
return stats?.find((s) => s.regionId === regionId)
|
||||
}
|
||||
```
|
||||
|
||||
Where a function does not currently receive a `regionId` (see §6), derive it from the SKU's
|
||||
product row (`sku.product.regionId`) in this phase.
|
||||
|
||||
## 6. Code changes
|
||||
|
||||
Every `with: { marketStats: true }` now returns an **array**; every `.marketStats` read must
|
||||
pick the region's row and suspension must test **both** flags
|
||||
(`!is_suspended && !is_suspended_in_region`).
|
||||
|
||||
### `packages/db_helper_sqlite/src/stores/store-helpers.ts`
|
||||
| Site | Change |
|
||||
|---|---|
|
||||
| `getAllProductsForCache` (~121,126,129) | `marketStats` array → `marketStatsForRegion(..., regionId)`; suspension check adds `isSuspendedInRegion`; region filter stays `product.regionId === regionId` (Phase 2 adds global). |
|
||||
| `getAvailabilityForCache` (~154) | query is already `productMarketStats.findMany` — add `eq(productMarketStats.regionId, regionId)` and filter `!isSuspended && !isSuspendedInRegion`. |
|
||||
| `getAllProductCombosForCache` (~246,274) | `ci.sku.marketStats` → pick region row. |
|
||||
| suspended-sku set (~252–260) | add `regionId` to the `where`. |
|
||||
| `getAllSlotsWithProductsForCache` (~389,408) | pick region row; suspension filter adds region flag. |
|
||||
|
||||
### `packages/db_helper_sqlite/src/user-apis/product.ts`
|
||||
| Site | Change |
|
||||
|---|---|
|
||||
| `getProductDetailById(skuId)` (~12–31) | no region param → derive `sku.product.regionId`; pick row; suspension check both flags. |
|
||||
| combo items (~56,68) | pick region row. |
|
||||
| `getProductById(skuId)` (~143–165) | derive region from product; pick row. |
|
||||
| `getAllProductsWithUnits(tagId?)` (~217) | **no region** — add a `regionId` parameter (see below). |
|
||||
| `getSuspendedSkuIds(regionId)` (~271) | add `regionId` filter to the query. |
|
||||
| `getAllSkusSummary(regionId)` (~347) | pick region row; suspension check both flags. |
|
||||
|
||||
> `getAllProductsWithUnits` is only consumed by the legacy controller
|
||||
> `apps/backend/src/apis/common-apis/apis/common-product.controller.ts` (pre-tRPC). Give it a
|
||||
> `regionId` param and pass the caller's region there, or note it as legacy if that controller
|
||||
> is dead.
|
||||
|
||||
### `packages/db_helper_sqlite/src/user-apis/order.ts`
|
||||
- `getProductById(skuId)` (~194–219) — derive region from product; pick row. (Phase 2 will add
|
||||
an explicit region for global SKUs.)
|
||||
|
||||
### `packages/db_helper_sqlite/src/user-apis/stores.ts`
|
||||
- `getStoreSummaries(regionId)` (~21,24) — pick region row.
|
||||
- `getStoreDetail(regionId, storeId)` (~81,87,90) — pick region row.
|
||||
|
||||
### `packages/db_helper_sqlite/src/user-apis/slots.ts`
|
||||
- `getProductAvailability(regionId)` (~37–61) — add `eq(productMarketStats.regionId, regionId)`.
|
||||
|
||||
### `packages/db_helper_sqlite/src/admin-apis/product.ts` (largest)
|
||||
- `mapSku` already takes a `marketStats` arg → callers must pass the region row.
|
||||
- `getAllProducts(regionId)` (~211–250): pick region row for `mapSku`; combo-item prices too.
|
||||
- `getProductById(regionId, id)` (~252): pick region row.
|
||||
- `createProduct` (~382): write `regionId` into the inserted market-stats row.
|
||||
- `updateProduct` (~535–556): upsert by `(skuId, regionId)` instead of `skuId`.
|
||||
- `updateProductPrices(regionId, …)` (~1118–1136): upsert by `(skuId, regionId)`.
|
||||
- `toggleProductOutOfStock(regionId, productId)` (~1143–1173): this is the **admin** toggle →
|
||||
it now sets **`is_suspended_in_region`**? *No — see note.* It currently toggles
|
||||
`is_out_of_stock`; keep it toggling `isOutOfStock` but scope to the region row.
|
||||
- `getProductTagInfoById` / `getAllProductTags` / groups (~670–952): pass region row to `mapSku`.
|
||||
|
||||
> **Suspension toggle note:** the admin-facing "suspend SKU" path is `updateProduct` with
|
||||
> `isSuspended` today. In this phase keep writing whatever field the admin sends to the region
|
||||
> row; Phase 2 changes the admin field to `is_suspended_in_region` and reserves `is_suspended`
|
||||
> for superadmins.
|
||||
|
||||
### `packages/db_helper_sqlite/src/admin-apis/order.ts`
|
||||
- `~652,667,673`: picking the latest price for order items — scope to the order's region row
|
||||
(these queries already run in an order/region context; add the region filter).
|
||||
|
||||
### `apps/backend/src/trpc/apis/user-apis/apis/order.ts`
|
||||
- `~132` `product.marketStats?.isSuspended` — `getOrderProductById` will return a single,
|
||||
region-picked stats object after Phase 1; keep reading `isSuspended` and add
|
||||
`isSuspendedInRegion` to the unavailability check.
|
||||
|
||||
## 7. Cache behaviour
|
||||
|
||||
- `scaffoldProducts(regionId)` / `scaffoldAvailability(regionId)` already take a region, so
|
||||
once the helpers are region-scoped the per-region caches are correct.
|
||||
- **Admin market-data writes must regenerate that region only**: `updateProductPrices` and
|
||||
`toggleOutOfStock` already call `createAvailabilityCacheFile(regionId)`; keep that. Full
|
||||
`updateProduct` calls `scheduleStoreInitialization(regionId)`. Unchanged.
|
||||
|
||||
## 8. Verification
|
||||
|
||||
1. `bunx tsc --noEmit` on `apps/backend`, `apps/admin-ui`, `apps/user-ui`, `apps/web-ui`
|
||||
(web-ui has ~12 pre-existing unrelated errors — compare counts).
|
||||
2. Apply nothing to the dev DB. Validate the **edited `0006`** on a **fresh** DB copy (reset
|
||||
local D1 and apply from `0000`): `region_id` + `is_suspended_in_region` present, new unique
|
||||
index, one row per (SKU, region), orphans pruned.
|
||||
3. Runtime probe (after the user applies the edited `0006`): for a region-1 and a region-2 SKU,
|
||||
GET `products.json` + `availability.json` and confirm prices/stock match the pre-change values.
|
||||
|
||||
## 9. Risks
|
||||
|
||||
- **Relation churn:** 23 `marketStats: true` sites / 33 `.marketStats` reads. Miss one and it
|
||||
either silently uses the wrong region's row or reads an array as an object.
|
||||
- **Order pricing** (`user-apis/order.ts`, `admin-apis/order.ts`) must keep resolving the right
|
||||
region row — a wrong region row = wrong charged price.
|
||||
- **Suspension semantics** temporarily live in two places; keep both flags in every filter.
|
||||
|
||||
## 10. Out of scope (Phase 2+)
|
||||
|
||||
Global products/stores, `is_global`, superadmin seeding, admin UI changes, the
|
||||
`is_suspended` vs `is_suspended_in_region` split enforcement.
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
# Phase 2 — Global stores & products (backend)
|
||||
|
||||
Status: **not started.**
|
||||
Depends on: **Phase 1 verified.**
|
||||
Blocks: Phases 3–4.
|
||||
|
||||
## 1. Goal
|
||||
|
||||
Introduce stores and products that are shared across **all** regions, created and owned by
|
||||
**superadmins**, visible to **every** regional admin, with per-region market data on top of
|
||||
Phase 1's `product_market_stats(region_id)`.
|
||||
|
||||
## 2. Model
|
||||
|
||||
- **Global store:** `store_info.is_global = 1`, `store_info.region_id = NULL`,
|
||||
`store_info.owner = NULL` (a superadmin has no `staff_users` row).
|
||||
- **Global product:** `product_info.region_id = NULL`, `product_info.store_id` → a global
|
||||
store. *A product is global iff its store is global.*
|
||||
- **Market data:** a global SKU has one `product_market_stats` row **per region** (created in
|
||||
Phase 1's schema). Regional SKUs keep exactly one row (their region).
|
||||
- **Suspension:** `product_skus.is_suspended = global` (superadmin only) — kills the SKU in
|
||||
every region. `product_market_stats.is_suspended_in_region = per region` (that region's
|
||||
admin) — kills it only there.
|
||||
|
||||
## 3. Schema changes go into `0006` (no new migration)
|
||||
|
||||
`0006_regions_and_superadmins.sql` is **not applied yet** and already rebuilds `store_info` and
|
||||
`product_info` through `__new_*` tables (with `owner`/`region_id` `NOT NULL`). Fold the global
|
||||
changes into those rebuilds instead of a standalone `0011` recreate — `0006` already rebuilds
|
||||
the entire connected FK subgraph in dependency order, so **no FK-deferral juggling is needed**.
|
||||
|
||||
### Edits to `0006_regions_and_superadmins.sql`
|
||||
|
||||
1. **`CREATE TABLE __new_store_info`**:
|
||||
- `owner` → drop `NOT NULL` (global stores have no staff owner).
|
||||
- `region_id` → drop `NOT NULL` (global stores are region-less).
|
||||
- add `is_global integer DEFAULT false NOT NULL`:
|
||||
```sql
|
||||
`owner` integer,
|
||||
`region_id` integer,
|
||||
`is_global` integer DEFAULT false NOT NULL,
|
||||
```
|
||||
2. **Its copy `INSERT INTO __new_store_info (…) SELECT …`**: append `is_global` with value
|
||||
`false`.
|
||||
3. **`CREATE TABLE __new_product_info`**: `region_id` → drop `NOT NULL` (global products are
|
||||
region-less). The copy `SELECT` is unchanged — pre-existing rows still get the Mahabubnagar
|
||||
region id via the existing `(SELECT id FROM regions WHERE name = 'Mahabubnagar')` subquery.
|
||||
4. Indexes (`idx_store_info_region`, `idx_product_info_region`) are unchanged — a NULL region is
|
||||
simply not matched by the region index.
|
||||
|
||||
End state: `store_info(owner NULL, region_id NULL, is_global)`, `product_info(region_id NULL)` —
|
||||
exactly what `schema.ts` declares.
|
||||
|
||||
### Seeding global products per region
|
||||
|
||||
On **global product create** (superadmin), for every SKU insert one `product_market_stats` row
|
||||
per region using the superadmin's entered values.
|
||||
|
||||
**Seeding a new region (decided).** When a **new region** is created, seed it by **replicating
|
||||
the least-id region's global data**:
|
||||
1. `srcRegion = MIN(regions.id)` (the newly created region has the greatest id, so it is never
|
||||
the source).
|
||||
2. For every **global** SKU, copy the source region's `product_market_stats` row
|
||||
(`region_id = srcRegion`) into a new row with `region_id = <newRegion>`.
|
||||
|
||||
Implement inside `createRegionWithBounds`
|
||||
(`packages/db_helper_sqlite/src/superadmin-apis/regions.ts`), alongside the region + bounds
|
||||
inserts, and honour the D1 compensating-cleanup pattern from FC-19 (a failure must not leave a
|
||||
half-seeded region). Global **stores** need no replication — they are region-less
|
||||
(`region_id NULL`) and already visible in every region.
|
||||
|
||||
## 4. Data helpers
|
||||
|
||||
New `packages/db_helper_sqlite/src/superadmin-apis/global-stores.ts` and `global-products.ts`:
|
||||
- `listGlobalStores()`, `getGlobalStore(id)`, `createGlobalStore(input)`,
|
||||
`updateGlobalStore(id, input)`, `deleteGlobalStore(id)`.
|
||||
- `listGlobalProducts()`, `getGlobalProduct(id)`, `createGlobalProduct(input)`,
|
||||
`updateGlobalProduct(id, input)`, `deleteGlobalProduct(id)`.
|
||||
- `seedGlobalProductMarketStats(skuIds | productId, regions, initialValues)`.
|
||||
- `seedRegionMarketStatsForGlobalSkus(regionId)`, called from `createRegionWithBounds`.
|
||||
- `isGlobalStore(storeId)` helper.
|
||||
|
||||
Export them from `packages/db_helper_sqlite/index.ts` and add to the **explicit** export list
|
||||
in `apps/backend/src/sqliteImporter.ts` (`dbService.ts` re-exports it).
|
||||
|
||||
## 5. tRPC routers
|
||||
|
||||
New `apps/backend/src/trpc/apis/superadmin-apis/apis/global-stores.ts` and `global-products.ts`;
|
||||
register in `superadmin-trpc-index.ts`:
|
||||
|
||||
```ts
|
||||
export const superadminRouter = router({
|
||||
auth, regions, staff, const,
|
||||
globalStores: superadminGlobalStoresRouter,
|
||||
globalProducts: superadminGlobalProductsRouter,
|
||||
})
|
||||
```
|
||||
|
||||
- `globalStores.list/get/create/update/delete` (all `superadminProcedure`).
|
||||
- `globalProducts.list/get/create/update/delete` (all `superadminProcedure`).
|
||||
- Global structural writes → regenerate **all** regions' caches
|
||||
`await scheduleStoreInitialization()` (no region = every region).
|
||||
|
||||
## 6. Visibility & guards (make global valid in every region)
|
||||
|
||||
### Reads
|
||||
- `admin-apis/product.ts`
|
||||
- `getAllProducts(regionId)`: include `product.region_id = regionId OR <store is global>`.
|
||||
- `getProductById(regionId, id)`: allow global.
|
||||
- `getAllSkusSummary(regionId)` (`user-apis/product.ts`): include global SKUs (admin pickers).
|
||||
- `admin-apis/store.ts`
|
||||
- `getAllStores(regionId)`: `region_id = regionId OR is_global = 1`.
|
||||
- `getStoreById(regionId, id)`: allow global.
|
||||
- `stores/store-helpers.ts`
|
||||
- `getAllProductsForCache(regionId)`: include global SKUs; use the region's market-stats row.
|
||||
- `getAvailabilityForCache(regionId)`: include global SKUs' region rows.
|
||||
- `getAllStoresForCache(regionId)`: include global stores.
|
||||
- `user-apis/stores.ts` `getStoreSummaries`/`getStoreDetail`: include global stores.
|
||||
|
||||
### Guards — accept global, still reject other regions
|
||||
- `assertStoreInRegion`, `assertStoreIdsInRegion`,
|
||||
`assertSkuIdsInRegion`/`resolveSkuRegions` (`admin-apis/product.ts`).
|
||||
- `resolveInRegionProductIds` (`admin-apis/store.ts`).
|
||||
- Slot/banner/tag/group/coupon resolvers that validate SKU/store regions
|
||||
(`admin-apis/{slots,banner}.ts`, `replaceTagProducts`, coupon create/update).
|
||||
**Assumption:** a global SKU/store is valid in every region.
|
||||
- `deleteStore`: a global store may only be deleted by a superadmin and only when no products
|
||||
reference it.
|
||||
|
||||
## 7. Write scoping
|
||||
|
||||
- **Admin editing a global product:** accept **only** market-stats fields
|
||||
(`price`, `marketPrice`, `flashPrice`, `isFlashAvailable`, `isOutOfStock`,
|
||||
`isSuspendedInRegion`, `isOffer`) and apply them to the caller region's row. Reject/ignore
|
||||
structural fields (name, descriptions, images, incrementStep, SKUs/features, combos, store,
|
||||
productType). Implement in `updateProduct` (branch on `product.region_id == null` /
|
||||
global store).
|
||||
- **Admin editing a regional product:** unchanged (full edit).
|
||||
- **Admin cannot** create/update/delete global stores, nor create/delete global products.
|
||||
- `updateProductPrices` / `toggleProductOutOfStock`: already region-scoped (Phase 1) — they
|
||||
work for global SKUs too.
|
||||
- **Suspension split:** admin product update writes `is_suspended_in_region`; `is_suspended`
|
||||
is writable only via the superadmin global-product path.
|
||||
- `checkProductExistsByName`: decide scoping — recommend **global names globally unique**,
|
||||
regional names unique within their region.
|
||||
|
||||
## 8. Region resolution for global SKUs (user-facing)
|
||||
|
||||
Once a SKU can be global, functions that resolved a region from the product row must receive
|
||||
one explicitly:
|
||||
- `getOrderProductById(skuId)` (`user-apis/order.ts`) → add `regionId`; `placeOrderUtil`
|
||||
(`apps/backend/src/trpc/apis/user-apis/apis/order.ts`) passes the order region. Verify the
|
||||
`isSuspended || isSuspendedInRegion` check (~132) uses the region row.
|
||||
- `getProductDetails` / `getProductDetailById` (`apps/backend/src/trpc/apis/user-apis/apis/product.ts`
|
||||
+ `user-apis/product.ts`): add an optional `regionId`; the app already knows its region
|
||||
(`useRegion`). Regional products fall back to the product's own region.
|
||||
- `admin-apis/order.ts` price lookups: scope to the order's region row.
|
||||
|
||||
## 9. Cache regeneration
|
||||
|
||||
| Change | Regen |
|
||||
|---|---|
|
||||
| Superadmin creates/edits/deletes a global store or global product (structure) | **all regions** — `scheduleStoreInitialization()` |
|
||||
| Admin edits market data for a global product | **that region** — `createAvailabilityCacheFile(regionId)` (+ `scheduleStoreInitialization(regionId)` if needed) |
|
||||
| Regional product/store change | that region (unchanged) |
|
||||
| New region created | seed global SKU rows, then regen that region |
|
||||
|
||||
## 10. Verification
|
||||
|
||||
1. `bunx tsc --noEmit` (backend + apps).
|
||||
2. Edited `0006` validated on a **fresh** DB copy (apply from `0000`): `store_info` accepts
|
||||
NULL region/owner and has `is_global`; `product_info` accepts NULL region; existing rows
|
||||
intact; indexes present.
|
||||
3. Runtime (after the user applies migrations):
|
||||
- Superadmin creates a global store + global product → a market-stats row exists for
|
||||
**every** region.
|
||||
- A region-1 admin sees the global product in `getProducts` and can change its price →
|
||||
**only** region 1's `availability.json`/`price` changes; region 2 unchanged.
|
||||
- A region-1 admin cannot edit the global product's name/SKUs, nor create/edit/delete the
|
||||
global store.
|
||||
- `is_suspended` (superadmin) removes it everywhere; `is_suspended_in_region` removes it in
|
||||
one region only.
|
||||
- Add a global SKU to a region-1 slot → allowed; order for it prices from region 1's row.
|
||||
|
||||
## 11. Risks
|
||||
|
||||
- **Editing the pending `0006`**: since it is unapplied, edits are safe, but the **local dev D1
|
||||
already has its effects** — validation requires a **fresh** DB (reset + re-apply `0000`…).
|
||||
- **Global SKU region resolution** in order/detail paths — wrong region = wrong price.
|
||||
- **Guard relaxation** must not accidentally allow another region's private rows.
|
||||
|
||||
## 12. Out of scope
|
||||
|
||||
Admin UI and superadmin UI (Phases 3–4).
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
# Phase 3 — Admin UI (React-Native `admin-ui` + web `admin-web`)
|
||||
|
||||
Status: **not started.**
|
||||
Depends on: **Phase 2 backend.**
|
||||
|
||||
## 1. Goal
|
||||
|
||||
Let a regional admin:
|
||||
1. see **global + regional** products on the Products page;
|
||||
2. edit a **global** product's **market data only** (price / stock / offer / region
|
||||
suspension) — everything else read-only — via a **separate component**;
|
||||
3. see **global stores read-only** (no edit/delete).
|
||||
|
||||
## 2. Shared types (`packages/shared/types/*`)
|
||||
|
||||
- `Store`: add `isGlobal: boolean`; change `owner` to `number | null`.
|
||||
- `AdminProduct` (and `AdminProductWithRelations`): add `isGlobal: boolean` (derived from the
|
||||
store) so lists/edits can branch without a second call.
|
||||
- No change to `AdminSku` shape (it already carries all market flags).
|
||||
|
||||
> Confirm exact files: `packages/shared/types/admin.ts` (`Store`, `AdminProduct`).
|
||||
|
||||
## 3. Server contract (from Phase 2 — restate so the UI is built to match)
|
||||
|
||||
- `admin.product.getProducts` / `getProductById` return global + regional; each product has
|
||||
`isGlobal`.
|
||||
- `admin.store.getStores` / `getStoreById` return global stores with `isGlobal: true`,
|
||||
`owner: null`.
|
||||
- `admin.product.updateProduct` **for a global product** accepts **only** market fields:
|
||||
`price`, `marketPrice`, `flashPrice`, `isFlashAvailable`, `isOutOfStock`,
|
||||
`isSuspendedInRegion`, `isOffer`. Structural fields are rejected/ignored.
|
||||
- `admin.product.updateProductPrices` / `toggleOutOfStock` remain region-scoped and work on
|
||||
global SKUs.
|
||||
- Admins get 403/error for global store create/update/delete and global product
|
||||
create/delete.
|
||||
|
||||
## 4. `admin-ui` (Expo / React Native)
|
||||
|
||||
### Products list — `app/(drawer)/dashboard/products/index.tsx`
|
||||
- Show global + regional products.
|
||||
- Add a **Global** badge on global rows/cards.
|
||||
- Optionally a filter chip `All / Regional / Global` alongside the existing
|
||||
`all / in-stock / out-of-stock` chips (`FilterType`).
|
||||
- `onEdit(id)` → navigates to `products/edit?id=…` as today; the edit screen branches.
|
||||
|
||||
### Products edit — `app/(drawer)/dashboard/products/edit.tsx`
|
||||
- After `trpc.admin.product.getProductById`, branch on `product.isGlobal`:
|
||||
- **regional** → existing `ProductForm` (+ add/update flows unchanged).
|
||||
- **global** → render the **new `GlobalProductForm`**.
|
||||
- Keep the existing image-upload / mutation plumbing for the regional path.
|
||||
|
||||
### New component — `src/components/GlobalProductForm.tsx`
|
||||
- **Read-only** (rendered as text/locked): name, short/long description, store, increment
|
||||
step, product type, per-SKU name + images + features, combo items.
|
||||
- **Editable**: a per-SKU market block — `price`, `marketPrice`, `flashPrice`,
|
||||
`isFlashAvailable`, `isOutOfStock`, `isOffer`, `isSuspendedInRegion`.
|
||||
- Submit → `admin.product.updateProduct` with **only** the market fields (never structural).
|
||||
- Show a hint banner: "Global product — shared across regions. You can edit price & stock for
|
||||
your region only."
|
||||
|
||||
### Products add — `app/(drawer)/dashboard/products/add.tsx`
|
||||
- Unchanged (admins cannot create global products). Optionally hide/note global store choices
|
||||
in the store picker (a regional product can't be assigned to a global store).
|
||||
|
||||
### Stores list — `app/(drawer)/dashboard/stores/index.tsx`
|
||||
- Show global stores with a **Global** badge.
|
||||
- **Disable edit/delete** for global stores (read-only). Keep them visible.
|
||||
|
||||
### Stores edit — `app/(drawer)/dashboard/stores/edit.tsx`
|
||||
- If the store `isGlobal`: render read-only (no submit) with a "Global store — managed by a
|
||||
superadmin" banner.
|
||||
|
||||
### Store picker (in `ProductForm` / `ProductsSelector`)
|
||||
- Ensure global stores don't appear as selectable owners/stores for regional product creation
|
||||
(or are clearly marked and rejected by the backend).
|
||||
|
||||
## 5. `admin-web` (TanStack Router)
|
||||
|
||||
Mirror §4:
|
||||
- `src/routes/dashboard.products.tsx` — global badge + optional filter.
|
||||
- `src/routes/dashboard.products.edit.tsx` — branch to a new
|
||||
`src/components/GlobalProductForm.tsx` when `product.isGlobal`.
|
||||
- `src/routes/dashboard.products.new.tsx` — unchanged.
|
||||
- `src/routes/dashboard.stores.tsx` — global badge, edit/delete disabled.
|
||||
- `src/routes/dashboard.stores.edit.tsx` — read-only for global.
|
||||
- Reuse the same field rules; share the market-fields type from `@packages/shared` if helpful.
|
||||
|
||||
## 6. Verification
|
||||
|
||||
1. `bunx tsc --noEmit` on both apps (compare any pre-existing web-ui/admin-web error counts).
|
||||
2. Manual/RTL smoke (only if asked — *not* the full suite):
|
||||
- Products page lists a seeded global product with a badge.
|
||||
- Editing it shows read-only structure + editable market fields; saving changes **only**
|
||||
the caller region's price/stock (verify via `availability.json`).
|
||||
- Global store rows show a badge and have no edit/delete action.
|
||||
3. No migrations, no test-suite run (unless the user asks).
|
||||
|
||||
## 7. Risks / notes
|
||||
|
||||
- `admin-ui` and `admin-web` both have a `ProductForm`; keep them behaviourally consistent
|
||||
but don't force a shared component across the RN/web boundary.
|
||||
- The global edit must never send structural fields — the backend rejects them, but avoid
|
||||
surfacing false "saved" states.
|
||||
- `owner: number | null` change ripples to store display components (`StoreItem`, store
|
||||
detail) — handle null ("Global" / "—").
|
||||
|
||||
## 8. Out of scope
|
||||
|
||||
Superadmin creation/editing of global entities (Phase 4).
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
# Phase 4 — Superadmin UI (`apps/superadmin-ui`)
|
||||
|
||||
Status: **not started.**
|
||||
Depends on: **Phase 2 backend** (routers + helpers). Phase 3 independent.
|
||||
|
||||
## 1. Goal
|
||||
|
||||
Give superadmins screens to **create/edit/delete global stores** and **create/edit/delete
|
||||
global products**, including the initial per-region market values that get seeded to every
|
||||
region.
|
||||
|
||||
## 2. App shape (for reference)
|
||||
|
||||
- `apps/superadmin-ui` is a **TanStack Router** web app (Vite + Cloudflare).
|
||||
- Routes are **file-based** in `src/routes/*.tsx`; `src/routeTree.gen.ts` is **generated** (do
|
||||
not hand-edit — it regenerates when Vite runs / builds).
|
||||
- Nav lives in `src/components/AppShell.tsx` (`NAV` array, `lucide-react` icons).
|
||||
- Auth/context: `src/lib/auth-context.tsx`; tRPC client uses `trpc.superadmin.*`.
|
||||
- Existing routes: `dashboard`, `regions`, `staff`, `constants`, `send-notifications`, `login`.
|
||||
|
||||
## 3. Backend surface used (Phase 2)
|
||||
|
||||
```
|
||||
trpc.superadmin.globalStores.list | get | create | update | delete
|
||||
trpc.superadmin.globalProducts.list | get | create | update | delete
|
||||
```
|
||||
|
||||
- Global store `create/update`: `{ name, description?, imageUrl? }` (no owner, no region).
|
||||
- Global product `create`: full structure
|
||||
`{ name, shortDescription?, longDescription?, storeId (global), incrementStep?, productType?,
|
||||
skus: [{ name?, images?, isComboOnly?, features[], comboItems? }] }`
|
||||
**plus** initial market values per SKU
|
||||
`{ price, marketPrice?, flashPrice?, isFlashAvailable?, isOutOfStock?, isOffer? }`
|
||||
which the backend seeds to **every region**.
|
||||
- Global product `update`: structural edit (name/SKUs/etc.) — regenerates all regions.
|
||||
(Per-region market data is edited by regional admins in Phase 3; optionally expose a
|
||||
per-region matrix here too — see §7.)
|
||||
|
||||
## 4. New routes / components
|
||||
|
||||
- `src/routes/global-stores.tsx` — list + create/edit (inline drawer or a `$id` sub-route
|
||||
following the `regions.tsx` pattern) + delete. Reuse the image-upload flow used elsewhere
|
||||
(check how `regions.tsx`/banners handle uploads; if none, add a presigned-URL uploader like
|
||||
`admin-ui`'s `useUploadToObjectStorage`).
|
||||
- `src/routes/global-products.tsx` — list + create/edit + delete.
|
||||
- New components under `src/components/`:
|
||||
- `GlobalStoreForm.tsx`
|
||||
- `GlobalProductForm.tsx` (structure editor + initial market-values block per SKU).
|
||||
- `src/components/AppShell.tsx` — add NAV entries:
|
||||
```ts
|
||||
{ to: '/global-stores', label: 'Global Stores', icon: Store /* or Storefront */ },
|
||||
{ to: '/global-products', label: 'Global Products', icon: Package /* or Boxes */ },
|
||||
```
|
||||
(`lucide-react` icons).
|
||||
|
||||
> After adding files under `src/routes/`, run the dev server / build once so `routeTree.gen.ts`
|
||||
> regenerates before typecheck.
|
||||
|
||||
## 5. Behaviour
|
||||
|
||||
- Global store create/edit → backend regens **all** regions' caches.
|
||||
- Global product create → seeds market-stats rows for **every** region from the entered values.
|
||||
- Global product structural delete → removes the product, its SKUs and all regions' market
|
||||
rows; regen all regions.
|
||||
- Global product edit → structural changes regen all regions; if a per-region editor is added
|
||||
(§7) it must call the same backend scoping as admins.
|
||||
|
||||
## 6. Verification
|
||||
|
||||
1. `bunx tsc --noEmit` in `apps/superadmin-ui` (confirm `routeTree.gen.ts` is regenerated).
|
||||
2. Manual (dev server): create a global store → appears in every region's admin store list
|
||||
(Phase 3); create a global product with an initial price → a market-stats row exists for
|
||||
each region and `availability.json` shows that price until a region overrides it.
|
||||
|
||||
## 7. Optional / follow-ups
|
||||
|
||||
- A superadmin **per-region market matrix** (rows = regions, columns = price/stock) on the
|
||||
global product screen, backed by a superadmin-scoped market-stats update.
|
||||
- Batch "seed/repair" action for regions missing rows for older global SKUs.
|
||||
- Note: new regions seed from the **least-id region's** rows (see Phase 2). To change the
|
||||
defaults future regions inherit, edit the least-id region's rows first.
|
||||
|
||||
## 8. Out of scope
|
||||
|
||||
Regional admin editing (Phase 3) and any schema/backend work (Phase 2).
|
||||
Loading…
Add table
Reference in a new issue