Skip to content

fix(tests): fix EBUSY crash on Windows, correct Unicode receipt assertions, graceful printer skip - #3

Merged
itsbkm merged 1 commit into
FreeOpenSourcePOS:mainfrom
khaira777:main
Jun 11, 2026
Merged

fix(tests): fix EBUSY crash on Windows, correct Unicode receipt assertions, graceful printer skip#3
itsbkm merged 1 commit into
FreeOpenSourcePOS:mainfrom
khaira777:main

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Summary

Three test-suite fixes found while running npm test on Windows for the first time.

Fixes

1. tests/backup-restore.test.ts — EBUSY crash on Windows

  • createTestDb() was returning a new open DatabaseSync handle after already closing the DB.
  • This leaked an open SQLite connection that Windows locked, causing fs.rmSync() to throw EBUSY: resource busy or locked on cleanup.
  • Fix: Changed return type to void and added currentDb.close() before cleanup().
  • macOS/Linux were unaffected (OS releases file handles more loosely), which is why this wasn't caught before.

2. tests/printer.test.ts — Wrong currency in assertions

  • All formatReceipt() calls in tests were missing useUnicode: true.
  • Without it, formatReceipt maps Rs (ASCII fallback for old thermal printers), so assertions like text.includes('₹925.00') were always false.
  • This caused 12 out of 58 tests to fail on all platforms.
  • Fix: Added useUnicode: true to all formatReceipt() calls in the test suite.

3. tests/printer.test.ts — Hard failure when no printer driver installed

  • The "host has at least one printer installed" assertion was a hard failure on any machine without thermal printer drivers (dev machines, CI).
  • Fix: Changed to a graceful informational skip when no printers are detected.

Testing

  • All 58 printer tests now pass ✅
  • All 4 backup/restore tests now pass ✅
  • DB audit passes ✅
  • Tested on Windows 11

@itsbkm
itsbkm merged commit eb0218b into FreeOpenSourcePOS:main Jun 11, 2026
khaira777 added a commit that referenced this pull request Jul 5, 2026
…ts/discounts/tax/loyalty)

Integration tests (7 files, 123 assertions):
- Happy path: order→discount→bill→payment→completed
- Tax correctness: India GST calculation and recalculation
- Payment integrity: split payments, wallet double-spend, zero-amount rejection
- Order lifecycle: status transitions, cancel with PIN
- Bill reconciliation: discount sync, add-items sync
- Loyalty points: cashback, idempotency, wallet balance
- Discount edge cases: combined discounts, max limits, addon prices

Bug fixes:
- #3: Add-items filters cancelled items from total recalculation
- #4: Add-items syncs bill after updating order total
- #5: Cancel/restore round-off formula corrected
- #6: Discount endpoint wrapped in withTxn (race condition)
- #7: Infinity passes validation (NaN/isFinite check)
- #8: Missing amount defaults to remaining balance
- #9: Amount capped at remaining balance
- #11: Removing discount restores original tax
- #12: Add-items preserves order-level discount
- #13: Cancel/restore preserves order-level discount
- #14: Item-level discount checks max settings
- #15: Item-level discount syncs to bill
- #17: Cancel/restore wrapped in withTxn
- #20: Cashback calculated on discounted subtotal
- #23: Quantity/price validation on order creation

Shared test helper (tests/helpers/test-setup.ts):
- Extracts 40 lines of boilerplate per test file
- Provides: initTestDb, createApp, startServer, seed helpers, assert utilities

Co-Authored-By: Claude <noreply@anthropic.com>
khaira777 pushed a commit that referenced this pull request Jul 6, 2026
fix(tests): fix EBUSY crash on Windows, correct Unicode receipt assertions, graceful printer skip
itsbkm added a commit that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants