| ← All Docs Testing

Testing

Verified Last updated: September 2026

AquaDealers has two test layers: unit tests via Vitest and end-to-end tests via Playwright.

Unit Tests (Vitest)

Configuration

Test Files (11)

FileCoverage AreaDescription
useCheckout.test.ts Checkout flow Tests the full checkout hook: payload building, bill creation, payment allocation, and post-checkout side effects (WhatsApp send, cache invalidation).
cartStore.test.ts Cart state Tests the Zustand cart store: add/remove items, quantity updates, price calculations, discount application, cart clearing.
PaymentStep.test.tsx Payment UI Tests the PaymentStep component rendering: payment mode selection, amount input, split payment handling, validation states.
DuesFarmerRow.test.tsx Dues display Tests the farmer row component in the dues list: amount formatting, ageing bucket display, overdue highlighting.
financialService.test.ts Financial calculations Tests financial service functions: revenue calculation, expense aggregation, profit computation, balance calculations.
inventoryService.test.ts Inventory queries Tests inventory service: stock level queries, lot lookups, low stock detection, valuation calculations.
farmerService.test.ts Farmer operations Tests farmer CRUD: creation, updates, search, balance queries, statement generation.
reportBuilders.test.ts Report generation Tests report builder functions: data aggregation, CSV formatting, date range filtering, summary calculations.
dashboardCardUtils.test.ts Dashboard metrics Tests dashboard utility functions: metric formatting, percentage calculations, trend indicators, card data shaping.
supabase.test.ts Client config Tests Supabase client initialization: URL configuration, key loading, auth persistence settings.
utils.test.ts Utility functions Tests shared utilities: phone normalization, currency formatting, date helpers, string manipulation.

E2E Tests (Playwright)

Configuration

Test Specs (5)

1. billing.spec.ts — Full Bill Creation

End-to-end bill creation flow:

2. farmer-payment.spec.ts — Payment Collection

Payment recording flow:

3. stock-purchase.spec.ts — Stock Purchase

Inventory purchase flow:

4. auth.spec.ts — Authentication Flows

Authentication flow tests:

5. screenshot.spec.ts — Login/Register Screenshots

Utility spec that captures screenshots of the login and register pages for visual reference.

Support Files

Running Tests

Commands

# Unit tests (Vitest)
npm test

# Unit tests in watch mode
npm test -- --watch

# E2E tests (Playwright)
npm run test:e2e

# E2E tests with UI mode
npx playwright test --ui

# E2E tests for a specific spec
npx playwright test billing.spec.ts

E2E Prerequisites

Before running E2E tests: