Files
xenia-pos-local/manager_dashboard/tests/v2-guards.test.mjs
T
bonaminandClaude Opus 5.5 5048f82a4c feat(manager): products and categories on v2, a product in several categories, allergens (platform-v2 step 6.3)
- Management/ProductsTab + ProductFormModal (3.1k lines) → src/pages/products/: category tree,
  list/grid, toolbar + filters (search folds accents and Latin letters), bulk actions, category
  dialogs; the editor in editor/ (details, sold at, cost, fiscal; the waiter's choices).
  Arithmetic in productsLogic.js / editor/formLogic.js (tests/products.test.mjs).
- Several categories per product with a main one (D-23): edited in the editor, "also in" on the
  rows, each category's list ordered on its own (drag or up/down → PUT /reorder with category_id);
  bulk "move to" / "also list in". The waiter's picker now shows a product in every category.
- Allergens: products.allergens (Alembic 0032, core/allergens.py: 14 EU, contains | may_contain,
  catalog.allergen), in the API, POS menu, menu tablet, catalogue bundles and the cloud snapshot
  (C-2); @xenia/access allergens.js + <Allergens> shown on the phone, the counter, the tablet.
- Bell: only the newest load sets the list (an older answer could hide a live notification).
- e2e: manager (two categories, order per category, allergens), terminal / menu tablet / waiter
  (allergens shown); media saves by test id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:04:35 +02:00

55 lines
2.7 KiB
JavaScript

// Plan step 6.1: the manager's pages on the v2 rules (v2.json `paths`) keep them. Texts are
// keys in @xenia/i18n (namespace `manager`), so no Greek letter in their source; colours are
// @xenia/ui tokens, so no colour value in their code. Each phase 6 step adds what it converted
// to v2.json; at the end (6.14) the list is `src`.
// Colours the venue picks for its screens (signage slides, a device's colour setting) are data,
// not styling: the files in DATA hold such defaults.
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
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',
])
const GREEK = /[Ͱ-Ͽἀ-῿]/
const COLOUR = [
/(^|[^\w&])#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?(?:[0-9a-fA-F]{2})?\b/,
/\brgba?\(\s*\d/,
/\bhsla?\(\s*\d/,
/['"](white|black)['"]/,
]
const walk = p => (statSync(p).isDirectory() ? readdirSync(p).flatMap(n => walk(path.join(p, n))) : (/\.(jsx?|css)$/.test(p) ? [p] : []))
const files = () => v2.paths.flatMap(rel => walk(path.join(ROOT, rel))).map(f => path.relative(ROOT, f).split(path.sep).join('/'))
test('every v2 path exists (v2.json is current)', () => {
assert.deepEqual(v2.paths.filter(p => !existsSync(path.join(ROOT, p))), [])
assert.deepEqual(v2.strict.filter(p => !v2.paths.some(q => p === q || p.startsWith(`${q}/`))), [], 'strict paths must be v2 paths')
})
test('no Greek text in v2 pages (texts are i18n keys)', () => {
const hits = []
for (const rel of files()) {
readFileSync(path.join(ROOT, rel), 'utf8').split('\n').forEach((line, i) => {
if (GREEK.test(line)) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 80)}`)
})
}
assert.deepEqual(hits, [], `Greek text found — make it a key in the manager namespace:\n${hits.join('\n')}`)
})
test('no colour literal in v2 pages (tokens only)', () => {
const hits = []
for (const rel of files()) {
if (DATA.has(rel)) continue
readFileSync(path.join(ROOT, rel), 'utf8').split('\n').forEach((line, i) => {
if (COLOUR.some(re => re.test(line))) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 90)}`)
})
}
assert.deepEqual(hits, [], `colour values in page code — use a token (var(--x-…) / @xenia/ui):\n${hits.join('\n')}`)
})