Repository navigation
fix(tests): fix EBUSY crash on Windows, correct Unicode receipt assertions, graceful printer skip - #3
Merged
Merged
Conversation
…tions, graceful printer skip
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 <[email protected]>
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
Aug 9, 2026
… legacy digest tests Issue #220 item #3 (High, supply chain): canonical/setup-lxd@main was a mutable ref used in a workflow with write permissions. Pinned to 8c6a87b (tag v1). Issue #220 item #8 (Low): `on.push.tags: '[0-9]*'` is a glob, not a version pattern — it matches any tag starting with a digit. Every downstream step reads VERSION from package.json rather than the pushed tag, so a malformed or mismatched tag could silently create a release titled after whatever package.json says. Added a validation step that rejects a tag that isn't strict X.Y.Z or doesn't equal package.json's version, before anything is built. Issue #220 item #4 (Medium): added a real, generated fixture frozen at schema v56 (the parent version of the tax-registration-number rename migration) and a test asserting that migration against a real pre-existing install's shape, not just a fresh createSchema() DB. Issue #220 item #9 (Medium): recovered the actual pre-removal official-india/official-thailand pack JSON from git history (the commit a51e828 removed the files but kept only their digests) and added a test proving the real historical bytes hash to exactly the digests LEGACY_TRUSTED_PACK_DIGESTS documents — previously only a synthetic stand-in pack exercised this path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
richanonymous22
referenced
this pull request
in richanonymous22/FloCafe
Aug 13, 2026
Milestone 2, Part 1+2. Finishes the work Phase 2A flagged as its natural next step: POST /orders/:id/items now goes through SaleService, and the per-item loop that used to be duplicated between order creation and item addition is one implementation with two callers. ## Shared line engine createSale and addSaleItems used to carry two near-identical copies of the per-item loop: product lookup, stock guard, price/quantity validation, addon subtotal, tax calculation, insert, addon insert, stock decrement. Both now call the internal persistSaleLine() for that work. What still differs between them is aggregation, and that difference is preserved deliberately: createSale sums per-line results as it goes (nothing else exists on a brand new sale); addSaleItems re-derives totals from every ACTIVE line in the database afterwards, because it may be adding to a sale that already has items, some of which may be cancelled — the inherited "BUG #3 FIX". One direct benefit of consolidation: items added via addSaleItems now receive a ULID uid, same as items from createSale. The old add-items route never populated it — an artifact of Phase 2A only having migrated one of the two paths. ## addSaleItems Behaviour-preserving extraction of the second half of docs/PHASE_2A_SALE_FLOW.md. All four inherited "BUG #N FIX" comments in the original handler are preserved and each has an explicit test: cancelled-line exclusion from recalculated totals (#3), order-level discount rescaling when a percentage discount meets a changed subtotal (#12), re-fetching the order under the transaction lock to catch a concurrent completion/cancellation (#175), and re-syncing an existing unpaid bill so it doesn't go stale (#4). Two guard clauses stay in the route rather than moving into the service, and the reasoning is written down at both ends (the route handler and the addSaleItems docstring): the bills.split_group_id lock is a simple, self-contained check with nothing to share, and the waiter-ownership check is an HTTP-layer authorization decision tied to the caller's role — it belongs beside requireRole, not inside a service with no Express dependency. Both run in the same relative order as before, so no response code changes for any input. actorUserId is threaded through for audit attribution only; it plays no part in either check. One new audit event type, sale.items_added, recorded inside the same transaction as the items it describes — added to the AuditEventType union introduced in Phase 1. ## Verification Extended tests/plemmo-sale-service.test.ts with 45 new checks (84 -> 129): shared-engine wiring (uid on newly added lines, stock decrement for post-creation additions), every rejection path with its exact status, rollback (a failure on line 2 of an add leaves no line, no audit event, and an unchanged subtotal), the four BUG-fix behaviours above with dedicated assertions, idempotent replay, the specialInstructions presence-vs-absence distinction (needed a typed { value } wrapper since `undefined` alone can't tell "leave untouched" apart from "clear the notes"), and a tableless counter sale proving the retail shape works for a multi-call flow, not just creation. Targeted regression: integration-happy, integration-tax, integration-reconciliation, integration-discount, issue-122 (exercises POST /orders/:id/items addon-quantity validation directly, exact 400s), issue-125, issue-24, order-item-addons, orders-authz, authz-phase3, tax-pack-management — all pass unchanged. Full npm test suite green (exit 0, 42 suites reporting 0 failed, zero assertion errors). Build clean, lint 0 errors. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_011HjBK8R8ArAjzGRLS7gjUj
27 tasks done
This was referenced Oct 28, 2026
This was referenced Nov 8, 2026
This was referenced Nov 28, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three test-suite fixes found while running
npm teston Windows for the first time.Fixes
1.
tests/backup-restore.test.ts— EBUSY crash on WindowscreateTestDb()was returning a new openDatabaseSynchandle after already closing the DB.fs.rmSync()to throwEBUSY: resource busy or lockedon cleanup.voidand addedcurrentDb.close()beforecleanup().2.
tests/printer.test.ts— Wrong currency in assertionsformatReceipt()calls in tests were missinguseUnicode: true.formatReceiptmaps₹→Rs(ASCII fallback for old thermal printers), so assertions liketext.includes('₹925.00')were always false.useUnicode: trueto allformatReceipt()calls in the test suite.3.
tests/printer.test.ts— Hard failure when no printer driver installedTesting