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:
+88
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user