Files
xenia-pos-local/tests/e2e/manager_layout.mjs
T
bonaminandClaude Opus 5.5 33a5125abc feat(manager): Settings full width with its cards in columns, tabs that wrap instead of hiding
Owner 2026-11-23 (plan 6F.0): Settings was the only 880 px page and its 11 tabs scrolled out of
sight ('Operatio...'). Now full width like every page; each tab's cards sit in the new @xenia/ui
<Columns> (cards flow down then across, 34rem columns: two on 1080p, three on an ultrawide, one on a
laptop), settings rows keep switches at the right edge. Tabs everywhere wrap onto another row when
they don't fit. manager_layout e2e: Settings tabs, a 1366x768 screen, every tab visible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 06:24:44 +02:00

143 lines
9.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The page rule (2026-11-20): every manager page is a <Page> that scrolls on its own, fills a
// 1080p screen and stays at 2200 px (never narrowed by a short window), centred, on an ultrawide. For each page, at 1920×1080
// and 3440×1440: the page body exists, fills the content area (1080p) or is capped and centred
// (ultrawide), and the page scrolls when its content is taller than the screen. Screenshots of a
// few key screens (and the open dropdowns / the day summary) go to out/manager-layout/.
//
// node manager_layout.mjs
//
// Starts its own backend (:8067, demo data) and the manager (:5191).
import { mkdirSync, openSync } from 'node:fs'
import path from 'node:path'
import { spawn } from 'node:child_process'
import { chromium } from 'playwright'
import { BROWSER_CHANNEL, CS, OUT, reporter, sleep } from './lib/env.mjs'
import { killTree, login, startBackend, waitHttp } from './lib/proc.mjs'
const DIR = path.join(OUT, 'manager-layout')
mkdirSync(DIR, { recursive: true })
// pages on <Page> (all but the stock placeholder, 2026-11-20)
const PAGES = [
'dashboard', 'tables', 'tables?view=qr', 'online-orders', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers',
'financials/expenses', 'financials/tabs', 'management/media', 'management/signage', 'management/staff', 'management/sessions',
'management/approvals', 'management/schedule', 'management/prep-zones', 'management/pricing', 'management/pricing?tab=channels',
'management/products', 'management/tables', 'management/tables?tab=floor', 'management/scenes', 'management/signage?tab=playlists', 'management/signage?tab=schedules', 'inventory/throwaways', 'notes',
'reports/today', 'reports/store', 'devices', 'license', 'apps', 'settings?tab=operation',
'settings?tab=security', 'settings?tab=identity', 'settings?tab=print-fonts', 'settings?tab=venue',
]
const SHOTS = ['dashboard', 'tables', 'tables?view=qr', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers', 'financials/expenses',
'management/products', 'management/tables?tab=floor', 'management/pricing?tab=channels', 'financials/tabs', 'management/staff', 'settings?tab=operation']
const SCREENS = [{ id: '1080p', width: 1920, height: 1080 }, { id: 'ultrawide', width: 3440, height: 1440 }, { id: 'laptop', width: 1366, height: 768 }]
const MODULES = ['connect_orders', 'connect_menu', 'crm', 'tabs', 'expenses', 'inventory', 'notes', 'chat', 'reservations', 'pricing', 'signage', 'staff_planning']
const backend = await startBackend({ port: 8067, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
const APP = 'http://localhost:5191'
const log = openSync(path.join(OUT, 'vite-5191.log'), 'w')
const vite = spawn('npx', ['vite', '--port', '5191', '--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('manager layout (the page rule): fills 1080p, 2200 px and centred on ultrawides, scrolls')
const name = p => p.replace(/[/?=]/g, '-')
try {
await waitHttp(APP)
const boss = await login(backend.url)
const call = (method, url, body) => fetch(`${backend.url}${url}`, { method, headers: { 'content-type': 'application/json', authorization: `Bearer ${boss}` }, body: body ? JSON.stringify(body) : undefined })
for (const m of MODULES) await call('PUT', `/api/platform/modules/${m}`, { enabled: true }).catch(() => {})
await call('POST', '/api/business-day/open', {}).catch(() => {})
const errors = []
for (const screen of SCREENS) {
const ctx = await browser.newContext({ viewport: { width: screen.width, height: screen.height } })
const page = await ctx.newPage()
page.on('pageerror', e => errors.push(String(e)))
await page.goto(`${APP}/login`)
await page.getByTestId('login-form').waitFor({ timeout: 60_000 })
if (!(await page.getByTestId('login-account').count())) await page.getByLabel('Username').fill('manager')
await page.getByLabel('Password').fill('password')
await page.getByRole('button', { name: 'Sign in', exact: true }).click()
await page.waitForURL(u => u.pathname === '/dashboard', { timeout: 20_000 })
const bad = []
for (const p of PAGES) {
await page.goto(`${APP}/${p}`)
await page.waitForLoadState('networkidle').catch(() => {})
await sleep(500)
const m = await page.evaluate(() => {
const body = document.querySelector('main .x-page__body')
const main = document.querySelector('main')
if (!body || !main) return null
const scroll = body.closest('.x-page__scroll')
// the area: the scroller without its scrollbar's room (kept on every page, 2026-11-21)
const b = body.getBoundingClientRect(); const s = scroll.getBoundingClientRect()
const a = { left: s.left, right: s.left + scroll.clientWidth, width: scroll.clientWidth }
// a form page (width="form": none left since 6F.0) is centred at its own width
const form = body.classList.contains('x-page__body--form')
return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: 2200,
scrolls: scroll.scrollHeight <= scroll.clientHeight + 1 || getComputedStyle(scroll).overflowY === 'auto' }
})
if (!m) { bad.push(`${p}: no <Page>`); continue }
const centred = Math.abs(m.left - m.right) <= 2
const fills = m.form || m.width >= Math.min(m.area, m.cap) - 2
if (!centred || !fills || !m.scrolls) bad.push(`${p}: ${JSON.stringify(m)}`)
if (SHOTS.includes(p)) await page.screenshot({ path: path.join(DIR, `${name(p)}-${screen.id}.png`) })
}
r.check(`${screen.id}: every page fills its area up to 2200 px, centred, and scrolls`, bad.length === 0, bad.join('\n'))
// Settings (6F.0, owner 2026-11-23): full width like every page, and every tab's button inside
// the window (tabs that don't fit wrap onto another row, never hidden in a sideways scroll)
await page.goto(`${APP}/settings`)
await page.getByTestId('settings-page').waitFor()
const tabsIn = await page.evaluate(() => [...document.querySelectorAll('[data-testid^="settings-tab-"]')]
.map(e => { const b = e.getBoundingClientRect(); return { id: e.dataset.testid, in: b.left >= 0 && b.right <= innerWidth && b.width > 0 } }))
r.check(`${screen.id}: settings: every tab is visible (${tabsIn.length})`, tabsIn.length >= 8 && tabsIn.every(x => x.in),
JSON.stringify(tabsIn.filter(x => !x.in)))
// Products (2026-11-21): the page doesn't scroll, its two panes do, each on its own
await page.goto(`${APP}/management/products`)
await page.getByTestId('products-panel').waitFor()
const panes = await page.evaluate(() => {
const scroll = document.querySelector('main .x-page__scroll')
const bodies = [...document.querySelectorAll('main .x-pane__body')].map(e => getComputedStyle(e).overflowY)
const tree = document.querySelector('[data-testid="category-tree"]').getBoundingClientRect()
const list = document.querySelector('[data-testid="products-panel"]').getBoundingClientRect()
return { page: getComputedStyle(scroll).overflowY, bodies, sameTop: Math.abs(tree.top - list.top) < 1, fits: list.bottom <= innerHeight + 1 }
})
r.check(`${screen.id}: products: two panes that scroll on their own, the page fixed`,
panes.page === 'hidden' && panes.bodies.length === 2 && panes.bodies.every(o => o === 'auto') && panes.sameTop && panes.fits, JSON.stringify(panes))
if (screen.id === '1080p') {
// the shared dropdown: multi-select, same height as the search box
await page.goto(`${APP}/financials/expenses`)
const search = page.locator('.x-search input')
await search.waitFor()
const hs = await search.boundingBox()
const dd = page.getByTestId('expenses-status')
const hd = await dd.boundingBox()
r.check('expenses: dropdowns are as tall as the search box', Math.abs(hs.height - hd.height) < 1, `${hs.height} vs ${hd.height}`)
await dd.click()
await page.locator('.x-dropdown__menu').waitFor()
await page.screenshot({ path: path.join(DIR, 'expenses-dropdown-open.png') })
await page.keyboard.press('Escape')
// the day summary
await page.goto(`${APP}/dashboard`)
await page.getByTestId('day-stats').click()
await page.getByTestId('day-summary').waitFor()
await sleep(400)
const tabsScroll = await page.evaluate(() => { const l = document.querySelector('.x-dialog .x-tabs__list'); return l.scrollHeight - l.clientHeight })
r.check('day summary: the tab strip has no up/down scroll', tabsScroll === 0, String(tabsScroll))
await page.screenshot({ path: path.join(DIR, 'day-summary.png') })
await page.getByTestId('day-tab-staff').click()
await sleep(300)
await page.screenshot({ path: path.join(DIR, 'day-summary-staff.png') })
}
await ctx.close()
}
r.check('no page errors', errors.length === 0, errors.slice(0, 3).join(' | '))
console.log(` screenshots: ${DIR}`)
} finally {
await browser.close()
killTree(vite)
await backend.stop()
}
process.exit(r.done() ? 1 : 0)