Test Inventory
Bilko —Drop Test Inventory
Status: Active — Tests Implemented
Version: 2.0
Last Updated:updated: 2026-03-0202-13
Author:Source: ALAIsrc/drop-app/tests/
DocumentationTotal Team
Thisfiles: inventory14 catalogs(7 allunit, implemented1 testsintegration, in1 Bilko,performance, organized1 byregression, package3 andE2E, file.1 setup)
SummaryDirectory Structure
tests/
setup.ts # Global setup (sets NODE_ENV=test)
unit/
auth.test.ts # Password hashing + JWT tokens
db.test.ts # Database schema validation
feature-flags.test.ts # Feature flag system
middleware.test.ts # Rate limiting + error responses
utils.test.ts # Utility functions (randomId, maskBankAccount)
validation.test.ts # Input validation functions
api-routes.test.ts # API routes with DB integration
integration/
api-endpoints.test.ts # Full API endpoint integration tests
performance/
api-benchmarks.test.ts # Performance benchmarks
regression/
known-bugs.test.ts # Regression tests for fixed bugs
e2e/
user-flows.spec.ts # Basic user journey E2E
full-flows.spec.ts # Complete feature journey E2E
input-chaos.spec.ts # Malicious/edge-case input E2E
Unit Tests (Vitest)
tests/unit/auth.test.ts -- 7 tests
Password Hashing (4 tests):
hashPasswordproduces bcrypt hash (starts with$2)verifyPasswordvalidates correct bcrypt passwordverifyPasswordrejects wrong passwordverifyPassworddoes NOT accept SHA-256 hashes (security fix C4)
JWT Token Management (3 tests):
signTokenandverifyTokenround-trip worksverifyTokenrejects invalid tokensverifyTokenrejects tampered tokens
tests/unit/db.test.ts -- 5 tests
- Creates all 11 expected tables (users, transactions, recipients, merchants, cards, bank_accounts, sessions, notifications, settings, exchange_rates, spending_limits)
- Users table does NOT have
balancecolumn (pass-through model verification) - Cards table does NOT have
card_numberorcvvcolumns (PCI-DSS fix verification). Haslast_fourandtoken_refinstead. - Transaction type constraint only allows
remittanceandqr_payment - Foreign key constraints are enforced
tests/unit/feature-flags.test.ts -- 6 tests
isEnabledreturns default when no env var is setisEnabledreadsNEXT_PUBLIC_FF_*env varsfeatureGatereturns 404-like response when disabledfeatureGatereturns null when enabledgetAllFlagsreturns complete flag set (8 flags)topUpViaCardflag does NOT exist (removed feature)
tests/unit/middleware.test.ts -- 7 tests
Rate Limiting (3 tests):
- Allows requests within limit
- Blocks after limit exceeded
- Resets after window expires
jsonError (2 tests):
- Returns correct JSON format (
{error, message, details}) - Includes details array when provided
getClientIp (2 tests):
- Extracts from
X-Forwarded-Forheader (first IP) - Returns
127.0.0.1when no header present
tests/unit/utils.test.ts -- 5 tests
randomId (3 tests):
- Generates prefixed IDs with correct format (
prefix_<hex16>) - Generates unique IDs on each call
- Uses the provided prefix
maskBankAccount (2 tests):
- Masks correctly, showing only last 4 characters
- Returns short accounts unchanged
tests/unit/validation.test.ts -- 10 tests
Email Validation (2 tests):
- Accepts valid emails (standard, tag, domain variants)
- Rejects invalid emails (empty, no @, space, null)
Phone Validation (2 tests):
- Accepts international format (+47, +381)
- Rejects invalid numbers (no +, too short, letters, null)
Amount Validation (2 tests):
- Accepts valid positive amounts (including 0.01)
- Rejects negative, zero, NaN, and >2 decimal places
IBAN Validation (2 tests):
- Validates correct IBANs (Norwegian, German)
- Rejects invalid IBANs (empty, too short, bad checksum, null)
Name Validation (6 tests, grouped):
- Accepts valid names (Latin, Bosnian chars, apostrophes, hyphens, umlauts)
- Rejects numbers-only input
- Accepts names with numbers mixed in (has letters)
- Rejects empty and null
- Rejects XSS payloads (
<script>,onclick=) - Rejects special-chars-only input
PIN Validation (2 tests):
- Validates 4-digit PINs
- Rejects invalid PINs (too short, too long, letters, null)
tests/unit/api-routes.test.ts -- 8 test groups
- DB + Auth Integration -- User creation with bcrypt, password verification, hash uniqueness
- Exchange Rates Seeded -- 6 NOK rates, queryable for API response
- Rate Limiting -- Allows within limit, blocks after exceeded, resets after window, cleans expired entries
- User Registration Flow -- Insert, unique constraint, default values, KYC/role constraints
- Session Tracking -- Create, retrieve, revocation, expiry, index verification
- End-to-End User Flow -- Register -> login -> session -> revoke
- Foreign Key Constraints -- Cannot create orphan sessions, cannot delete user with sessions
- Utility Functions -- randomId format and uniqueness
Integration Tests (Vitest)
tests/integration/api-endpoints.test.ts -- 20+ tests
Tests actual API route handlers with mocked database and auth.
POST /api/auth/register (5 tests):
- Successfully registers with valid input (201, checks DB)
- Returns 422 for missing email
- Returns 422 for short password
- Returns 422 for missing first name
- Returns 409 for duplicate email
- Returns 400 for invalid JSON body
POST /api/auth/login (5 tests):
- Successfully logs in with valid credentials (200)
- Returns 401 for wrong password
- Returns 401 for non-existent user
- Returns 400 for missing email or password
- Returns 400 for invalid JSON body
GET /api/rates (2 tests):
- Returns all exchange rates (6 currencies)
- Returns empty rates when none seeded
GET /api/rates/[currency] (3 tests):
- Returns rate for valid currency
- Returns 404 for unsupported currency
- Handles case-insensitive codes
POST /api/transactions/remittance (7 tests):
- Successfully creates remittance (201, verifies balance deduction)
- Returns 401 when not authenticated
- Returns 403 when KYC not approved
- Returns 404 when recipient not found
- Returns 402 when insufficient balance
- Returns 400 for amount below/above limits
- Returns 400 for invalid amount (NaN)
POST /api/transactions/qr-payment (8 tests):
- Successfully creates QR payment (201, verifies balance, fee calc)
- Returns 401 when not authenticated
- Returns 404 when merchant not found
- Returns 402 when insufficient balance
- Returns 400 for amount below/above limits
- Returns 400 for missing merchantId
- Returns 400 for invalid JSON body
Performance Tests (Vitest)
tests/performance/api-benchmarks.test.ts -- 8 tests
( |
|||
( |
|||
|
|||
DB |
|||
DB |
|||
Test Category Breakdown
| ||
|
||
|
||
| ||
|
packages/core/tests/ — UnitRegression Tests
Pure unit tests for the @bilko/core financial engine. No database, no HTTP. Uses (globals: trueno explicit imports of describe/it/expect).
accounting.tests/regression/known-bugs.test.ts —-- 204 testsbug groups
TestsBUG-001: double-entry bookkeeping engine: validateDoubleEntry, createJournalEntry, calculateTrialBalance.
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
chart-of-accounts.test.ts — 32 tests
Tests chart of accounts operations: account creation, parent-child hierarchy, account type validation.
invoicing.test.ts — 22 tests
Tests invoice number generation, total calculations, and line item validation.
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
multi-currency.test.ts — 24 tests
Tests currency conversion, exchange rate locking, and NUMERIC precision handling.
tax.test.ts — 23 tests
Tests VAT calculations for all supported countries and edge cases.
apps/api/tests/ — Mock API Tests
Integration tests for Express API endpoints. Tests use mocked Prisma clienttests): — no real database required. Setup in tests/setup.ts.
setup.ts — Test Infrastructure (not a test file)
Provides:
PrismaRateclientlimitmockactuallyviablocksafter exceededvi.mock('../src/lib/prisma')EnvironmentCountvariableincrementssetupcorrectly(JWTinsecrets, rate limits)databaseResetscreateTestUser()—afterfactorywindow expires
BUG-002: Validation errors generic message (3 tests):
- Register returns details array for
testvalidationuser objectserrors DetailsgenerateTestAccessToken()—contain specific field errors- Multiple validation errors all included
BUG-003: Email without @ passed client-side (3 tests):
- API rejects email without @ symbol
- API rejects empty string as email
- API accepts valid
JWTemailforwithauthenticated@
BUG-004: Missing getDb import in auth.ts (5 tests):
- All auth module exports are functional (signToken, verifyToken, setAuthCookie, clearAuthCookie, getCurrentUser)
getCurrentUsergenerateTestRefreshToken()—returnsvalidnullrefreshwhen no tokenConstants:AllTEST_ORG_ID,exportsTEST_USER_ID,arefunctionsTEST_USER_EMAIL
E2E Tests (Playwright)
auth.test.tests/e2e/user-flows.spec.ts —-- 115 teststest groups
| onboarding
||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
invoices.test.ts — 11 tests
| credentials, ||
| ||
| fields, ||
| client-side
||
| ||
| ||
| ||
| ||
| PIN Dashboard (2 tests):
API Health (4 tests):
| api/rates |
returns | ||
returns | All Pages Load (10 tests): |
/, /login, /onboarding, /dashboard, /send, /scan, /history, /accounts, /profile, /cards) returns no server error
expenses.test.tests/e2e/full-flows.spec.ts —-- 98 testsjourneys
contacts.test.tests/e2e/input-chaos.spec.ts —-- 97 tests
test accounts.test.ts — 4 tests
banking.test.ts — 10 tests
reports.test.ts — 9 tests
transactions.test.ts — 9 tests
country.test.ts — 2740+ tests
TestsLogin the country plugin integration — routes that return country-specific tax configuration.
chatbot.test.ts — Chatbot API Tests
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
invoice-gl-reversal.test.ts — Invoice GL Reversal Tests
Tests InvoiceService.cancelInvoice() — when a SENT invoice is cancelled, reversing double-entry GL entries are created to undo the original booking.
new-endpoints.test.ts — Additional Endpoint Tests
Tests for supplemental endpoints not covered in the main mock suite.
e2e/api.test.ts — Full E2E (no mocks, live server)
End-to-end API integration test. Exercises the full Express application stack with a live server.
e2e/billing-flow.e2e.test.ts — Billing Workflow E2E
Tests the full billing flow through HTTP endpoints with mocked services (no real DB required):
Create contactCreate invoiceSend invoice (draft → sent)Mark invoice paid (sent → paid)Check P&L shows revenueVerify trial balance returnsisBalanced=trueMulti-currency invoice in EUR with country VAT ratesCredit note creation
apps/api/tests/unit/ — Unit Tests (service layer)
Service-level unit tests with mocked Prisma. No HTTP layer. Tests business logic in individual service classes.
invoice-service-calculations.test.ts — Invoice Arithmetic
Tests InvoiceService.createInvoice() arithmetic at the service layer. Verifies:
lineTotalEmpty=fields,quantityspaces-only×email,unitPriceXSS lineTaxin=email,lineTotalSQL×injectiontaxRatein/email,10010K subtotalchar=email,sum(lineTotals)unicode taxAmountpassword,=specialsum(lineTaxes)characters, totalNorwegian= subtotal + taxAmountcharactersbaseAmount = total × exchangeRate
password
two-factor.test.tscomplexity, —underage Two-FactorDOB, Authenticationduplicate Service
email, far-future DOB, OTP with letters/5 digits/7+ digits, phone with letters
TestsSend Money TwoFactorServiceatChaos the(6 service level. Mocks: bcryptjs, speakeasy, qrcode, Prisma.tests):
| XSS |
| |
| |
| |
| |
| |
| |
|
sef-submission.test.ts — SEF (Serbia E-Invoicing) Client
Tests SefClient class and InvoiceService.submitToSef() fire-and-forget behavior. HTTP calls are mocked via vi.spyOn(global, 'fetch').
| |
| |
| |
| |
| |
|
vat-calculation.test.ts — VAT Calculation Tests (Country Packages)
Tests pure calculation functions from @bilko/country-rs, @bilko/country-ba, and @bilko/country-hr. No Prisma, no HTTPletters
— stateless math functions.
| ||
| ||
| ||
apps/api/tests/integration/ — Real Database Tests
Integration tests that run against a real PostgreSQL database via docker-compose.test.yml. Requires Docker.
RunPage with:
cd apps/api
docker-compose -f ../../docker-compose.test.yml up -d
npm run test:integration
auth.integration.test.ts — Auth Integration
Full registration + login + refresh flow against real DB.
invoice.integration.test.ts — Invoice CRUD Integration
Invoice lifecycle against real DB: create → read → update → status change.
credit-note-gl.integration.test.ts — Credit Note GL Integration
Tests credit note creation against real DB — verifies reversing GL entries balance.
report.integration.test.ts — Reports Integration
Report generation against real DB with seeded transactions.
|
tenant-isolation.integration.test.ts — Multi-Tenant Security
Verifies multi-tenant isolation: Organization A cannot read or modify Organization B's data.
Coverage Tracking
| ||
| ||
| ||
| ||
| ||
Test Execution Commands
# All tests (from project root — mock + unit + E2E suites)
npm run test
# Core unit tests only
cd packages/core && npx vitest run
# API mock suite only (no DB required)
cd apps/api && npx vitest run
# API unit suite only
cd apps/api && npx vitest run tests/unit/
# API E2E suite only (mocked services, no DB)
cd apps/api && npx vitest run tests/e2e/
# Real DB integration tests (requires docker-compose.test.yml)
docker-compose -f docker-compose.test.yml up -d
cd apps/api && npm run test:integration
# Watch mode (re-run on change)
cd packages/core && npx vitest
cd apps/api && npx vitest
# Specific file
cd apps/api && npx vitest run tests/auth.test.ts
cd apps/api && npx vitest run tests/unit/two-factor.test.ts
# With coverage
cd packages/core && npx vitest run --coverage
# Verbose output
npx vitest run --reporter=verbose
Related Documents
tests):
TestingDashboardGuide:withoutTESTING-GUIDE.mdauth, BackendsendArchitecture:without../backend/BACKEND-ARCHITECTURE.mdauth, rapid navigation, double-click submit, browser back from OTP
Last Updated: 2026-03-02
Status: Active
Total Tests: ~390 across 27 test files (mock + unit + E2E + integration)