feat: printing problems shown and handled; printing set-up on v2 (platform-v2 step 6.10)
- a ticket that doesn't print is a problem for whoever sent it and the managers: GET /api/print-problems (the order, table, dishes, printer, since when, tries, last error, who sent it) and three ways out: print again, send to another printer, handled (services/print_problems.py; print_jobs.resolved_by / redirected_to, Alembic 0036); live event print.problems from the print paths - phone: the red printer button opens the problems sheet, the table page warns (usePrintProblems replaces the 8 s poll); counter POS: a red button under the modes with the shared panel (@xenia/ordering PrintProblemsPanel + pure rules); manager: a card on the overview (top), the Tables page and the order page - manager: Settings -> Printing (printers with reachability, test print, network scan; ticket layout + test ticket, beep, fonts with previews, dot leader, dividers) and Management -> Prep zones (cards + zone dialog with the ticket language, printers, copies, sorting, category order, kitchen screen) rebuilt in src/pages/printing; v1 PrintFontsTab, PrepZonesConfigPage, PendingPrints and /api/orders/pending-prints removed - access: printer add/edit/delete/scan need core.settings.manage, prep zone changes catalog.menu.manage (were any dashboard user) - tests: test_print_problems.py, @xenia/ordering printProblems, manager printing.test.mjs, e2e print_problems.mjs (done-when) + manager.mjs printing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
bookingBody, cashCheck, dayKpis, dayOrders, durationParts, hourBuckets, initials, itemKind, itemShown,
|
||||
messageAcks, messageTargets, notesPreview, orderPairs, orderTotal, paymentTotals, printRetries, quickAmounts,
|
||||
messageAcks, messageTargets, notesPreview, orderPairs, orderTotal, paymentTotals, quickAmounts,
|
||||
shiftCounts, shiftMoney, tableCards, tableName, tablesByZone, toneOf, TONES, venueWallClock,
|
||||
} from '../src/pages/overview/overviewLogic.js'
|
||||
import { onlineKind, onlineNextStep } from '../src/pages/online/onlineOrdersLogic.js'
|
||||
@@ -110,8 +110,6 @@ test('the day\'s payments, messages, notes, print retries', () => {
|
||||
const notes = [{ id: 1, is_pinned: true }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]
|
||||
const todos = [{ id: 9, priority: 'high' }, { id: 8, priority: 'high', is_done: true }, { id: 7, priority: 'low' }]
|
||||
assert.deepEqual(notesPreview(notes, todos).map(x => `${x.kind}${x.id}`), ['note1', 'todo9', 'note2', 'note3', 'note4'])
|
||||
assert.equal(printRetries({ print_jobs: [{ status: 'pending', retry_count: 2 }, { status: 'done', retry_count: 9 }] }), 2)
|
||||
assert.equal(printRetries({}), 0)
|
||||
})
|
||||
|
||||
test('bookings are typed in venue time', () => {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Printing set-up as plain data (plan step 6.10).
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
beepBytes, beepSettings, decodeBeep, decodeDots, decodeFont, encodeDots, encodeFont, move, orderedCategories, printerBody,
|
||||
printerProblems, setBypass, setMain, toggleSecond, zoneBody, zoneForm, zoneProblem,
|
||||
} from '../src/pages/printing/printingLogic.js'
|
||||
|
||||
test('fonts and the dot leader round-trip; bad values fall back', () => {
|
||||
assert.deepEqual(decodeFont('48:1:0'), { size: '48', bold: true, caps: false })
|
||||
assert.equal(encodeFont({ size: '16', bold: false, caps: true }), '16:0:1')
|
||||
assert.deepEqual(decodeFont('99:x'), { size: '0', bold: false, caps: false })
|
||||
assert.equal(encodeDots(decodeDots('dash_space:32:1')), 'dash_space:32:1')
|
||||
assert.deepEqual(decodeDots(''), { style: 'dot_space', size: '0', bold: false })
|
||||
})
|
||||
|
||||
test('beep: presets, custom, off, and what the test sends', () => {
|
||||
assert.deepEqual(decodeBeep('triple', 'true'), { preset: 'triple', n1: 1, n2: 1, n3: 3 })
|
||||
assert.deepEqual(decodeBeep('custom:3:2:4', 'true'), { preset: 'custom', n1: 3, n2: 2, n3: 4 })
|
||||
assert.equal(decodeBeep('double', 'false').preset, 'off')
|
||||
assert.deepEqual(beepSettings({ preset: 'off' }), [['print.beep_on_ticket', 'false']])
|
||||
assert.deepEqual(beepSettings({ preset: 'custom', n1: 99, n2: 0, n3: 2.4 }), [['print.beep_on_ticket', 'true'], ['print.beep_pattern', 'custom:30:1:2']])
|
||||
assert.deepEqual(beepBytes({ preset: 'long' }), { n1: 5, n2: 2, n3: 1 })
|
||||
})
|
||||
|
||||
test('printer form: what is wrong, and the body', () => {
|
||||
assert.deepEqual(printerProblems({ name: ' ', ip_address: '10.0.0.300', port: 0, line_width: 48 }), ['name', 'ip_address', 'port'])
|
||||
assert.deepEqual(printerProblems({ name: 'Bar', ip_address: '192.168.1.20', port: '9100', line_width: '42' }), [])
|
||||
assert.deepEqual(printerBody({ name: ' Bar ', ip_address: '192.168.1.20 ', port: '9100', line_width: '42', codepage_n: '24' }),
|
||||
{ name: 'Bar', ip_address: '192.168.1.20', port: 9100, protocol: 'escpos_tcp', line_width: 42, codepage_n: 24, is_active: true })
|
||||
})
|
||||
|
||||
test('zones: main and second printers, the kitchen screen switches, what is missing, the body', () => {
|
||||
let f = zoneForm(null)
|
||||
assert.equal(zoneProblem(f), 'name')
|
||||
f = { ...f, name: ' Grill ' }
|
||||
assert.equal(zoneProblem(f), 'printer')
|
||||
f = setMain(f, 3)
|
||||
assert.deepEqual(f.printer_ids, [3])
|
||||
f = toggleSecond(toggleSecond(f, 5), 3) // the main one can't be unticked
|
||||
assert.deepEqual(f.printer_ids, [3, 5])
|
||||
assert.equal(zoneProblem(f), null)
|
||||
f = setBypass(f, 'bypass_kds', true)
|
||||
assert.equal(f.bypass_pending, true)
|
||||
f = setBypass(f, 'bypass_pending', false)
|
||||
assert.equal(f.bypass_kds, false)
|
||||
const body = zoneBody({ ...f, description: ' ', master_copies: 20 })
|
||||
assert.equal(body.name, 'Grill')
|
||||
assert.equal(body.description, null)
|
||||
assert.equal(body.language, null)
|
||||
assert.equal(body.master_copies, 9)
|
||||
assert.equal(zoneForm({ name: 'Bar', group_by_category: 1, language: null }).group_by_category, true)
|
||||
})
|
||||
|
||||
test('category order: ranked first, then the rest; moving within bounds', () => {
|
||||
const cats = [{ id: 1 }, { id: 2 }, { id: 3 }]
|
||||
assert.deepEqual(orderedCategories(cats, [3, 9]).map(c => c.id), [3, 1, 2])
|
||||
assert.deepEqual(move([1, 2, 3], 0, -1), [1, 2, 3])
|
||||
assert.deepEqual(move([1, 2, 3], 2, -1), [1, 3, 2])
|
||||
})
|
||||
Reference in New Issue
Block a user