Files
xenia-pos-local/waiter_pwa/tests/idle.test.mjs
T
bonaminandClaude Opus 5.5 8299184e3a feat(waiter): sign-in v2 on the phones (platform-v2 step 4.2)
- Login follows auth.waiter_login_mode / auth.waiter_require_username from the
  bootstrap: name + PIN, name + password, typed username, or a "paired screens
  only" message for tap mode. POST /api/auth/login {client: "waiter"}; a miss
  shows the translated error without a reload.
- POST /api/auth/login-by-id removed; bootstrap login carries waiter_mode and
  waiter_require_username.
- Sign-out ends the session on the server (POST /api/auth/logout), so
  single_session_waiter = refuse_new no longer strands a waiter.
- Lock on the phone: menu "Lock", automatic lock / sign-out after inactivity
  (security.auto_lock*, auto_logout*), unlock with the PIN in the same session,
  lock kept across app restarts (restore() no longer clears it).
- e2e: new waiter.mjs (22 checks) in run-all; android.mjs signs in for real and
  locks/unlocks on the emulator; TLS live check waits for the socket; the
  rediscovery helper re-attaches to a stale WebView handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:25:00 +02:00

25 lines
1.2 KiB
JavaScript

// Locking and signing out an idle phone (plan step 4.2).
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { idleAction, idleLimits } from '../src/logic/idle.js'
const on = (lock, logout) => ({
'security.auto_lock': { value: lock ? 'true' : 'false' }, 'security.auto_lock_seconds': { value: String(lock || 300) },
'security.auto_logout': { value: logout ? 'true' : 'false' }, 'security.auto_logout_seconds': { value: String(logout || 1800) },
})
test('limits from the venue settings (off = never)', () => {
assert.deepEqual(idleLimits(on(60, 600)), { lockMs: 60_000, logoutMs: 600_000 })
assert.deepEqual(idleLimits(on(0, 0)), { lockMs: Infinity, logoutMs: Infinity })
assert.deepEqual(idleLimits({}), { lockMs: Infinity, logoutMs: Infinity })
assert.equal(idleLimits({ ...on(60), 'security.auto_lock_seconds': { value: 'x' } }).lockMs, Infinity)
})
test('lock, then sign out; nothing twice', () => {
const l = idleLimits(on(60, 600))
assert.equal(idleAction(30_000, l, false), null)
assert.equal(idleAction(60_000, l, false), 'lock')
assert.equal(idleAction(90_000, l, true), null, 'already locked')
assert.equal(idleAction(600_000, l, true), 'logout')
})