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:
+29
-12
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user