Barcode scanner — manual testing
How to exercise the v4 barcode flow locally: device configuration, editor assignment, and cart scanning. EAN/UPC values are stored in barcode, not in the quick-search code field.
Prerequisites
- A place with at least one product.
- A connected TPV service (
RASPPI) with aCODESCANrow (Place → Devices → service → add barcode scanner). - POS front open on the cart tab or a product/shortcut editor.
Without a configured CODESCAN, barcode UI and cart HID listening stay hidden (service?.codescans.length === 0).
HID simulator (host)
Location: tools/barcode-hid-simulator/
cd tools/barcode-hid-simulator
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python simulate_barcode.py
Stdin workflow (recommended on macOS):
- Run the script in Terminal.
- Type a digit
0–9and Enter. - During the countdown, focus Chrome on the POS (editor or cart).
- The script injects the mapped barcode + Enter at keyboard speed.
Default mappings in barcodes.json are real EAN-13 barcodes for common soft drinks (refrescos), suitable for discovery (barcode/discover) and manual cart/editor tests:
| Key | EAN-13 | Typical product |
|---|---|---|
0 | 5449000000996 | Coca-Cola Original Taste 33 cl |
1 | 5449000004840 | Fanta Naranja |
2 | 5449000000729 | Sprite slim 25 cl |
3 | 5449000205520 | Sprite |
4 | 5449000054227 | Coca-Cola 500 ml |
5 | 5449000120960 | Fanta Zero Sugar |
6 | 5449000104885 | Sprite Zero lima-limón |
7 | 8712561730034 | Pepsi Cola 330 ml |
8 | 9002490100071 | Red Bull Energy Drink 250 ml |
9 | 5449000120984 | Fanta Orange Zero 2 L |
Copy those values into PRODUCT.barcode or PRESELECT.barcode in the editor — not into code.
macOS: grant Accessibility to the Python binary printed at startup if injection does nothing.
Scenarios
Assign barcode in editor
- Open product or shortcut edit (with scanner configured).
- Tap Assign barcode → listening overlay.
- Run simulator digit
1→ value5449000004840(Fanta Naranja) should appear with preview. - Accept the editor → sync persists
barcode.
Cart — single match
- Assign
5449000004840to a purchasable product. - Open cart select tab.
- Scan/simulate the same barcode → product added to ticket.
Cart — multiple matches
- Assign the same barcode to two products or shortcuts.
- Scan once → product match modal opens (barcode prefilled).
- Pick one row → added to ticket.
Cart — manual code search
- Enable Product codes in place settings (
optionProductCodes). - At catalog root, tap the By number thumb (
PRDNO). - Enter a product
codeprefix on the numpad → same modal in code mode (doPrdCode).
Field reference
| Field | Table | Used for |
|---|---|---|
barcode | PRODUCT, PRESELECT | HID scanner, editor assignment, doBarCode |
code | PRODUCT, PRESELECT | Manual keypad search when optionProductCodes |
Unit tests
upp-data:barcode.spec.ts,productcode.spec.tsupp-base:barcode.spec.tsupp-wdgt:upp-barcode-display.spec.tsfeature/place:upp-tab-select.spec.ts,upp-product-match-modal.spec.ts
Run in nx-dev:
npx nx test upp-data --testPathPattern='barcode|productcode'
npx nx test upp-base --testPathPattern=barcode
npx nx test upp-wdgt --testPathPattern=upp-barcode
npx nx test feature-place --testPathPattern='tab-select|product-match|codescan'