feat(manager): every settings tab on v2 (platform-v2 step 6.14a)
- Settings: tabs in the address (?tab=), Fiscal only with the fiscal app, Appearance only with the waiter app - General: version / update / license / state / uptime, the local network (address by hand or found, the pairing QR), what is set up, export / import of the catalogue and the tables (a wrong file refused, two confirmations), support lock - Sign-in & security: idle lock / sign-out (seconds..hours, warning when sign-out comes first), recovery codes - Operation: role permissions, waiters' own shifts and takings, card payments, tables and orders, courses (add, rename, colour, order), quick notes, table flags (emoji, colour, white/black text, on/off), quick messages, send the QR menu now - Appearance: the waiter app's table-card colours per state, light and dark, flash, colour picker with opacity, reset - Fiscal: on/off, driver, folders with a reachability check, clerk / card terminal numbers, receipt end lines, VAT groups - Development: pretend printing - dropped: the v1 'automatic store schedule' switches (kept in the browser only, nothing read them) and the second time-zone card - backend: JSON settings must be JSON (validation.setting_value); fiscal folders are plain paths (were typed json) - venue colour data in sections/venueColours.js (guard DATA); store/tableColourStore and Settings/tabs deleted - tests: settings.test.mjs (5), test_settings_json.py, e2e manager.mjs 'settings v2' (12 checks) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// The settings tabs' rules as plain data (plan step 6.14a).
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
addCourse, buildColour, bundleSummary, cleanNotes, cleanVatGroups, endLines, idleParts, lanAddress, mergeColours, move,
|
||||
nextColour, parseColour, readJson, setSlot, uptime, waiterPairUrl,
|
||||
} from '../src/pages/Settings/sections/settingsLogic.js'
|
||||
|
||||
test('idle times, JSON settings read safely', () => {
|
||||
assert.deepEqual(idleParts(30), { n: 30, unit: 'seconds' })
|
||||
assert.deepEqual(idleParts(300), { n: 5, unit: 'minutes' })
|
||||
assert.deepEqual(idleParts(3600), { n: 1, unit: 'hours' })
|
||||
assert.deepEqual(readJson('[1,2]', []), [1, 2])
|
||||
assert.deepEqual(readJson('{"a":1}', []), [])
|
||||
assert.deepEqual(readJson('nope', []), [])
|
||||
assert.deepEqual(readJson(null, ['x']), ['x'])
|
||||
})
|
||||
|
||||
test('courses and quick notes', () => {
|
||||
const pal = ['A', 'B']
|
||||
const c = addCourse([{ id: 3, name: 'Main', color: 'A' }], pal, id => `Course ${id}`)
|
||||
assert.deepEqual(c[1], { id: 4, name: 'Course 4', color: 'B' })
|
||||
assert.deepEqual(move([1, 2, 3], 0, 2), [2, 3, 1])
|
||||
assert.deepEqual(move([1, 2, 3], 0, -1), [1, 2, 3])
|
||||
assert.equal(nextColour(pal, 'B'), 'A')
|
||||
assert.equal(nextColour(pal, 'Z'), 'A')
|
||||
assert.deepEqual(cleanNotes([' Χωρίς αλάτι ', '', 'Χωρίς αλάτι', 'Extra']), ['Χωρίς αλάτι', 'Extra'])
|
||||
})
|
||||
|
||||
test('table colours: merged with the defaults, parsed and built', () => {
|
||||
const defaults = { light: { free: { cardBg: '#111111', nameText: '#222222' } }, dark: { free: { cardBg: '#333333' } } }
|
||||
const merged = mergeColours({ light: { free: { cardBg: '#abcdef' } } }, defaults)
|
||||
assert.deepEqual(merged, { light: { free: { cardBg: '#abcdef', nameText: '#222222' } }, dark: { free: { cardBg: '#333333' } } })
|
||||
assert.equal(setSlot(merged, 'dark', 'free', 'cardBg', '#000000').dark.free.cardBg, '#000000')
|
||||
assert.equal(merged.dark.free.cardBg, '#333333') // not changed in place
|
||||
assert.deepEqual(parseColour('rgba(255,255,255,0.92)'), { hex: '#ffffff', alpha: 0.92 })
|
||||
assert.deepEqual(parseColour('#FFF'), { hex: '#ffffff', alpha: 1 })
|
||||
assert.equal(parseColour('teal'), null)
|
||||
assert.equal(buildColour('#ff8f60', 1), '#ff8f60')
|
||||
assert.equal(buildColour('#ff8f60', 0.5), 'rgba(255,143,96,0.50)')
|
||||
assert.equal(buildColour('#ff8', 1), null)
|
||||
})
|
||||
|
||||
test('fiscal: VAT groups and the receipt end lines', () => {
|
||||
assert.deepEqual(cleanVatGroups([{ machine_id: ' 1 ', friendly_name: ' Food ' }, { machine_id: '1', friendly_name: 'Again' },
|
||||
{ machine_id: '', friendly_name: 'No id' }, { machine_id: '2', friendly_name: '' }, { machine_id: '3', friendly_name: 'Drinks' }]),
|
||||
[{ machine_id: 1, friendly_name: 'Food' }, { machine_id: 3, friendly_name: 'Drinks' }])
|
||||
assert.deepEqual(endLines('["THANK YOU"]'), ['THANK YOU', '', '', '', ''])
|
||||
assert.deepEqual(endLines('bad'), ['', '', '', '', ''])
|
||||
})
|
||||
|
||||
test('export files, the pairing link, the LAN address, uptime', () => {
|
||||
const cat = { bundle: 'catalog', data: { categories: [{ products: [1, 2] }, { products: [3] }], uncategorized_products: [4] } }
|
||||
assert.deepEqual(bundleSummary(cat, 'catalog'), { groups: 2, items: 4 })
|
||||
assert.equal(bundleSummary(cat, 'tables'), null)
|
||||
assert.deepEqual(bundleSummary({ bundle: 'tables', data: { table_groups: [{ tables: [1, 2] }], ungrouped_tables: [3] } }, 'tables'), { groups: 1, items: 3 })
|
||||
assert.equal(waiterPairUrl('192.168.1.5', 'S1', 'abc'), 'http://192.168.1.5/?pair=S1&k=abc')
|
||||
assert.equal(waiterPairUrl('192.168.1.5'), 'http://192.168.1.5/')
|
||||
assert.deepEqual(lanAddress({ lan_ip: '10.0.0.2', lan_ip_info: { source: 'override' } }, 'x'), { ip: '10.0.0.2', source: 'override' })
|
||||
assert.deepEqual(lanAddress({}, '192.168.1.9'), { ip: '192.168.1.9', source: 'browser' })
|
||||
assert.deepEqual(lanAddress({}, 'localhost'), { ip: null, source: null })
|
||||
assert.deepEqual(uptime(90061), { days: 1, h: 1, m: 1 })
|
||||
})
|
||||
@@ -15,6 +15,7 @@ const v2 = JSON.parse(readFileSync(path.join(ROOT, 'v2.json'), 'utf8'))
|
||||
const DATA = new Set([
|
||||
'src/pages/signage/signageLogic.js', 'src/pages/signage/SignageFields.jsx', 'src/pages/signage/SlideEditor.jsx',
|
||||
'src/pages/signage/MenuEditor.jsx', 'src/pages/platform/DeviceConfigFields.jsx', 'src/pages/products/categoryColours.js',
|
||||
'src/pages/Settings/sections/venueColours.js',
|
||||
])
|
||||
const GREEK = /[Ͱ-Ͽἀ-]/
|
||||
const COLOUR = [
|
||||
|
||||
Reference in New Issue
Block a user