feat(backend,waiter,terminal,manager): sign-in: ask before signing a waiter's other phone out, usernames on paired screens
- auth.single_session_waiter gains 'ask', the new default (Alembic 0051 moves venues on 'off'
to it): a second phone gets auth.session_elsewhere {device, since}; Continue retries with
replace=true and the first phone is signed out at once (live session.ended, reason
"replaced") and says why on its sign-in page. Only phones count (terminal sessions are
their own client). refuse_new / end_old unchanged.
- auth.session_ended now carries the reason; the waiter app keeps it until the next sign-in.
- The waiter app sends queued offline ops on every (re)connection, so an order queued on a
phone that was signed out by another goes out after the next sign-in there (e2e checked).
- auth.terminal_require_username (venue) + Device.require_username (per device, wins):
GET /api/devices/me/users lists nobody, the screen asks for a username then PIN/password,
a picked user_id is refused (auth.username_required), "tap" falls back to PIN.
- Manager: Sign-in settings (ask, the new switch), the device dialog's usernames choice.
Plan platform-v2 6F.7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+15
-5
@@ -189,7 +189,7 @@ try {
|
||||
await page.getByRole('button', { name: 'Pair a device' }).first().click()
|
||||
await dlg.getByLabel('Code shown on the device').fill('zz-zz-zz')
|
||||
await dlg.getByLabel('App to run').selectOption('kds')
|
||||
await dlg.getByLabel('Name').fill('Kitchen')
|
||||
await dlg.getByLabel('Name', { exact: true }).fill('Kitchen')
|
||||
await dlg.getByRole('button', { name: 'Pair a device' }).click()
|
||||
await page.getByTestId('pair-error').waitFor({ timeout: 5000 }).catch(() => {})
|
||||
r.check('devices: a wrong code is refused with a message', (await page.getByTestId('pair-error').textContent().catch(() => '')).includes('pairing code is wrong'))
|
||||
@@ -221,12 +221,15 @@ try {
|
||||
r.check('devices: the screen opens a live connection with its device token alone (3.1a)', await sock.ready)
|
||||
await row.getByRole('button', { name: 'Edit' }).click()
|
||||
r.check('devices: the edit dialog shows the device setting', await dlg.getByLabel('Sign out after').inputValue() === '10')
|
||||
await dlg.getByLabel('Name').fill('Kitchen 1')
|
||||
await dlg.getByLabel('Name', { exact: true }).fill('Kitchen 1')
|
||||
await dlg.getByLabel('Sign out after').selectOption('5')
|
||||
await dlg.getByTestId('device-usernames').selectOption('true') // 6F.7: this screen asks for usernames
|
||||
await dlg.getByRole('button', { name: 'Save' }).click()
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid^="device-"][data-status]')?.textContent.includes('Kitchen 1'), null, { timeout: 8000 }).catch(() => {})
|
||||
const me2 = await asDevice(deviceToken, '/api/devices/me').then(x => x.json())
|
||||
r.check('devices: renamed, setting changed', (await row.textContent()).includes('Kitchen 1') && me2.name === 'Kitchen 1' && me2.config?.auto_sign_out_minutes === 5, JSON.stringify(me2))
|
||||
r.check('6F.7: a device set to "staff type their username" lists nobody', me2.require_username === true
|
||||
&& (await asDevice(deviceToken, '/api/devices/me/users').then(x => x.json())).length === 0)
|
||||
await sleep(300)
|
||||
r.check('devices: the screen is told at once (device.updated)', sock.messages.some(m => m.type === 'device.updated'), JSON.stringify(sock.messages))
|
||||
|
||||
@@ -667,11 +670,18 @@ try {
|
||||
(await api('GET', '/api/platform/bootstrap')).login.manager_mode === 'pin')
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-settings-sign-in.png'), fullPage: true })
|
||||
await page.getByTestId('setting-auth.manager_login_mode').selectOption('password')
|
||||
const sessionDefault = await page.getByTestId('setting-auth.single_session_waiter').inputValue()
|
||||
r.check('6F.7: one session per waiter is "ask" by default', sessionDefault === 'ask', sessionDefault)
|
||||
await page.getByTestId('setting-auth.terminal_require_username').click()
|
||||
await sleep(800)
|
||||
r.check('6F.7: "staff type their username" on paired devices is saved', await settingValue('auth.terminal_require_username') === 'true')
|
||||
await page.getByTestId('setting-auth.terminal_require_username').click()
|
||||
await sleep(800)
|
||||
await page.getByTestId('setting-auth.single_session_waiter').selectOption('end_old')
|
||||
await sleep(800)
|
||||
r.check('settings: one session per waiter → "sign out the older one"', await settingValue('auth.single_session_waiter') === 'end_old' &&
|
||||
await settingValue('auth.manager_login_mode') === 'password' && await settingValue('auth.waiter_login_mode') === 'pin')
|
||||
await page.getByTestId('setting-auth.single_session_waiter').selectOption('off')
|
||||
await page.getByTestId('setting-auth.single_session_waiter').selectOption('ask')
|
||||
const idleSel = page.getByTestId('setting-auth.idle_days')
|
||||
const idleDefault = await idleSel.inputValue()
|
||||
await idleSel.selectOption('30')
|
||||
@@ -912,7 +922,7 @@ try {
|
||||
const odlg = o.getByRole('dialog')
|
||||
await odlg.getByLabel('Code shown on the device').fill(kitchenCode)
|
||||
await odlg.getByLabel('App to run').selectOption('kds')
|
||||
await odlg.getByLabel('Name').fill('Kitchen pass')
|
||||
await odlg.getByLabel('Name', { exact: true }).fill('Kitchen pass')
|
||||
await odlg.getByLabel('How staff sign in').selectOption('pin')
|
||||
await odlg.getByRole('button', { name: 'Pair a device' }).click()
|
||||
await odlg.waitFor({ state: 'detached', timeout: 8000 }).catch(() => {})
|
||||
@@ -971,7 +981,7 @@ try {
|
||||
r.check(`${ov} a shift started for a waiter with €20.50 (typed with a comma)`, await ovRow.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
&& (await api('GET', '/api/shifts/?active_only=true', { token: boss })).shifts.some(s => s.waiter_id === ovWaiter.id && s.starting_cash === 20.5))
|
||||
const freeTable = (await api('GET', '/api/tables/', { token: boss })).find(t => !t.open_order_id && !t.current_order_id)
|
||||
const ovOrder = await api('POST', '/api/orders/', { token: await loginApi('demo_maria', { pin: '3302', client: 'waiter' }), body: { table_id: freeTable.id } })
|
||||
const ovOrder = await api('POST', '/api/orders/', { token: await loginApi('demo_maria', { pin: '3302', client: 'waiter', replace: true }), body: { table_id: freeTable.id } })
|
||||
const chip = page.locator(`[data-testid="table-chip"][data-state="open"]`).filter({ hasText: freeTable.label || `T${freeTable.number}` }).first()
|
||||
r.check(`${ov} a table a waiter opens turns "open" by itself (live)`, await chip.waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
|
||||
await chip.click()
|
||||
|
||||
Reference in New Issue
Block a user