feat(manager): notification bell, sign-in/venue/print settings, log download (platform-v2 2.6f)

- Bell in the header: /api/platform/notifications with unread count, live via
  the new LiveProvider (one createLiveClient connection) on platform_notification
  and reconnect; mark read / all; warning+critical pop a toast.
- Settings: Sign-in card (manager/waiter/device modes, require username, one
  session per manager/waiter, username autofill) replaces the dead v1
  security.login_method card; new "Venue & language" tab (language, time zone);
  print alert threshold in Printing. Tab labels are i18n keys.
- Technical > Log files: list + download of the daily logs (owner-level).
  Backend: GET /api/system/logs, /api/system/logs/{date} (core.settings.manage),
  error system.log_not_found.
- Setup wizard asks staff language and time zone (setup/init stores them).
- @xenia/ui theme helpers (applyTheme, getStoredTheme); the manager stays light
  until phase 6 converts the older pages (owner decision 2026-11-14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 09:01:26 +02:00
co-authored by Claude Opus 5.5
parent 92bc1b0113
commit 2426ffddad
36 changed files with 995 additions and 92 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ Or run one suite at a time:
| `node install.mjs` | `install.sh`: VPN-safe `HOST_IP` detection (simulated WireGuard/WiFi hosts); fresh install, upgrade, re-run; proxy config identical to `nginx-proxy/nginx.conf` | Docker | ~1 min |
| `python license_e2e.py` | Offline licensing with a real cloud + site process: 400 days offline, tampered file, clock set back, expiry deferred to workday close, renewal, remote lock | Python deps of both backends | ~2 min |
| `node ui.mjs` | `@xenia/ui` components on the dev-only gallery (`/ui-gallery`, manager Vite :5185): dialog focus/Escape/backdrop, sheet, toasts, field wiring, switch, InfoTip, PinPad, themes; `@xenia/i18n` on `/i18n-sample` with the browser in New York: venue time, live language switch, el/en money and numbers, price input, translated component labels | Edge | ~40 s |
| `node manager.mjs` | Manager on `@xenia/api`/`@xenia/access` (backend :8057 on a demo DB, manager Vite :5186): bootstrap before/after login, wrong password and wrong lock PIN stay on screen, sidebar from keys, KDS module off → "turned off" screen, session ended elsewhere → /login, a waiter's cancel approved by a manager PIN (wrong PIN first) and audited; Apps, Integrations, License, Devices (pairing played through the API); the approvals log, "Signed in now" + end session, the staff permission editor (give, reset to role, a staff manager can't give what they lack) | Edge | ~1 min |
| `node manager.mjs` | Manager on `@xenia/api`/`@xenia/access` (backend :8057 on a demo DB, manager Vite :5186): bootstrap before/after login, wrong password and wrong lock PIN stay on screen, sidebar from keys, KDS module off → "turned off" screen, session ended elsewhere → /login, a waiter's cancel approved by a manager PIN (wrong PIN first) and audited; Apps, Integrations, License, Devices (pairing played through the API); the approvals log, "Signed in now" + end session, the staff permission editor (give, reset to role, a staff manager can't give what they lack); the notification bell (live, read, read all), sign-in/venue/print settings, log download | Edge | ~1 min |
| `node browser.mjs` | Waiter web modes (same-origin, plain HTTP by LAN IP, venue mode), install dialog + drawer entry (Android / iPhone / desktop / no APK) | Docker, Edge | ~2 min |
| `node android.mjs basics` | Pairing, wrong address / other venue's QR, login + live WS, back button, restart, two venues, camera permission | Android emulator | ~5 min |
| `node android.mjs rediscovery` | Server IP change (logged in / out), server down + manual search, cold start while offline | Android emulator | ~4 min |
+88 -2
View File
@@ -6,12 +6,12 @@
// ended session logs out), a module turned off, and the manager-approval dialog.
// node manager.mjs
import { spawn } from 'node:child_process'
import { openSync } from 'node:fs'
import { openSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { chromium } from 'playwright'
import { BROWSER_CHANNEL, CS, OUT, reporter, sleep } from './lib/env.mjs'
import { killTree, startBackend, waitHttp } from './lib/proc.mjs'
import { SUPPORT_MASTER, codeFor, siteSecret } from './lib/support.mjs'
import { SUPPORT_MASTER, codeFor, siteSecret, supportLogin } from './lib/support.mjs'
const PORT = 5186
const APP = `http://localhost:${PORT}`
@@ -430,6 +430,92 @@ try {
(await s2.getByTestId('perm-error').textContent().catch(() => '')).includes('You can only give permissions you have yourself: "See reports"'))
r.check('…and nothing was saved', !(await mariaPerms()).keys.includes('reports.view'))
// ── 2.6f: notification bell (live), settings pages, log download ───────────
await page.goto(`${APP}/dashboard`)
const bell = page.getByTestId('notif-bell')
await bell.waitFor({ timeout: 10_000 })
await page.getByTestId('notif-count').waitFor({ timeout: 8000 }).catch(() => {})
r.check('bell: unread count from the earlier support sign-ins', Number((await page.getByTestId('notif-count').textContent().catch(() => '0')).replace('+', '')) >= 1)
await bell.click()
const panel = page.getByTestId('notif-panel')
r.check('bell: the list says support signed in, in plain words', (await panel.textContent()).includes('Xenia support logged in'))
await page.getByTestId('notif-read-all').click()
await page.getByTestId('notif-count').waitFor({ state: 'detached', timeout: 5000 }).catch(() => {})
r.check('bell: "mark all as read" clears the count', await page.getByTestId('notif-count').count() === 0)
await bell.click() // close
await sleep(1500) // the live socket is up (opened with the shell)
await supportLogin(backend.url)
await page.getByTestId('notif-count').waitFor({ timeout: 8000 }).catch(() => {})
r.check('bell: a new one arrives live (no reload): count 1 and a toast',
await page.getByTestId('notif-count').textContent().catch(() => '') === '1' && await page.getByText('Xenia support logged in').count() >= 1)
await bell.click()
const unreadItem = panel.locator('[data-read="false"]').first()
await unreadItem.click()
await page.waitForFunction(() => !document.querySelector('[data-testid="notif-count"]'), null, { timeout: 5000 }).catch(() => {})
r.check('bell: opening it marks it read', await page.getByTestId('notif-count').count() === 0 &&
(await api('GET', '/api/platform/notifications', { token: boss })).unread === 0)
await page.screenshot({ path: path.join(OUT, 'manager-notifications.png') })
await page.keyboard.press('Escape')
const settingValue = async key => (await api('GET', '/api/settings/', { token: boss }))[key].value
await page.goto(`${APP}/settings`)
await page.getByText('Sign-in & security', { exact: true }).click()
const waiterMode = page.getByTestId('setting-auth.waiter_login_mode')
await waiterMode.waitFor({ timeout: 10_000 })
await waiterMode.selectOption('tap')
await page.getByRole('note').waitFor({ timeout: 5000 }).catch(() => {})
r.check('settings: waiter sign-in → "Tap your name" is saved and warns it needs paired devices',
await settingValue('auth.waiter_login_mode') === 'tap' && (await page.getByRole('note').textContent()).includes('only on paired devices'))
await waiterMode.selectOption('pin')
await page.getByTestId('setting-auth.manager_login_mode').selectOption('pin')
await sleep(800)
r.check('settings: manager sign-in → PIN reaches the sign-in page (bootstrap)',
(await api('GET', '/api/platform/bootstrap')).login.manager_mode === 'pin')
await page.screenshot({ path: path.join(OUT, 'manager-settings-sign-in.png'), fullPage: true })
await page.getByTestId('setting-auth.manager_login_mode').selectOption('password')
await page.getByTestId('setting-auth.single_session_waiter').selectOption('end_old')
await sleep(800)
r.check('settings: one session per waiter → "sign out the older one"', await settingValue('auth.single_session_waiter') === 'end_old' &&
await settingValue('auth.manager_login_mode') === 'password' && await settingValue('auth.waiter_login_mode') === 'pin')
await page.getByTestId('setting-auth.single_session_waiter').selectOption('off')
await page.getByText('Venue & language', { exact: true }).click()
const tzSelect = page.getByTestId('setting-venue.timezone')
await tzSelect.waitFor({ timeout: 10_000 })
await tzSelect.selectOption('Europe/London')
await sleep(800)
await page.getByTestId('setting-venue.language').selectOption('el')
await sleep(800)
const venue = (await api('GET', '/api/platform/bootstrap')).venue
r.check('settings: time zone and venue language saved (bootstrap says Europe/London, el)', venue.timezone === 'Europe/London' && venue.language === 'el', JSON.stringify(venue))
await page.screenshot({ path: path.join(OUT, 'manager-settings-venue.png'), fullPage: true })
await page.getByTestId('setting-venue.language').selectOption('en')
await sleep(800)
await tzSelect.selectOption('Europe/Athens')
await sleep(800)
await page.getByText('Printing', { exact: true }).click()
const alertSel = page.getByTestId('setting-print.alert_after_failures')
await alertSel.waitFor({ timeout: 10_000 })
await alertSel.selectOption('5')
await sleep(800)
r.check('settings: print alert after 5 failed attempts', await settingValue('print.alert_after_failures') === '5')
await alertSel.selectOption('2')
await sleep(500)
await page.goto(`${APP}/reports/technical`)
await page.getByText('Log files', { exact: true }).click()
const today = new Date().toISOString().slice(0, 10)
const logRow = page.getByTestId(`log-${today}`)
await logRow.waitFor({ timeout: 10_000 }).catch(() => {})
r.check("logs: today's file is listed (still being written)", (await logRow.textContent().catch(() => '')).includes('still being written'))
const [dl] = await Promise.all([page.waitForEvent('download', { timeout: 10_000 }), logRow.getByRole('button', { name: 'Download' }).click()])
const dlText = readFileSync(await dl.path(), 'utf-8')
r.check('logs: Download saves xenia-<day>.log with the backend\'s lines', dl.suggestedFilename() === `xenia-${today}.log` && dlText.includes('session.started'), dl.suggestedFilename())
await s2.goto(`${APP}/reports/technical`)
await s2.getByText('Printer history').or(s2.getByText('Ιστορικό Εκτυπωτή')).first().waitFor({ timeout: 10_000 }).catch(() => {})
r.check('logs: a staff manager has no "Log files" tab (owner-level)', await s2.getByText('Log files', { exact: true }).count() === 0)
r.check('no page errors', errors.length === 0, errors.slice(0, 3).join(' | '))
} finally {
await browser.close()
+2 -1
View File
@@ -123,7 +123,8 @@ try {
await p.screenshot({ path: path.join(OUT, 'ui-gallery-dark-amber.png'), fullPage: true })
await p.evaluate(() => { history.pushState({}, '', '/login'); dispatchEvent(new PopStateEvent('popstate')) })
await sleep(500)
r.check('theme: leaving the gallery restores <html>', await p.evaluate(() => !document.documentElement.hasAttribute('data-theme') && !document.documentElement.hasAttribute('data-venue-theme')))
// the manager sets data-theme="light" at startup (2.6f); the gallery puts that back
r.check('theme: leaving the gallery restores <html>', await p.evaluate(() => document.documentElement.getAttribute('data-theme') === 'light' && !document.documentElement.hasAttribute('data-venue-theme')))
r.check('no page or console errors', errs.length === 0, errs.slice(0, 3).join(' | '))
failures += r.done()