WyzBooks WyzBooks v26.4.140658

Accounting & API Tests

Help — Accounting Tests

WyzBooks includes 1,579 tests across seven suites that validate all accounting functions, the shared accounting module, the REST API, multi-user shared file operations, UI smoke tests, event-store integrity, and projection replay.

Note

Run from the terminal:

npm run test                        # 365 CPA-level accounting tests (35 categories)
npm run test:lib                    # 376 shared module tests (via require())
npm run test:api                    # 587 REST API tests (28 suites)
npm run test:ui                     # 14 Playwright UI smoke tests
node tests/shared-file.test.js      # 99 multi-user shared file tests
node tests/lib/event-store.test.js  # 87 event-store tests
node tests/lib/projection.test.js   # 51 projection tests

CPA-Level Accounting Tests (365 tests)

Validate all accounting functions against GAAP: double-entry math, balance sheet equation, trial balance, revenue recognition, A/R reconciliation, aging, bank reconciliation, import parsers, and more.

Test Categories

  • Double-entry bookkeeping (debit/credit math)
  • Balance sheet equation: A = L + E + Net Income
  • Trial balance always balances
  • Revenue recognition (invoice posting)
  • Cash collection & AR reduction (payments)
  • Partial payment tracking
  • Profit & Loss with date filtering
  • A/R & A/P aging buckets
  • Bank reconciliation arithmetic
  • General ledger running balances
  • IIF parser (QuickBooks import)
  • CSV parser (trial balance, transactions)
  • Payment terms & due date calculation
  • Chart of accounts structure
  • Inter-account transfers (bank, CC payments)
  • Transfers don't affect P&L
  • Import invoice line items (IIF TRNS/SPL)
  • CSV multi-line invoice grouping
  • Duplicate invoice detection
  • Payment recovery by reference matching
  • FIFO payment-to-invoice reconciliation
  • Self-payment for cash sales

Full Business Cycle Scenarios

  • Invoice-to-Payment: Owner invests → Invoice → Full payment → verify AR, bank, TB, and BS equation
  • Partial Payments: Multiple invoices with partial payments, status transitions, remaining balances
  • Credit Card Cycle: Expenses on CC → Pay CC from checking → verify all balances zero out correctly
  • Depreciation: Equipment purchase → 12 months of depreciation → verify net book value and equation

GAAP Principles Verified

  • Every journal entry must have equal debits and credits
  • Assets & Expenses increase with debits (debit-normal)
  • Liabilities, Equity & Income increase with credits (credit-normal)
  • Balance Sheet uses all-time balances; P&L uses date-filtered balances
  • Aging reports use correct day-count from due date with proper bucketing
  • Reconciliation: difference = statement balance − previously reconciled − cleared total

Shared Module Tests (376 tests)

Run against the shared accounting module (src/lib/accounting.js) via require(). Includes the same CPA tests plus additional tests for module-specific features (tolerance constants, import balance verification, enrichment).

REST API Tests (587 tests, 28 suites)

End-to-end tests for all 18 REST API routes. Each test suite spins up a temporary data directory, starts the API server, and validates request/response behavior including:

  • CRUD operations — Create, read, update, delete for accounts, contacts, invoices, payments, items, journals, and bank transactions.
  • Report generation — All 17 reports via API with date range parameters.
  • Import pipeline — IIF and CSV import via API endpoints.
  • Data integrity — A/R reconciliation, atomic writes, file locking, and audit logging.
  • Regression suites (22–28) — Payment edit, cloud sync, import validation, JE rounding, cascade delete, BOM handling, merge safety, and post-import accounting verification.

UI Smoke Tests (14 tests)

Playwright end-to-end tests that launch the Electron app and verify: app launches without white screen, all 15 sidebar menu items render, all 7 Settings tabs work, Dashboard quick-action modal, theme toggle, Help page topics, vendor/item creation end-to-end, and basic page rendering for invoices, Chart of Accounts, reports, journal entries, and bank register.

Event Store & Projection Tests (138 tests)

Unit tests for the event-log storage engine (87 tests) and projection replay algorithm (51 tests). Cover: append/batch operations, compaction, serialization round-trips, migration from old format, incremental vs full replay, diffSnapshots, and computeChangedFields with order-independent deep comparison.

Post-Import Verification (Suite 27, 14 tests)

After each import type (IIF, CSV, pipeline), verifies accounting invariants: trial balance balanced, balance sheet equation holds, every journal entry balanced, no orphaned account references, AR balance matches open invoices, no duplicate account numbers.

Enrichment Debug Harness

A separate debug tool verifies that invoice enrichment (qty/rate/total) matches expected values from the item-detail CSV:

node tests/enrichment-debug.js           # Full comparison
node tests/enrichment-debug.js --summary  # Summary stats only
node tests/enrichment-debug.js --invoice 2664  # Debug specific invoice