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:
+25
-23
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user