diff --git a/docs/README.md b/docs/README.md index 9d53d4d..58ccb11 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,7 +54,9 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r | `waiter_pwa/src/native/pairing.js`, `src/pages/VenuesPage.jsx` | Pairing with a venue (QR / typed address) and the venue switcher | | `waiter_pwa/src/api/client.js`, `src/api/bootstrapCache.js`, `src/api/venueSettings.js`, `src/api/errors.js` | The waiter's client on `@xenia/api` (since 4.1): token, 401 → logout, no answer → `backend-offline`, the manager-approval retry; `` keeps the last bootstrap per venue so an offline restart stays signed in (CS-3); one shared, offline-cached read of the venue settings; `apiError(err, fallback)` shows backend error codes in the user's language | | `waiter_pwa/src/context/LiveContext.jsx`, `src/hooks/useWebSocket.js` | Real-time lifecycle, event → store/cache updates, visibility refresh; the socket itself is `createLiveClient` from `@xenia/api` | -| `waiter_pwa/src/db/posdb`, `src/services/offlineOrders` | Offline cache and queued orders | +| `waiter_pwa/src/db/posdb`, `src/services/offlineOrders` | Offline cache and queued orders (lines by id, priced on sync; refused lines kept in `kv.refused_lines`, `components/RefusedLines.jsx`; 4.4) | +| `waiter_pwa/src/i18n.js`, `src/logic/colour.js`, `tests/no-greek.test.mjs`, `tests/no-colours.test.mjs` | The waiter's texts (`waiter` namespace, `tw()`, `money()`; 4.5) and colours (tokens only, `fade()`; 4.6), and the guards that keep them so | +| `waiter_pwa/src/pages/TableDetailPage.jsx`, `AddItemsPage.jsx`, `BookingsPage.jsx`, `components/TableHistory.jsx` | The table (actions by permission key 4.3, combine lines and close-with-unpaid 4.8, history 4.7), ordering (server-priced cart 4.4), bookings (4.8) | | `nginx-proxy/nginx.conf` | Proxy config used in dev / by hand | | `install.sh` | Site installer. **Writes its own copy of the proxy config.** | | `docker-compose.yml` / `docker-compose.dev.yml` | Prod (pull images) / dev override (build + expose ports) | @@ -84,8 +86,9 @@ Control frames from `routers/ws.py` (3.1a) are not stored and have no seq: `devi **CS-3. The waiter app must survive bad networks.** Waiters walk in and out of WiFi range and phones sleep. Any new waiter flow must: - work from the IndexedDB cache when offline, or clearly block with an offline state -- never lose an order that was entered (queue it) +- never lose an order that was entered (queue it): queue it **by id** (`@xenia/api` `wireLine`, step 4.4) so the server prices it when the phone is back, and show what the server refused instead of dropping it (`kv.refused_lines`, the "Not sent" sheet) - tolerate duplicate or replayed events +- never hang on a request: every request that a screen waits for has a time limit or a retry (the bootstrap: 8 s, then offline + retry; step 4.6) **CS-4. Money and prices are snapshotted.** Prices, costs and discounts are copied onto order items and logs when the action happens (snapshot pattern, `PriceEventLog`). Reports read the snapshots, never the live catalogue. diff --git a/tests/e2e/android.mjs b/tests/e2e/android.mjs index 39c9c57..7e877cf 100644 --- a/tests/e2e/android.mjs +++ b/tests/e2e/android.mjs @@ -217,7 +217,9 @@ async function rediscovery() { await backend.stop() v = await stale(v) - const offlineShown = await onScreen(async vv => (await vv.evaluate('location.pathname')) === '/offline', 45_000) + // the offline screen: its own route, or in place of the app when the start-up data can't load (4.6) + const offlineShown = await onScreen(async vv => (await vv.evaluate('location.pathname')) === '/offline' + || (await vv.evaluate("!!document.querySelector('#root') && document.body.innerText.includes('Search the network')")), 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('Search the network')).click()") diff --git a/tests/e2e/run-all.mjs b/tests/e2e/run-all.mjs index fc98f14..3197655 100644 --- a/tests/e2e/run-all.mjs +++ b/tests/e2e/run-all.mjs @@ -23,7 +23,7 @@ const suites = [ ['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E], ['browser', 'node', ['browser.mjs'], E2E], ['ui (@xenia/ui + @xenia/i18n)', 'node', ['ui.mjs'], E2E], - ['waiter (sign-in, lock, approvals)', 'node', ['waiter.mjs'], E2E], + ['waiter (sign-in, keys, prices, languages, history, look, bookings)', 'node', ['waiter.mjs'], E2E], ['manager (login, bootstrap, approvals)', 'node', ['manager.mjs'], E2E], ['terminal (pairing, sign-in, states)', 'node', ['terminal.mjs'], E2E], ['order app (cloud: takeaway + delivery + bookings)', 'node', ['order_app.mjs'], E2E], diff --git a/tests/e2e/waiter.mjs b/tests/e2e/waiter.mjs index 29574f9..7aadc29 100644 --- a/tests/e2e/waiter.mjs +++ b/tests/e2e/waiter.mjs @@ -266,7 +266,8 @@ try { 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 }) + // the screen changes first, the profile is saved right after: wait for it + const me = await waitFor(async () => { const u = await api('GET', '/api/auth/me', { token: tokenA }); return u.language === 'el' && u }, 8000, 300) || {} 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)))