feat(waiter): English-first texts, part c: shift, log, chat, offline, notifications; language switch; guard (platform-v2 step 4.5c)

- Shift overview, order log, chat list / thread, offline + server search +
  rediscovery screens, notifications, the refused-lines sheet and the offline queue's
  reasons become keys; times and dates through useFormat() in the venue's clock.
- User menu: the other language(s) (data-testid menu-language-<lng>), saved to the
  person's profile (PATCH /api/auth/me) and the bootstrap reloaded (D-12).
- tests/no-greek.test.mjs: no Greek letter in waiter_pwa/src (the one Greek word the
  app recognises in staff messages is a \u escape).
- e2e: the test venue is English: waiter / browser / android use the English texts;
  waiter.mjs +3 (English by default, switch to Greek at once and saved, after reload);
  android bundle checks print what they saw when they fail.
- Pack README: the waiter texts rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 04:31:48 +02:00
co-authored by Claude Opus 5.5
parent 2c4f78af47
commit f8d91e7fae
16 changed files with 493 additions and 201 deletions
+25 -23
View File
@@ -54,28 +54,28 @@ async function basics() {
let v = await freshApp()
await typeInto(v, `${H}:9999`)
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(6500)
r.check('wrong address → "no server" error', (await v.evaluate('document.body.innerText')).includes('Δεν βρέθηκε server'))
r.check('wrong address → "no server" error', (await v.evaluate('document.body.innerText')).includes('No server found'))
await typeInto(v, `http://${H}:8055/?pair=some-other-site`)
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(3000)
r.check("another venue's QR → refused", (await v.evaluate('document.body.innerText')).includes('διαφορετικό κατάστημα'))
r.check("another venue's QR → refused", (await v.evaluate('document.body.innerText')).includes('A different venue'))
await typeInto(v, `${H}:8055`)
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(5000)
v = await attach()
const st = await venuesState(v)
r.check('pairing saves and activates the venue', st?.active === 'test-site-1' && st.venues['test-site-1'].baseUrl.includes(`${H}:`), JSON.stringify(st))
r.check('login screen shows the venue + "Αλλαγή"', (await v.evaluate('document.body.innerText')).includes('Αλλαγή'))
r.check('login screen shows the venue + "Change"', (await v.evaluate('document.body.innerText')).includes('Change'))
// 4.2: a real sign-in in the native app: pick your name, PIN on the pad, start the shift
await fetch(`${b1.url}/api/business-day/open`, { method: 'POST', headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` }, body: '{}' }).catch(() => {})
await tap(v, '[data-testid="waiter-card"]', 'Κωνσταντίνου')
for (const d of '3302') await tap(v, 'button.pin-btn', d)
await tap(v, 'button', 'Έναρξη Βάρδιας', { timeout: 15_000 })
await tap(v, 'button', 'Start shift', { timeout: 15_000 })
await waitFor(() => v.evaluate("location.pathname === '/tables'"), 15_000, 500)
await sleep(3000)
r.check('signed in with name + PIN on the pad: /tables', (await v.evaluate('location.pathname')) === '/tables'
@@ -86,7 +86,7 @@ async function basics() {
// 4.2: lock from the menu, unlock with the PIN on the pad (same session)
const before = await v.evaluate("localStorage.getItem('xenia:test-site-1:token')")
await tap(v, 'button[title="Μενού χρήστη"]')
await tap(v, '[data-testid="user-menu"]')
await tap(v, '[data-testid="menu-lock"]')
const lockedOk = await waitFor(() => v.evaluate("!!document.querySelector('[data-testid=lock-screen]')"), 5000, 300)
for (const d of '3302') await tap(v, '[data-testid="lock-screen"] button.pin-btn', d)
@@ -102,9 +102,9 @@ async function basics() {
r.check('restart: still paired and logged in', (await v.evaluate('location.pathname')) === '/tables')
// venues
await tap(v, 'button[title="Μενού χρήστη"]')
await tap(v, '[data-testid="user-menu"]')
await sleep(600)
await tap(v, 'button.user-menu-item', 'Κατάστημα')
await tap(v, 'button.user-menu-item', 'Venue')
await sleep(1200)
r.check('user menu → /venues', (await v.evaluate('location.pathname')) === '/venues')
back()
@@ -113,14 +113,14 @@ async function basics() {
await goTo(v, '/venues')
await sleep(1000)
await typeInto(v, `${H}:8056`)
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(5000)
v = await attach()
let vs = await venuesState(v)
r.check('second venue paired and active', vs.active === 'test-site-2' && Object.keys(vs.venues).length === 2)
const path2 = await v.evaluate('location.pathname')
r.check('second venue starts logged out (own session)', path2 === '/login', `${path2} ${JSON.stringify(vs)}`)
await tap(v, 'button', 'Αλλαγή')
await tap(v, 'button', 'Change')
await sleep(1200)
await tap(v, 'button', `${H}:8055`)
await sleep(5000)
@@ -139,14 +139,14 @@ async function basics() {
v = await relaunch()
await goTo(v, '/venues')
await sleep(1000)
await tap(v, 'button', 'Σάρωση QR')
await tap(v, 'button', 'Scan QR')
await sleep(2500)
r.check(`camera ${label}: permission prompt shown`, /GrantPermissions/.test(focusedWindow()))
tapDialogButton(button)
await sleep(label === 'deny' ? 2000 : 4000)
if (label === 'deny') {
r.check('camera deny: asked only once', !/GrantPermissions/.test(focusedWindow()))
r.check('camera deny: explains the missing permission', (await v.evaluate('document.body.innerText')).includes('Δεν δόθηκε άδεια κάμερας'))
r.check('camera deny: explains the missing permission', (await v.evaluate('document.body.innerText')).includes("Camera permission wasn't given"))
} else {
const video = await v.evaluate("(() => { const x = document.querySelector('video'); return { ready: x.readyState, w: x.videoWidth, paused: x.paused } })()")
r.check('camera allow: live preview', video.ready >= 2 && video.w > 0 && !video.paused, JSON.stringify(video))
@@ -219,8 +219,8 @@ async function rediscovery() {
const offlineShown = await onScreen(async vv => (await vv.evaluate('location.pathname')) === '/offline', 45_000)
r.check('server really down: saved address untouched', (await venuesState(v)).venues['test-site-1'].baseUrl.includes('.99:'))
r.check('server really down: offline screen', !!offlineShown, await v.evaluate('location.pathname + " | " + document.body.innerText.slice(0, 200)').catch(e => String(e)))
await v.evaluate("[...document.querySelectorAll('button')].find(e => e.textContent.includes('Αναζήτηση server')).click()")
const notFound = await waitFor(async () => (await v.evaluate('document.body.innerText')).includes('Ο server δεν βρέθηκε'), 60_000)
await v.evaluate("[...document.querySelectorAll('button')].find(e => e.textContent.includes('Search the network')).click()")
const notFound = await waitFor(async () => (await v.evaluate('document.body.innerText')).includes("The server wasn't found"), 60_000)
r.check('manual search ends with "not found" guidance', !!notFound)
// cold start while the server is down keeps the login
@@ -272,11 +272,11 @@ server { listen 443 ssl; ssl_certificate /t/cert.pem; ssl_certificate_key /t/key
// ── TLS ───────────────────────────────────────────────────────────────────
let v = await freshApp()
await typeInto(v, qr('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='))
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(4000)
r.check('TLS: QR with a wrong key → refused', (await v.evaluate('document.body.innerText')).includes('κλειδί ασφαλείας'))
r.check('TLS: QR with a wrong key → refused', (await v.evaluate('document.body.innerText')).includes('security key'))
await typeInto(v, qr(pin))
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
await sleep(6000)
v = await attach()
let ven = (await venuesState(v)).venues['test-site-1']
@@ -344,7 +344,8 @@ server { listen 443 ssl; ssl_certificate /t/cert.pem; ssl_certificate_key /t/key
serve({ ...manifest, version: 'e2e-new-apk', min_shell_build: 99 })
await bgAndBack(); await sleep(8000); v = await attach()
r.check('bundles: needs a newer APK → skipped + banner', (await current()) === 'e2e-staged' && (await v.evaluate('document.body.innerText')).includes('νεότερη έκδοση της εφαρμογής'))
const newer = { cur: await current(), text: await v.evaluate('document.body.innerText').catch(e => String(e)) }
r.check('bundles: needs a newer APK → skipped + banner', newer.cur === 'e2e-staged' && newer.text.includes('needs a newer version of the app'), `${newer.cur} | ${newer.text.replace(/\s+/g, ' ').slice(0, 160)}`)
const broken = zipSync({ 'index.html': strToU8('<!doctype html><html><body><h1>broken bundle</h1></body></html>') })
execFileSync('docker', ['exec', '-i', WAITER1, 'sh', '-c', `cat > ${DL}/waiter-bundle-broken.zip`], { input: Buffer.from(broken) })
@@ -354,9 +355,10 @@ server { listen 443 ssl; ssl_certificate /t/cert.pem; ssl_certificate_key /t/key
await bgAndBack()
await waitFor(async () => { v = await attach(); return (await v.evaluate('document.body.innerText')).includes('broken bundle') }, 40_000, 1500)
const rolledBack = await waitFor(async () => { v = await attach(); return (await current()) === 'e2e-staged' }, 60_000, 2000)
r.check('bundles: broken bundle rolled back automatically', !!rolledBack)
r.check('bundles: broken bundle rolled back automatically', !!rolledBack, String(await current()))
await sleep(70000); await bgAndBack(); await sleep(12000); v = await attach()
r.check('bundles: no retry loop, broken version blocklisted', (await current()) === 'e2e-staged' && (await v.evaluate("localStorage.getItem('xenia.bundleFailed') || ''")).includes('e2e-broken'))
const after = { cur: await current(), failed: await v.evaluate("localStorage.getItem('xenia.bundleFailed') || ''").catch(e => String(e)) }
r.check('bundles: no retry loop, broken version blocklisted', after.cur === 'e2e-staged' && after.failed.includes('e2e-broken'), JSON.stringify(after))
serve(manifest)
// ── two venues, each on its own bundle ─────────────────────────────────────
@@ -366,7 +368,7 @@ server { listen 443 ssl; ssl_certificate /t/cert.pem; ssl_certificate_key /t/key
v = await attach()
await goTo(v, '/venues'); await sleep(1200)
await typeInto(v, `http://${H}:28080/?${new URLSearchParams({ pair: 'test-site-2', k: pin2 })}`)
await tap(v, 'button', 'Σύνδεση')
await tap(v, 'button', 'Connect')
v.close()
let s = await waitFor(async () => { const st = await state(); return st.active === 'test-site-2' && st.current === m2.version && st }, 90_000, 2000)
r.check('bundles: pairing venue 2 → venue 2 bundle', !!s)
+7 -7
View File
@@ -75,7 +75,7 @@ try {
// ── Install-app dialog + drawer entry ─────────────────────────────────────
const r2 = reporter('browser: install-app dialog')
const phone = ua => browser.newContext({ userAgent: ua, viewport: { width: 393, height: 852 }, deviceScaleFactor: 2.75, isMobile: true, hasTouch: true })
const dialog = page => page.getByRole('dialog', { name: 'Εφαρμογή Xenia' })
const dialog = page => page.getByRole('dialog', { name: 'The Xenia app' })
const hamburger = page => page.locator('button').filter({ has: page.locator('svg') }).first()
let ctx = await phone(ANDROID_UA)
@@ -85,21 +85,21 @@ try {
r2.check('first visit on Android: dialog opens by itself', await dialog(page).isVisible())
const box = await dialog(page).boundingBox()
r2.check('dialog is taller than wide', box && box.height > box.width, box ? `${Math.round(box.width)}×${Math.round(box.height)}` : '')
r2.check('download link points at the APK', (await page.getByRole('link', { name: 'Λήψη εφαρμογής' }).getAttribute('href')) === '/downloads/xenia-waiter.apk')
r2.check('download link points at the APK', (await page.getByRole('link', { name: 'Download the app' }).getAttribute('href')) === '/downloads/xenia-waiter.apk')
await page.screenshot({ path: path.join(OUT, 'install-dialog.png') })
await page.getByRole('button', { name: 'Όχι τώρα' }).click()
await page.getByRole('button', { name: 'Not now' }).click()
await sleep(400)
await page.reload()
await sleep(3500)
r2.check('"Όχι τώρα" → never opens by itself again', !(await dialog(page).isVisible()))
r2.check('"Not now" → never opens by itself again', !(await dialog(page).isVisible()))
await page.evaluate(t => localStorage.setItem('token', t), token)
await page.goto(`http://${LAN}:15173/tables`)
await sleep(4000)
await hamburger(page).click()
await sleep(600)
const install = page.getByRole('button', { name: 'Εγκατάσταση εφαρμογής' })
const install = page.getByRole('button', { name: 'Install the app' })
const [ib, sb] = [await install.boundingBox(), await page.getByRole('button', { name: 'Settings' }).boundingBox()]
r2.check('drawer shows "Εγκατάσταση εφαρμογής" right above Settings', !!(ib && sb && ib.y < sb.y && sb.y - ib.y < 80))
r2.check('drawer shows "Install the app" right above Settings', !!(ib && sb && ib.y < sb.y && sb.y - ib.y < 80))
await install.click()
await sleep(500)
r2.check('drawer entry reopens the dialog', await dialog(page).isVisible())
@@ -115,7 +115,7 @@ try {
const noDialog = !(await dialog(page).isVisible())
await hamburger(page).click()
await sleep(500)
r2.check(`${label}: never offered (no dialog, no drawer entry)`, noDialog && !(await page.getByRole('button', { name: 'Εγκατάσταση εφαρμογής' }).isVisible()))
r2.check(`${label}: never offered (no dialog, no drawer entry)`, noDialog && !(await page.getByRole('button', { name: 'Install the app' }).isVisible()))
await ctx.close()
}
ctx = await phone(ANDROID_UA)
+29 -12
View File
@@ -15,7 +15,7 @@ const vite = await startViteNative({ port: 5181, backendUrl: backend.url })
const APP = 'http://localhost:5181'
const TOKEN_KEY = 'xenia:dev:token'
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4)')
const r = reporter('waiter: sign-in v2, lock, approvals (4.2), keys (4.3), server prices (4.4), languages (4.5)')
const errors = []
let failures = 0
@@ -77,7 +77,7 @@ try {
r.check('the session is a "waiter" session', sessions.some(s => s.username === 'demo_maria' && s.client === 'waiter'), JSON.stringify(sessions.map(s => [s.username, s.client])))
// start the shift on the phone (the gate after sign-in)
await a.getByRole('button', { name: /Έναρξη Βάρδιας/ }).click({ timeout: 10_000 }).catch(() => {})
await a.getByRole('button', { name: /Start shift/ }).click({ timeout: 10_000 }).catch(() => {})
await a.waitForURL(u => u.pathname.startsWith('/tables'), { timeout: 10_000 }).catch(() => {})
await sleep(1500)
@@ -94,7 +94,7 @@ try {
// ── Lock from the menu, wrong PIN, right PIN (same session) ────────────────
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
await a.getByTestId('menu-lock').click()
r.check('menu "Κλείδωμα" locks the phone', await shown(a, 'lock-screen', 5000))
r.check('menu "Lock" locks the phone', await shown(a, 'lock-screen', 5000))
await a.reload()
r.check('still locked after the app is reopened', await shown(a, 'lock-screen', 10_000))
await pin(a, '0000')
@@ -132,9 +132,9 @@ try {
await sleep(800)
const sheet = await a.locator('.modal-sheet--top').innerText().catch(() => '')
r.check('4.3: the actions follow the keys (transfer yes, discount hidden, cancel "with a manager\'s PIN")',
sheet.includes('Μεταφορά Τραπεζιού') && !sheet.includes('Εφαρμογή Έκπτωσης') && sheet.includes('Με έγκριση διαχειριστή'), sheet.replace(/\s+/g, ' ').slice(0, 300))
await a.getByText('Ακύρωση Παραγγελίας', { exact: true }).click()
await a.getByRole('button', { name: 'Ακύρωση ✕' }).click()
sheet.includes('Transfer the table') && !sheet.includes('Apply a discount') && sheet.includes("With a manager's approval"), sheet.replace(/\s+/g, ' ').slice(0, 300))
await a.getByText('Cancel order', { exact: true }).click()
await a.getByRole('button', { name: 'Cancel ✕' }).click()
const dlg = a.getByRole('dialog')
await dlg.waitFor({ timeout: 10_000 }).catch(() => {})
r.check('4.3: cancelling from the screen opens the approval dialog', await a.getByTestId('override-key').textContent().catch(() => '') === 'ordering.orders.cancel')
@@ -192,10 +192,10 @@ try {
const exact = await waitFor(async () => await total().getAttribute('data-estimated') === 'false', 10_000, 300)
const shownTotal = await total().innerText().catch(() => '')
r.check('4.4: the cart total is the server\'s price (a price the phone\'s menu doesn\'t know)', !!exact && shownTotal.includes('2.40'), shownTotal.replace(/\s+/g, ' '))
await a.getByRole('button', { name: /^(ΑΠΟΣΤΟΛΗ|ΣΥΝΟΨΗ)/ }).last().click()
await a.getByRole('button', { name: /^(SEND|SUMMARY)/ }).last().click()
if (await shown(a, 'summary-total', 3000)) {
r.check('4.4: the summary shows the same total', (await a.getByTestId('summary-total').innerText()).includes('2.40'))
await a.getByRole('button', { name: /ΑΠΟΣΤΟΛΗ/ }).last().click()
await a.getByRole('button', { name: /SEND/ }).last().click()
}
const sent = await waitFor(async () => {
const st = await api('GET', `/api/tables/${t4.id}/status`, { token: boss })
@@ -212,7 +212,7 @@ try {
await addOn(t5.id, plain)
await ctxA.setOffline(true)
await a.getByTestId('cart-open').click()
const wentOffline = await waitFor(async () => (await total().innerText().catch(() => '')).includes('χωρίς σύνδεση'), 30_000, 1000)
const wentOffline = await waitFor(async () => (await total().innerText().catch(() => '')).includes('offline'), 30_000, 1000)
const est = await total().getAttribute('data-estimated').catch(() => null)
r.check('4.4: offline the cart total is an estimate (≈, the menu prices)', !!wentOffline && est === 'true'
&& (await total().innerText()).includes('≈'), `${wentOffline} ${est} ${await total().innerText().catch(() => '')}`)
@@ -220,8 +220,8 @@ try {
await sleep(500)
await addOn(t5.id, other)
await a.getByTestId('cart-open').click()
await a.getByRole('button', { name: /^(ΑΠΟΣΤΟΛΗ|ΣΥΝΟΨΗ)/ }).last().click()
if (await shown(a, 'summary-total', 3000)) await a.getByRole('button', { name: /ΑΠΟΣΤΟΛΗ/ }).last().click()
await a.getByRole('button', { name: /^(SEND|SUMMARY)/ }).last().click()
if (await shown(a, 'summary-total', 3000)) await a.getByRole('button', { name: /SEND/ }).last().click()
await sleep(2000)
await api('PUT', `/api/products/${other.id}`, { token: boss, body: { is_available: false } })
await ctxA.setOffline(false)
@@ -244,9 +244,26 @@ try {
for (const o of [sent, synced]) if (o) await api('DELETE', `/api/orders/${o.id}`, { token: boss }).catch(() => {})
await a.goto(`${APP}/tables`)
// ── 4.5: English first; the language switch in the user menu, saved to the person ──
const navText = () => a.locator('body').innerText()
await a.goto(`${APP}/tables`)
await a.locator('.table-card, [data-testid="user-menu"]').first().waitFor({ timeout: 10_000 }).catch(() => {})
r.check('4.5: the phone runs in English (the venue language; the demo data stays Greek)', (await navText()).includes('Tables') && !(await navText()).includes('Τραπέζια'), (await navText()).replace(/\s+/g, ' ').slice(0, 300))
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
await a.getByTestId('menu-language-el').click()
const greek = await waitFor(async () => (await navText()).includes('Τραπέζια'), 8000, 300)
const me = await api('GET', '/api/auth/me', { token: tokenA })
r.check('4.5: menu → Ελληνικά: the screen turns Greek at once and it is saved for the person', !!greek && me.language === 'el', me.language)
await a.reload()
r.check('4.5: …still Greek after a reload', !!(await waitFor(async () => (await navText()).includes('Τραπέζια'), 15_000, 500)))
await a.screenshot({ path: path.join(OUT, 'waiter-greek.png') })
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
await a.getByTestId('menu-language-en').click()
await waitFor(async () => (await navText()).includes('Tables'), 8000, 300)
// ── Signing out ends the session on the server: the second phone can sign in ─
await a.getByRole('button', { name: 'demo_maria' }).first().click({ timeout: 10_000 })
await a.getByRole('button', { name: /Αποσύνδεση/ }).last().click()
await a.getByRole('button', { name: /Sign out/ }).last().click()
await a.waitForURL(u => u.pathname === '/login', { timeout: 10_000 }).catch(() => {})
await sleep(1000)
const after = await api('GET', '/api/auth/sessions', { token: boss })