510 lines
26 KiB
Markdown
510 lines
26 KiB
Markdown
# user-ui — test case info
|
||
|
||
Every test case for the user-ui app, grouped by file with the API expectation
|
||
each one locks in. Companion to `tests/home-page/README.md` (long-form home-page
|
||
detail).
|
||
|
||
- **Runner**: `jest-expo` + `@testing-library/react-native`
|
||
- **Total**: **51 suites / 243 tests**
|
||
- Network is mocked at the layer (`tests/mocks/api.ts`); components, stores, hooks and the router stay real.
|
||
|
||
## Run
|
||
|
||
From `apps/user-ui`:
|
||
|
||
```bash
|
||
NODE_ENV=test bun run test # everything
|
||
NODE_ENV=test bun run test tests/screens # one folder
|
||
NODE_ENV=test bun run test:watch # watch
|
||
bun run test:typecheck # tsc over app + tests
|
||
```
|
||
|
||
`NODE_ENV=test` is required (production React rejects `act`).
|
||
|
||
## Conventions
|
||
|
||
- **API expectation**: any button that triggers a network call has a case asserting it —
|
||
`expectProcedureCalled(fetchMock, '<proc>')`, `lastProcedureInput` for the payload, or the
|
||
axios mock's call history for CDN files.
|
||
- **Router**: `tests/mocks/router.ts` spies; real-router flows use `tests/helpers/real-router.tsx`
|
||
in files that do **not** mock expo-router.
|
||
- **State**: zustand stores are module singletons — reset them in `beforeEach`.
|
||
|
||
---
|
||
|
||
# home-page (`tests/home-page/`) — 48
|
||
|
||
### `home.test.tsx` — 18
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | requests the products cache url derived from common.essentialConsts | `common.essentialConsts` fetched, then the CDN products URL |
|
||
| 2 | shows a tab for every tag | one `tag-tab-*` per tag with its name |
|
||
| 3 | shows every product of every tag, expanding each grid once | 6-item preview then Show More reveals the rest |
|
||
| 4 | renders a tag with its out-of-stock items last | out-of-stock pushed last, admin order kept within groups |
|
||
| 5 | shows the upcoming slots in delivery order | first 5 upcoming slots, delivery then freeze sort |
|
||
| 6 | hides a slot whose freeze time has passed | expired-freeze slot absent from the strip |
|
||
| 7 | hides a slot whose freeze time has passed in the add-to-cart dialog | expired slot not offered, a valid one still is |
|
||
| 8 | shows the load-all button until every product is loaded | `products-show-more` pages 21 at a time |
|
||
| 9 | marks exactly the unavailable products out of stock in every tag | badge present iff unavailable |
|
||
| 10 | lists the main product list with unavailable items last | mounted head matches the expected order |
|
||
| 11 | adds items to the cart | bar counts lines; card swaps to a stepper |
|
||
| 12 | updates and removes a cart item through the card quantity stepper | dialog update mode, quantity change, delete |
|
||
| 13 | shows the store list and navigates when a store is tapped | push `…/stores` + navigationStore flags |
|
||
| 14 | opens the product detail page from a tag grid card | push `…/product-detail/<id>` |
|
||
| 15 | opens the product detail page from the main list | push `…/product-detail/<id>` |
|
||
| 16 | opens the slot detail page when a slot card is tapped | push `…/slot-view?slotId=<id>` |
|
||
| 17 | opens search from the search bar | push `…/search-results` |
|
||
| 18 | opens the cart from the floating bar | push `…/home/cart` |
|
||
|
||
### `navigation.test.tsx` — 3 (real router)
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | routes to the product detail screen carrying the id | pathname + `id` param delivered |
|
||
| 2 | routes to the slot view carrying the slotId | `/home/slot-view` + `slotId` param |
|
||
| 3 | routes to the stores screen | `/stores` stub visible |
|
||
|
||
### `home-states.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the loading screen while the products request is pending | "Loading products..." |
|
||
| 2 | shows the products error state when the products request fails | "Oops!" + "Failed to load products" |
|
||
| 3 | shows the app-settings error state when essentialConsts fails | "Failed to load app settings" |
|
||
| 4 | shows the empty state when there are no products | "No products available" |
|
||
| 5 | shows the empty-category message for a tag with no products | "No products in this category yet" |
|
||
|
||
### `home-refresh.test.tsx` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | refetches every data source through useManualRefresh | products/stores/slots/consts URLs requested again |
|
||
| 2 | refetches every data source through useMarkDataFetchers | same, via the mark-data-fetchers callback |
|
||
|
||
### `home-slots.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | marks only the slots closing within 4 hours | CLOSING SOON iff freeze < 4h (both branches) |
|
||
| 2 | labels each slot with its delivery range and order-by time | delivery range, order-by clock, date line |
|
||
| 3 | shows how many products each slot holds | "View all N items" |
|
||
|
||
### `home-add-to-cart-dialog.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | offers flash delivery and routes to the flash cart when enabled | flash row shown; confirm pushes the flash cart |
|
||
| 2 | keeps confirm disabled until a delivery option is chosen | disabled CTA |
|
||
| 3 | pre-selects the cart quantity when reopened from the card stepper | Update Item + current quantity |
|
||
|
||
### `home-floating-cart-bar.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | adds exactly the pinned products and tracks the total and delivery threshold | ₹215 → "₹34 more"; +₹129 → ₹344 • 2 Items → Unlocked |
|
||
| 2 | places each pinned product in the first open slot it belongs to | one slot label per line |
|
||
| 3 | recomputes the total when the quantity changes | ₹215 → ₹430, still one line |
|
||
| 4 | expands into the cart dialog with the line and the subtotal | "Your Cart" + Subtotal |
|
||
| 5 | re-slots a stored cart item whose slot no longer exists | `useReconcileCartSlots` rewrites the slotId |
|
||
|
||
### `next-order-glimpse.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders nothing and never requests orders when signed out | no preview; `user.order.getOrders` not called |
|
||
| 2 | previews an upcoming order | id, "N items • ₹total", status label |
|
||
| 3 | flags a flash order | FLASH + "30-Min Delivery" |
|
||
| 4 | ignores cancelled and completed orders | no preview |
|
||
| 5 | routes to my-orders when a card is tapped | `router.replace('…/me')` |
|
||
|
||
### `home-cards.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | never renders a combo-only SKU | id 149 absent everywhere |
|
||
| 2 | renders every store with the leading "The " stripped | all stores + name normalisation |
|
||
| 3 | strikes through the market price when it is above the selling price | market price shown |
|
||
| 4 | shows a fallback when a product image fails to load | "Image failed to load" |
|
||
|
||
---
|
||
|
||
# screens (`tests/screens/`) — 87
|
||
|
||
### `auth.test.tsx` — 9
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the mobile step with the submit button | mobile input + CTA |
|
||
| 2 | rejects an invalid mobile number without calling the API | validation error, no `user.auth.sendOtp` |
|
||
| 3 | sends an OTP and moves to the OTP step | `user.auth.sendOtp` called → OTP step |
|
||
| 4 | verifies the OTP and hands the token to the auth context | `user.auth.verifyOtp` → `loginWithToken('tok', user)` |
|
||
| 5 | logs in with identifier + password via the password path | `user.auth.login` → `loginWithToken` |
|
||
| 6 | opens the terms dialog from the terms link | dialog visible |
|
||
| 7 | renders the registration form and links to sign in | `router.push('/(auth)/login')` |
|
||
| 8 | shows a spinner while the session is loading | auth layout spinner |
|
||
| 9 | renders the stack once loading finishes | no spinner |
|
||
|
||
### `navigation-shell.test.tsx` — 2 (real router)
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | redirects to the home route once auth has settled | pathname `/home` |
|
||
| 2 | stays on the entry route and shows a spinner while auth loads | spinner, pathname `/` |
|
||
|
||
### `flash-gate.test.tsx` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the unavailable screen and routes home when disabled | unavailable copy + `router.replace('…/home')` |
|
||
| 2 | renders the slot content when enabled | `common.essentialConsts` fetched, no gate |
|
||
|
||
### `stores.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | lists every store with its product count | all names + one Explore Store each |
|
||
| 2 | navigates to a store detail when Explore Store is pressed | push `…/store-detail/<id>` |
|
||
| 3 | deep-links to the store chosen on the home page and clears the flag | focus effect push + flags cleared |
|
||
| 4 | shows the error state and refetches on Retry | "Store Fetch Failed" → `stores.json` re-requested |
|
||
| 5 | shows the empty state when there are no stores | "No Stores Available" |
|
||
|
||
### `store-detail.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the store, its tags and products | store meta + "Chicken (3)" + cards |
|
||
| 2 | filters by tag and clears the filter | "Chicken items" → Clear → "N products" |
|
||
| 3 | navigates to a product detail when a card is pressed | push `…/product-detail/<id>` |
|
||
| 4 | shows the error state when the store cannot be loaded | store-not-found copy |
|
||
|
||
### `search.test.tsx` — 6
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | lists all products when the query is empty | "All Products" + cards |
|
||
| 2 | filters products by the debounced query | 300ms debounce → filtered header + fewer cards |
|
||
| 3 | shows the no-results state for an unmatched query | "No products found" + hint |
|
||
| 4 | restores all products when the query is cleared | header back to "All Products" |
|
||
| 5 | shows the loading state while products are pending | "Loading products..." |
|
||
| 6 | opens the product detail page when a card is pressed | push `…/product-detail/<id>` |
|
||
|
||
### `order-again.test.tsx` — 6
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders both section headers | Offers + Combos |
|
||
| 2 | shows the empty message for a section with no products | "No offers available right now" |
|
||
| 3 | renders a card for every combo | ≥1 card |
|
||
| 4 | opens the product detail page when a card is pressed | push `…/order-again/product-detail/<id>` |
|
||
| 5 | shows the loading state while products are pending | "Loading offers..." |
|
||
| 6 | shows the error state when products fail to load | "Oops!" + "Failed to load offers" |
|
||
|
||
### `slot-view.test.tsx` — 8
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the loading state while slots load | "Loading slot delivery..." |
|
||
| 2 | shows the error state when slots fail | "Failed to load slot delivery" |
|
||
| 3 | shows the no-slot state for an unknown slot id | "No delivery slot available." |
|
||
| 4 | lists the slot products and navigates on press | cards + push product-detail |
|
||
| 5 | shows the empty message when a store has no products in the slot | store-filter copy |
|
||
| 6 | lists flash-available in-stock products | flash filter |
|
||
| 7 | filters products by the search box | no-results copy |
|
||
| 8 | shows the empty message when there are no products | "No 1 Hr Delivery products available." |
|
||
|
||
### `cart-screen.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the empty state and Start Shopping navigates home | push `…/home` |
|
||
| 2 | renders the seeded line, the bill and queries the cart slots | bill ₹230 + `user.cart.getCartSlots` input `{productIds:[2]}` |
|
||
| 3 | queries eligible coupons only when authenticated | `user.coupon.getEligible` + Offers & Coupons |
|
||
| 4 | navigates to checkout with the selected slot | push `…/home/checkout` |
|
||
| 5 | renders the flash cart variant without slot selection | "1 Hr Delivery Cart" |
|
||
|
||
### `checkout.test.tsx` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the empty-cart state and goes back | "Your cart is empty" + `router.back` |
|
||
| 2 | redirects to login when unauthenticated | `router.push('/(auth)/login')` |
|
||
|
||
### `product-detail-routes.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | home route renders ProductDetail with the id | `7:regular` |
|
||
| 2 | stores route renders ProductDetail | id passed |
|
||
| 3 | order-again route renders ProductDetail | id passed |
|
||
| 4 | flash route renders ProductDetail | id passed |
|
||
|
||
### `order-success.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the confirmation and performs both actions | `dismissTo` + `dismissAll` + push my-orders |
|
||
| 2 | shows the order id and total when params are present | "Order #ORD-9" + "Total: ₹500" |
|
||
| 3 | renders the confirmation actions | flash variant CTAs |
|
||
|
||
### `me-hub.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the account sections and menu entries | My Account + entries |
|
||
| 2 | navigates to the orders screen | push `…/me/my-orders` |
|
||
| 3 | navigates to addresses | push `…/me/addresses` |
|
||
| 4 | logs out from the footer button | `logout` called |
|
||
|
||
### `me-orders.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the fetched orders | `user.order.getOrders` + row |
|
||
| 2 | navigates to the order detail when a row is pressed | push `…/my-orders/11` |
|
||
| 3 | shows the empty state and Start Shopping navigates home | push `…/home` |
|
||
| 4 | shows the error state and retries | error copy + `getOrders` re-requested |
|
||
| 5 | retries payment through user.payment.createRazorpayOrder | procedure called |
|
||
|
||
### `order-detail.test.tsx` — 6
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the order, its items and the total | `user.order.getOrderById` + total |
|
||
| 2 | shows the error state and goes back | `router.back` |
|
||
| 3 | saves special instructions via user.order.updateUserNotes | `{id, userNotes}` |
|
||
| 4 | requires a reason before cancelling | alert, no `cancelOrder` |
|
||
| 5 | cancels the order with a reason via user.order.cancelOrder | `{id, reason}` |
|
||
| 6 | opens the complaint form | complaint textarea visible |
|
||
|
||
### `me-account.test.tsx` — 16
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | lists the addresses and singles out the default | cards + Set Default |
|
||
| 2 | shows the empty state with an Add Address action | empty copy |
|
||
| 3 | shows the error state and retries | `user.address.getUserAddresses` re-requested |
|
||
| 4 | marks an address as default via user.address.updateAddress | `{id, isDefault: true}` |
|
||
| 5 | deletes an address after confirming via user.address.deleteAddress | `{id}` |
|
||
| 6 | renders personal and general sections | SAVE20 + both sections |
|
||
| 7 | redeems a code via user.coupon.redeemReservedCoupon | `{secretCode: 'SECRET1'}` |
|
||
| 8 | shows the empty sections when there are no coupons | both empty copies |
|
||
| 9 | renders complaints and support contacts | item + Pending + Need Help? |
|
||
| 10 | opens the dialer from Call Us | `Linking.openURL('tel:…')` |
|
||
| 11 | shows the empty state and Continue Shopping navigates home | push `…/home` |
|
||
| 12 | shows the error state | "Failed to load complaints" |
|
||
| 13 | renders the profile form and logs out | `logout` called |
|
||
| 14 | requires a mobile number before deleting the account | alert, no `deleteAccount` |
|
||
| 15 | deletes the account via user.auth.deleteAccount | `{mobile}` |
|
||
| 16 | renders the policy and goes back | terms content |
|
||
|
||
---
|
||
|
||
# components (`tests/components/`) — 59
|
||
|
||
### `product-card.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the name, price, struck market price and unit | all four |
|
||
| 2 | shows the out-of-stock overlay when unavailable | badge |
|
||
| 3 | queues the product when the add icon is pressed (dialog mode) | `cartStore.addedToCartProduct` |
|
||
| 4 | shows the image-error fallback | "Image failed to load" |
|
||
| 5 | calls onPress when the card is tapped | callback |
|
||
|
||
### `product-detail.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | shows the loading state | "Loading product details..." |
|
||
| 2 | renders the product and loads its reviews | `getProductDetails{id}` + `getProductReviews` + flash badge |
|
||
| 3 | shows the error state when the product fails to load | "Product not found or error loading" |
|
||
| 4 | queues the add-to-cart dialog from the Add to Cart button | `cartStore.addedToCartProduct` |
|
||
|
||
### `payment-and-order.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the bill and an enabled Place Order button | Bill Details + ₹230 + enabled |
|
||
| 2 | blocks ordering without an address | error banner + disabled CTA |
|
||
| 3 | places a COD order and redirects to order success, clearing the cart | `placeOrder` payload, `replace('…order-success…')`, cart cleared |
|
||
| 4 | shows an error when placing the order fails | alert |
|
||
|
||
### `order-menu.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | navigates to the order details | push `…/my-orders/42` |
|
||
| 2 | saves edited instructions via user.order.updateUserNotes | `{id, userNotes}` |
|
||
| 3 | requires a reason before cancelling | alert, no `cancelOrder` |
|
||
| 4 | cancels the order with a reason via user.order.cancelOrder | `{id, reason}` |
|
||
|
||
### `complaint-form.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders nothing when closed | null tree |
|
||
| 2 | rejects an empty complaint without calling the API | alert, no `complaint.raise` |
|
||
| 3 | raises a complaint with the typed body and closes | `{orderId, complaintBody, imageUrls: []}` + close |
|
||
|
||
### `registration-form.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the registration fields | Create Account + name field |
|
||
| 2 | blocks submit with a validation error | "Name is required" |
|
||
| 3 | rejects mismatched passwords | "Passwords do not match" |
|
||
| 4 | submits the normalised register payload | trimmed/lowercased payload |
|
||
| 5 | updates the password in edit mode via user.auth.updatePassword | `{password}` |
|
||
|
||
### `address-form.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the add-address form | title + name field + service notice |
|
||
| 2 | validates the required fields | name/phone/line1 errors |
|
||
| 3 | creates an address via user.address.createAddress | payload |
|
||
| 4 | updates an address in edit mode via user.address.updateAddress | `{id, name}` |
|
||
|
||
### `address-selectors.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | lists the addresses and auto-selects the default | both cards + `onAddressSelect(2)` |
|
||
| 2 | selects an address on press | `onAddressSelect(1)` |
|
||
| 3 | shows the empty state | empty copy + Add Address |
|
||
| 4 | shows the earliest slot and changes it from the dialog | slot options → `onSlotChange` |
|
||
| 5 | shows the flash header variant | "Delivery in within 1 hour" |
|
||
|
||
### `location-attacher.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | attaches the current location on success | `onLocationChange(coords)` + attached badge |
|
||
| 2 | shows an error when permission is denied | error copy, no callback |
|
||
| 3 | does nothing while disabled | no permission request |
|
||
|
||
### `location-wrapper.test.tsx` — 1
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders its children on an emulator | passthrough |
|
||
|
||
### `slot-layout.test.tsx` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the delivery-time selector and the cart bar | Delivery Time + No Items In Cart |
|
||
| 2 | renders the flash variant header | flash header copy |
|
||
|
||
### `wrappers.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders children when the backend is healthy | `common.healthCheck` ok |
|
||
| 2 | shows the service-unavailable state and retries | error copy + `healthCheck` re-requested |
|
||
| 3 | prompts to update when the backend version is ahead | "Update Available" |
|
||
| 4 | renders children and does not check for updates on dev builds | UpdateChecker inert |
|
||
|
||
### `static-components.test.tsx` — 10
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | renders the full policy with the title by default | title + sections |
|
||
| 2 | hides the title when showTitle is false | no title |
|
||
| 3 | renders the notice and dismisses via the close button | notice visible |
|
||
| 4 | auto-hides after the delay | timer removes it |
|
||
| 5 | renders the testing-phase bullets | bullets |
|
||
| 6 | renders its children | TabLayoutWrapper |
|
||
| 7 | shows the welcome screen once, then the children after Next | first-run gate |
|
||
| 8 | renders children when there is no webview html | children |
|
||
| 9 | renders the webview when the server provides html | mock webview |
|
||
| 10 | shows the exit confirmation on the home screen and swallows the event | alert + returns true |
|
||
|
||
### `icons.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1–5 | %s renders focused and unfocused (Home, Cart, Stores, Offers, Me) | each icon renders in both states |
|
||
|
||
---
|
||
|
||
# hooks / stores / lib / contexts — 49
|
||
|
||
### `hooks/cart-query-hooks.test.tsx` — 6
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | adds an item to the regular cart | `cart_items` line written |
|
||
| 2 | keeps the flash cart separate from the regular cart | flash key only |
|
||
| 3 | increments the quantity of an item already in the cart | qty 1 → 3 |
|
||
| 4 | updates and removes a cart line | qty → 4, then removed |
|
||
| 5 | derives cart items and the total from the central stores | subtotal/total/totalItems |
|
||
| 6 | clears the local cart | `clearLocalCart` empties |
|
||
|
||
### `hooks/prominent-api-hooks.test.tsx` — 6
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | exposes essentialConsts from the trpc procedure | threshold 249 |
|
||
| 2 | derives the products cache url and merges availability | products + availability URLs, price/marketPrice |
|
||
| 3 | derives the stores cache url | stores URL |
|
||
| 4 | derives the slots cache url | slots URL |
|
||
| 5 | fetches a single store detail | `stores/1.json` + store.id |
|
||
| 6 | propagates a products fetch error | error surfaced |
|
||
|
||
### `hooks/useUploadToObjectStore.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | requests presigned urls and PUTs every image | `common.generateUploadUrls` + 2 PUTs + keys |
|
||
| 2 | short-circuits when there are no images | empty result, no request |
|
||
| 3 | fails when the URL count does not match the image count | throws |
|
||
|
||
### `hooks/useAuthenticatedRoute.test.tsx` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | redirects an unauthenticated user to login | `router.push('/(auth)/login')` |
|
||
| 2 | does not redirect an authenticated user | no push |
|
||
| 3 | does not redirect while auth is still loading | no push |
|
||
|
||
### `hooks/useProductSlotIdentifier.test.tsx` — 5
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | returns the id of the earliest upcoming slot for a product | slot 11 |
|
||
| 2 | ignores slots whose delivery is already past | slot 2 |
|
||
| 3 | returns null when the product has no slots | null |
|
||
| 4 | returns null when there are no slots at all | null |
|
||
| 5 | returns null when every slot for the product is in the past | null |
|
||
|
||
### `hooks/useJWT.test.ts` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | stores, reads and deletes the auth token | token round-trip |
|
||
| 2 | stores and reads the user id | userId round-trip |
|
||
| 3 | exposes the storage keys | `authToken` / `userId` |
|
||
|
||
### `hooks/useHideTabNav.test.tsx` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | marks the tab bar hidden for the caller key on focus | `hideTabsNav.cart` |
|
||
| 2 | defaults the caller key when none is given | `hideTabsNav.default` |
|
||
|
||
### `hooks/useColorScheme.test.tsx` — 1
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | returns the platform colour scheme | null/light/dark |
|
||
|
||
### `stores/stores.test.ts` — 11
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | appStore tracks tab-bar visibility per caller | set key true/false |
|
||
| 2 | addressStore holds the selected checkout address | 7 |
|
||
| 3 | cartStore queues and clears the add-to-cart product | queue/clear |
|
||
| 4 | flashCartStore queues and clears the flash product | queue/clear |
|
||
| 5 | navigationStore tracks the from-home flag and selected store | flags |
|
||
| 6 | quickDeliveryStore holds the selected slot | 1849 |
|
||
| 7 | storeHeaderStore holds the screen title | title |
|
||
| 8 | slotStore holds the quick-delivery slot and store | ids |
|
||
| 9 | flashNavigationStore flags navigation back to the cart and resets | flag + reset |
|
||
| 10 | centralProductStore indexes products by id | productsById |
|
||
| 11 | centralSlotStore builds productSlotsMap from slots + availability | map + flags |
|
||
|
||
### `lib/string-manipulators.test.ts` — 3
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | maps pending to the user-facing "Confirmed" | mapping |
|
||
| 2 | is case-insensitive | PENDING/Pending |
|
||
| 3 | passes every other status through unchanged | packaged/success/cancelled/'' |
|
||
|
||
### `lib/trpc-client.test.ts` — 2
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | emits the force-logout event on a 401 UNAUTHORIZED response | `FORCE_LOGOUT_EVENT` |
|
||
| 2 | does not emit the force-logout event on a 500 response | no emit |
|
||
|
||
### `contexts/auth-context.test.tsx` — 4
|
||
| # | Test | Asserts |
|
||
| --- | --- | --- |
|
||
| 1 | settles to a signed-out state when there is no stored token | `false|false|none` |
|
||
| 2 | loginWithToken persists the token and authenticates | token stored + `true|false|5` |
|
||
| 3 | logout clears the session and the stored token | signed out + token null |
|
||
| 4 | useAuth throws outside an AuthProvider | throws |
|
||
|
||
---
|
||
|
||
## Not covered
|
||
|
||
Thin/global shells only: `app/_layout.tsx`, `(drawer)/_layout.tsx`, the per-route
|
||
`_layout.tsx` files, and `services/notif-service`.
|
||
|
||
## Harness reference
|
||
|
||
| Path | Purpose |
|
||
| --- | --- |
|
||
| `tests/setup.ts` | Global stubs: axios, native modules (webview/updates/linking/location/notifications/razorpay/secure-store), `@react-navigation/native` focus, auth, storage, refresh hooks; frozen clock |
|
||
| `tests/mocks/api.ts` | axios CDN + tRPC stubs; `setupApiMocks({ procedures, products, stores, storeProducts, consts, orders, fail*, pending* })` |
|
||
| `tests/mocks/procedures.ts` | `expectProcedureCalled` / `procedureCalls` / `lastProcedureInput` (query + body inputs) |
|
||
| `tests/mocks/router.ts` | Mocked expo-router + `routerMock` spies + `searchParamsMock` |
|
||
| `tests/mocks/auth.ts` | Overridable auth mock + spies |
|
||
| `tests/mocks/native.ts` | Native module stubs |
|
||
| `tests/helpers/render.tsx` | `Providers` + `renderWithProviders` |
|
||
| `tests/helpers/real-router.tsx` | `renderRoute` (real expo-router) |
|