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
+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)