Repository navigation
Enhancement: Add-on Multi-Quantity Support - #122
Merged
Merged
Conversation
khaira777
force-pushed
the
main
branch
2 times, most recently
from
July 22, 2026 21:59
46f0145 to
c6f9e70
Compare
…issue #83) - Add migration v33 with addon_groups.allow_multiple_quantities column - Update backend order and tax routes to validate and compute addon quantities - Update POS AddonModal with +/- quantity controls and total group bounds check - Update cart store identity generation and subtotal calculations - Format add-on quantities on KDS views and printed receipts (e.g. Sugar ×3) - Add comprehensive integration test suite in tests/issue-122-addon-quantities.test.ts
…toggle to products addon modal - Add server-side validateItemAddonGroupLimits helper in main/routes/orders.ts to enforce allow_multiple_quantities, min_selection, and max_selection on order placement - Update Products page add-on group editor state, form submit handler, and modal UI to load, edit, and submit allow_multiple_quantities - Add backend group limit enforcement integration test assertions in tests/issue-122-addon-quantities.test.ts
# Conflicts: # frontend/src/components/pos/AddonModal.tsx
…ddon count + inactive category indicators - Unify layout in POS AddonModal so both single-select and multi-select rows show price next to name on the left and action controls (+ / [- 1 +]) on the right - Add Add-ons column in Products page table showing total addon groups linked to each product - Add Inactive Category warning badge to Products page table when a product's parent category is disabled
…e browser printing mode, and fix toggle alignment - Enforce required add-on group selection in POS AddonModal (disabled Add to Cart button + red warning when required count not met) - Handle browser print mode smoothly in usePrinter (call printViaBrowser instead of throwing uncaught Error) - Add shrink-0, gap-4, and flex-1 min-w-0 to settings page toggle rows to prevent switch cutoff on small screens
Contributor
Author
PR #122 Summary: Add-on Multi-Quantity Support (Issue #83)1. Overview & ArchitectureThis PR completes the full implementation of multi-quantity add-on support per add-on group. Store owners can configure whether an add-on group allows customers to select multiple quantities of individual add-on items (e.g. 2x Extra Shot, 3x Syrup) while strictly enforcing group minimum and maximum selection caps. 2. Key ChangesDatabase Schema
Backend Routes & Validation (
|
khaira777
marked this pull request as ready for review
July 23, 2026 14:36
khaira777
added a commit
that referenced
this pull request
Sep 25, 2026
khaira777
added a commit
that referenced
this pull request
Sep 25, 2026
* test(harness): add throwing assertion variants and pin the contract The shared helpers only printed and counted, so a suite that never read getResults() exited 0 with failing assertions. Add assertOrThrow and friends alongside them, and add a regression test that spawns a deliberately failing fixture and requires a non-zero exit while the counting variants keep reporting without throwing. * test(auth-state-recovery): fail loudly instead of counting silently * test(currency): fail loudly in currency split-check suite * test(customer-phone-search): exit non-zero on a failed assertion * test(held-orders): fail loudly instead of counting silently * test(kds): fail loudly in the WebSocket revalidation suite * test(tables): fail loudly in the string-ID suite * test(issue-646): run the floor-management regression and fail loudly The suite was referenced by no script, so the Issue #646 floor rename, merge, and RBAC coverage never ran, and its assertions only counted. * test(issue-263): run the phone-normalization regression The suite was referenced by no script. Its setup predates the decision that regional settings come from signup, so the store had no country and national-format numbers were rejected at the route; seed through the shared initTestDb() choke point instead. * test(integration-tax): run the inclusive-tax integration suite * test(addons): run the add-on multi-quantity regression for issue #122 * test(barcode): run the scale-barcode regression for issue #365 * test(backup): run the Windows temp-file unlink EBUSY regression * test(whatsapp): drop the shutdown-timeout suite it can no longer pass Wiring it exposed two things. Its fixture sends to +15555550100, which libphonenumber now rejects as invalid, so the send short-circuits with not_on_whatsapp and the test never reaches its assertions - it exits 0 having tested nothing. Correcting the number reaches the real scenario, and main/services/whatsapp.ts:289 then never returns: it spreads a Map into [key, value] pairs, so Promise.allSettled resolves immediately and the while loop starves the event loop, meaning neither the service's own SHUTDOWN_TIMEOUT_MS timer nor runShutdownSteps' bounded timeout can fire. The suite hangs forever, so it cannot be wired into the default run until that production bug is fixed. Reported separately, not fixed here. * test(inventory): run the volume sale-unit and inventory-link suite * test(script-coverage): fail when a suite file is in no reachable script The validator only walked script to script, so eight suites that nothing referenced passed CI untouched. Check the test-file direction against the transitive closure from pretest/test, allowlist nothing the closure already reaches, and cover the new behaviour in the validator's test. * test(manager-pin): reset the bill PIN rate limiter around the suite main/routes/orders.ts exports a reset hook for its limiter; the copy in bills.ts had none, so the module-level map leaked between suites keyed by client IP. Export the same hook and clear it before and after the suite that spends the whole 5-attempt budget. * test(db): fail when the maintenance allowlist drifts from the routes The five hardcoded METHOD /api/... strings in main/db.ts decide which handlers are excluded from activeDatabaseRequests. A rename makes a handler wait on a drain that includes itself, so assert each string still resolves to a registered route. * docs: record the assertion and wiring contract for test suites * fix(script-coverage): read the path capture group, not a fixed slice extractReferencedTestFiles anchored its match with (?:^|[\s'"]) and then dropped the first character of every match. The boundary alternates a real character with the zero-width `^`, so a command that begins directly with a suite path lost its leading `t`: "tests/held-orders.test.ts" extracted as "ests/held-orders.test.ts". Every current script happens to prefix its paths with a space or a node binary, so the bug was latent - but this validator exists to catch omissions, and a path it silently truncates is an omission it would report. Read match[1] via matchAll instead. Two regression cases pin it: a command that starts with the path, and a mixed command where the second path follows `&&` and also matches the `^` boundary. * test(db-allowlist): clean up the temp dir and accept either quote style The suite mkdtemp'd a directory for the electron stub and never removed it, so every run left one behind. Move to process.exitCode + finally: an immediate process.exit in the catch handler would skip the cleanup, and the non-zero exit is preserved either way. Widen the route extractor from '...' to ['"]...['"]. The empty-extraction guard already caught a wholesale format change, so this is defensive, but a suite whose purpose is failing on route drift should not go red on a quote-style change instead. * test(whatsapp): park the shutdown-timeout suite instead of deleting it The suite is the contract for a real production bug: waitForWhatsAppWork() in main/services/whatsapp.ts spreads a Map where promises are expected, so the drain loop starves the event loop and both shutdown timeouts can never fire. The suite hangs rather than fails, so it cannot run in the default suite. Deleting it destroyed the exact assertions the fix needs. Restore it and exclude it explicitly, with the blocking bug named in the exclusion reason and in a header note, so the next reader knows it is parked rather than obsolete. The validator's own test already asserts that an excluded file still exists and is still unreachable, so the exclusion cannot rot silently. The production fix is behaviour, not structure, and stays in its own change. * style(tests): use plain hyphens in the lines this change adds AGENTS.md asks for plain hyphens rather than em dashes, and the five lines this branch adds broke that. No test asserts on the message punctuation, so the formatting-only change is safe. Pre-existing helpers in the same file still emit em dashes, as do roughly a dozen suites that build their own failure lines. Those are untouched here: they are not part of this change and sweeping them would bloat the diff. The inconsistency is recorded in the pull request for a later cleanup. * fix(rebase): restore the issue-646 script definition lost resolving a conflict Rebasing onto the titlebar and Nepali commits conflicted on the single-line `test` chain, because main added test:menu-surface to the same place this branch added test:issue-646-floor-management. Resolving that by taking the upstream line wholesale also reverted the script *definition* added by the earlier wiring commit, leaving the chain invoking a script that did not exist. The chain is now verified to be exactly main's plus this branch's one insertion, and the definition is back. The check that caught this is the coverage validator, which is exactly the guard this slice adds. * fix(script-coverage): require a test runner before a path counts as coverage extractReferencedTestFiles matched any test-file path anywhere in a command string, so `echo "tests/foo.test.ts"` marked that suite covered. A file could therefore be reported as run by the default suite when nothing ran it - the same false-negative shape as the slice(1) truncation, in the direction this validator exists to close. Filter to segments that actually invoke a runner (node, ts-node, tsx, bun, deno, electron, optionally through the run-test.sh wrapper). Verified no legitimate script was lost by the tightening: the reachable and covered counts are unchanged at 183 and 220. Four regression cases: a quoted printed path, a printed path alongside a suite that really runs, the run-test.sh wrapper, and a command that is only a path. Proven end to end too - a script whose only mention of a new suite file is an echo makes the validator report that file as orphaned. Two earlier cases asserted that a bare path at the start of a command is extracted intact. Requiring a runner makes that command run nothing, so both now assert the opposite, and the no-truncation guarantee is pinned through runner-prefixed commands instead. Since a counted segment always begins with a runner token, the `^` boundary no longer fires; the capture group is kept regardless, so the extractor stays correct if that ever changes. Also correct the success line: it described excluded files as "run by a dedicated command", which is true of the audit file but false of the parked WhatsApp suite, excluded because a production bug blocks it. It now says "excluded with a stated reason"; the counts and the default-suite wording are unchanged. And assert that the command justifying an exclusion still names its file, so retargeting or deleting `audit:db` cannot leave tests/db-audit.test.ts run by nothing while the validator and its test stay green. Only exclusions justified that way are listed; the parked suite has no command by definition and is deliberately kept out of that map so the two different reasons stay distinct. * test(db-allowlist): expect the five maintenance handlers independently The suite derived its inputs from DATABASE_MAINTENANCE_ROUTES and then probed only those entries, so deleting a handler from the set while leaving the handler registered passed: the probe simply had one fewer entry to check. A coverage gap in the one test whose job is failing on drift. Declare the five handlers the test expects and compare the allowlist against them, so removal fails. Verified by deleting 'POST /api/db/backup' from the set with the handler still registered: the suite fails on the new comparison, and passes again once restored. Production shutdown and maintenance behaviour is untouched. * docs(whatsapp): correct the parked suite's description of the map The comment had the map backwards. inFlightWhatsAppWork is a Map<Promise, WhatsAppWorkCancellation>: the in-flight operation is the key and the cancellation callback is the value, both confirmed at the declaration and at inFlightWhatsAppWork.set(operation, cancel). Spreading it therefore hands allSettled alternating operations and cancellation callbacks, not "no promises". Corrected in the parked test's header and in the validator's exclusion reason so the two agree. While correcting it, removed the claim that was not established: I had described the loop as starving the event loop, but the timeout is a timer and the loop exits on the map emptying, which operation.finally does - so that mechanism does not follow from the code. What is verified is the symptom: the suite does not finish and neither timeout fires. The comment now says that, and leaves the cause for the fix task. Comment only. No production behaviour touched. * docs(whatsapp): correct the parked suite's mechanism, with evidence A review thread was right and this file was wrong. Spreading a Map iterates its default entry sequence, so `[...inFlightWhatsAppWork]` is an array of `[operation, cancel]` ENTRY ARRAYS - not a flat alternation of keys and values, which is what the last commit claimed. An entry array is not a thenable, so `Promise.allSettled` resolves on the next microtask without awaiting any operation at all. That also means last commit's removal of the starvation claim was an over-correction: the starvation is real. Restored, and now grounded rather than asserted. A faithful miniature of trackWhatsAppWork + waitForWhatsAppWork shows `[...map]` hanging with the 20ms release timer and a 1500ms diagnostic timer both never firing, against `[...map.keys()]` draining in 21ms in one pass. The proposed fix is now stated correctly: `[...inFlightWhatsAppWork.keys()]`, not `values()` - the values are the cancellation callbacks, equally non-thenable. The exclusion reason in the validator is brought into line with the file, so the two no longer disagree. Re-read the rest of the file against current code rather than memory. Verified correct and left alone: the Map's key/value roles (whatsapp.ts:167, 269), the drain expression (whatsapp.ts:289), `abortable` calling `trackWhatsAppWork` at whatsapp.ts:204 so the pending presence really is tracked, `SHUTDOWN_TIMEOUT_MS` = 10_000 shared by whatsapp.ts and shutdown.ts so the test's setTimeout patch covers both timers, the four whatsapp exports, the `../baileys-loader.cjs` request string, `runShutdownSteps` with `onFatalTimeout`, and the `whatsapp_messages` columns status/error/failed_at/direction/body the queries name. No other statement in the file needed changing. Comment only. main/services/whatsapp.ts untouched.
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.
Resolves #83. Work in progress for add-on configuration UX and multi-quantity support.