AquaDealers has two test layers: unit tests via Vitest and end-to-end tests via Playwright.
vitest.config.ts@testing-library/react, jest-domnpm test| File | Coverage Area | Description |
|---|---|---|
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. |
playwright.config.ts.env.e2e filenpm run test:e2eEnd-to-end bill creation flow:
Payment recording flow:
Inventory purchase flow:
Authentication flow tests:
Utility spec that captures screenshots of the login and register pages for visual reference.
tests/e2e/auth.setup.ts — Authentication setup (logs in before tests)tests/e2e/fixtures.ts — Shared test fixturestests/e2e/helpers/db.ts — Database helper for test setup/teardown# 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
.env.e2e file with test dealer credentialsnpm run dev)npx playwright install chromium