Skip to content

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

Open
khaira777 wants to merge 1 commit into
FreeOpenSourcePOS:mainfrom
khaira777:main
Open

fix(tests): fix EBUSY crash on Windows, correct Unicode receipt assertions, graceful printer skip#3
khaira777 wants to merge 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

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.

1 participant