feat(manager): the setup wizard and the shell on v2; all of src on the v2 rules (platform-v2 step 6.14b)

- setup wizard (src/pages/setup): welcome (pick the language: the wizard switches at once), the owner's account, the venue
  (kind, name, staff language, time zone), an optional lock-screen PIN, finish -> sign in; English and Greek
- shell (src/shell): AppLayout (license banner in both languages, header, lock button, idle lock / sign-out), Sidebar on a
  new 'nav' token set in @xenia/ui (light + dark), ProfileDialog (name, username, password, 4-6 digit PIN), licenseContext;
  App.jsx loads the session and the setup state with react-query (no setState in effects); the header's dead search box gone
- Management -> Tables -> List (src/pages/tables, was TablesConfigTab): zones as tabs (drag to reorder), zone name / prefix /
  colour, add many numbered on, a table's name (6 chars) / zone / seats, twice-used names flagged, off / on / delete,
  pick several to move, rename in a series or delete (says how many failed)
- the old src/ui kit, layouts/, components/Sidebar + EditProfileModal, the 'primary' palette and the .btn/.card/.input classes deleted;
  NotificationBell / UserMenuButton on tokens; @xenia/ui: nav tokens, 'scrim' in the Tailwind preset
- v2.json paths = src (the guards cover all of it); npm run lint = eslint src; argsIgnorePattern for components in JSX
- tests: shell.test.mjs (3), e2e setup.mjs (new: a fresh install through the wizard in Greek to the overview, in run-all),
  manager.mjs 'tables list' (zone, 3 tables, rename series, profile PIN, rail tokens)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 20:01:23 +02:00
co-authored by Claude Opus 5.5
parent f6fcfb7736
commit 294b769850
40 changed files with 1680 additions and 2766 deletions
+40
View File
@@ -770,6 +770,46 @@ try {
await page.getByTestId('user-menu').click()
await page.getByRole('menuitemradio', { name: 'English' }).click()
// ── 6.14b: the tables list, the profile, the shell on v2 ──────────────────────
const tl = 'tables list:'
await page.goto(`${APP}/management/tables`)
await page.getByTestId('zone-new').click()
await page.getByTestId('zone-save').click()
r.check(`${tl} a zone needs a name`, (await page.getByTestId('zone-dialog').textContent()).includes('Enter a name'))
await page.getByTestId('zone-name').fill('E2E Zone')
await page.getByTestId('zone-prefix').fill('EZ')
await page.getByTestId('zone-save').click()
const zoneTab = page.locator('[data-testid="zone-tab"]', { hasText: 'E2E Zone' })
await zoneTab.waitFor({ timeout: 8000 }).catch(() => {})
await zoneTab.click()
await page.getByTestId('tables-batch').click()
await page.getByTestId('batch-count').fill('3')
r.check(`${tl} adding many: the button says the series (EZ-1 … EZ-3)`, (await page.getByTestId('batch-save').textContent()).includes('EZ-1') && (await page.getByTestId('batch-save').textContent()).includes('EZ-3'))
await page.getByTestId('batch-save').click()
await page.locator('[data-testid="table-row"][data-name="EZ-3"]').waitFor({ timeout: 8000 }).catch(() => {})
const ezZone = (await api('GET', '/api/tables/groups', { token: boss })).find(g => g.name === 'E2E Zone')
let ezTables = (await api('GET', '/api/tables/', { token: boss })).filter(x => x.group_id === ezZone?.id)
r.check(`${tl} a zone with 3 tables EZ-1..EZ-3`, ezTables.map(x => x.label).sort().join() === 'EZ-1,EZ-2,EZ-3', JSON.stringify(ezTables.map(x => x.label)))
await page.getByTestId('tables-pick').click()
for (const row of await page.getByTestId('table-row').all()) await row.locator('input[type=checkbox]').check()
await page.getByTestId('tables-rename').click()
await page.getByTestId('rename-prefix').fill('Q')
await page.getByTestId('rename-save').click()
await page.locator('[data-testid="table-row"][data-name="Q3"]').waitFor({ timeout: 8000 }).catch(() => {})
ezTables = (await api('GET', '/api/tables/', { token: boss })).filter(x => x.group_id === ezZone?.id)
r.check(`${tl} the 3 picked tables renamed in a series (Q1..Q3)`, ezTables.map(x => x.label).sort().join() === 'Q1,Q2,Q3', JSON.stringify(ezTables.map(x => x.label)))
await page.screenshot({ path: path.join(OUT, 'manager-tables-list.png'), fullPage: true })
for (const x of ezTables) await api('DELETE', `/api/tables/${x.id}?hard=true`, { token: boss }).catch(() => {})
if (ezZone) await api('DELETE', `/api/tables/groups/${ezZone.id}`, { token: boss }).catch(() => {})
await page.getByTestId('user-menu').click()
await page.getByRole('menuitem', { name: 'Edit profile' }).click()
await page.getByTestId('profile-pin').fill('12')
await page.getByTestId('profile-pin2').fill('12')
await page.getByTestId('profile-save').click()
r.check(`${tl} the profile: a PIN of 2 digits is refused before saving`, (await page.getByTestId('profile-dialog').textContent()).includes('4 to 6 digits'))
await page.keyboard.press('Escape')
r.check(`${tl} the side rail is drawn with the nav tokens`, await page.getByTestId('sidebar').evaluate(el => getComputedStyle(el).backgroundColor) === 'rgb(17, 94, 89)')
await page.goto(`${APP}/reports/technical`)
await page.getByText('Log files', { exact: true }).click()
const today = new Date().toISOString().slice(0, 10)
+1
View File
@@ -29,6 +29,7 @@ const suites = [
['ui (@xenia/ui + @xenia/i18n)', 'node', ['ui.mjs'], E2E],
['waiter (sign-in, keys, prices, languages, history, look, bookings)', 'node', ['waiter.mjs'], E2E],
['manager (login, bootstrap, approvals)', 'node', ['manager.mjs'], E2E],
['setup (a fresh install: the wizard to the overview)', 'node', ['setup.mjs'], E2E],
['media (Media page, product photos, waiter offline photos)', 'node', ['media.mjs'], E2E],
['terminal (pairing, sign-in, states)', 'node', ['terminal.mjs'], E2E],
['signage (the player on a TV, the editor)', 'node', ['signage.mjs'], E2E],
+69
View File
@@ -0,0 +1,69 @@
// First-run setup (plan step 6.14b, "done when"): a fresh install (an empty database, no manager)
// sends the sign-in page to the setup wizard; the wizard is filled in Greek (it switches language
// at once), finishes, and the new owner signs in and reaches the overview.
// Starts its own backend (:8065, an empty data folder) and the manager (:5189).
// node setup.mjs
import path from 'node:path'
import { mkdtempSync, openSync } from 'node:fs'
import { spawn } from 'node:child_process'
import { chromium } from 'playwright'
import { BROWSER_CHANNEL, CS, OUT, reporter } from './lib/env.mjs'
import { killTree, startBackend, waitHttp } from './lib/proc.mjs'
const dataDir = mkdtempSync(path.join(OUT, 'fresh-')) // no pos.db: the backend creates it
const backend = await startBackend({ port: 8065, dataDir })
const APP = 'http://localhost:5189'
const log = openSync(path.join(OUT, 'vite-5189.log'), 'w')
const vite = spawn('npx', ['vite', '--port', '5189', '--strictPort'], {
cwd: path.join(CS, 'manager_dashboard'), shell: process.platform === 'win32', detached: process.platform !== 'win32',
stdio: ['ignore', log, log], env: { ...process.env, XENIA_BACKEND: backend.url },
})
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('setup (6.14b): a fresh install goes through the wizard, in Greek, to the overview')
const errors = []
try {
await waitHttp(APP)
const page = await browser.newPage({ locale: 'en-US' })
page.on('pageerror', e => errors.push(String(e)))
const status = await fetch(`${backend.url}/api/setup/status`).then(x => x.json())
r.check('a fresh install needs setup', status.needs_setup === true, JSON.stringify(status))
await page.goto(`${APP}/login`)
const wizard = page.getByTestId('setup-wizard')
r.check('the sign-in page sends to the wizard', await wizard.waitFor({ timeout: 60_000 }).then(() => true).catch(() => false) && new URL(page.url()).pathname === '/setup')
r.check('…in English for an English browser', (await wizard.textContent()).includes('Welcome to Xenia POS'))
await page.getByTestId('setup-lang-el').click()
r.check('choosing Ελληνικά switches the wizard at once', await page.getByText('Καλώς ήρθατε στο Xenia POS').waitFor({ timeout: 5000 }).then(() => true).catch(() => false))
await page.getByTestId('setup-start').click()
await page.getByTestId('setup-next').click()
r.check('the account step says what is missing', await wizard.getAttribute('data-step') === 'account' && (await wizard.textContent()).includes('Υποχρεωτικό'))
await page.getByTestId('setup-username').fill('olga')
await page.getByTestId('setup-full-name').fill('Όλγα Ιδιοκτήτρια')
await page.getByTestId('setup-password').fill('kalimera1')
await page.getByTestId('setup-confirm').fill('kalimera1')
await page.getByTestId('setup-next').click()
await page.getByTestId('setup-type-coffee_shop').click()
await page.getByTestId('setup-venue-name').fill('Καφέ E2E')
r.check('the venue step starts in Greek with the browser\'s time zone', await page.getByTestId('setup-language').inputValue() === 'el' && !!(await page.getByTestId('setup-timezone').inputValue()))
await page.getByTestId('setup-next').click()
await page.getByTestId('setup-pin').fill('2468')
await page.getByTestId('setup-pin-again').fill('2468')
await page.getByTestId('setup-next').click()
await page.screenshot({ path: path.join(OUT, 'setup-done.png'), fullPage: true })
await page.getByTestId('setup-finish').click()
r.check('finishing goes to the sign-in page', await page.getByTestId('login-form').waitFor({ timeout: 15_000 }).then(() => true).catch(() => false))
const boot = await fetch(`${backend.url}/api/platform/bootstrap`).then(x => x.json())
r.check('the venue is set up in Greek', boot.venue?.language === 'el', JSON.stringify(boot.venue))
await page.locator('input[type=password]').waitFor({ timeout: 10_000 })
if (!(await page.getByTestId('login-account').count())) await page.locator('input[autocomplete=username]').fill('olga') // one manager: the form shows the account
await page.locator('input[type=password]').fill('kalimera1')
await page.locator('button[type=submit]').click()
r.check('the new owner signs in and reaches the overview', await page.getByTestId('overview').waitFor({ timeout: 20_000 }).then(() => true).catch(() => false))
await page.screenshot({ path: path.join(OUT, 'setup-overview.png'), fullPage: true })
r.check('the setup is done (no second owner can be made)', (await fetch(`${backend.url}/api/setup/status`).then(x => x.json())).needs_setup === false)
r.check('no page errors', errors.length === 0, errors.slice(0, 3).join(' | '))
} finally {
await browser.close()
killTree(vite)
await backend.stop()
}
process.exit(r.done() ? 1 : 0)