- terminal/: new workspace app (Vite + React 19 + Router 7, Tailwind on the shared preset, @xenia/i18n namespace `terminal`, @xenia/api client sending X-Xenia-Device, @xenia/access bootstrap). Apps are lazy chunks by app_key (kds, pos_counter, customer_display placeholders); start screen; "unknown app" screen; dev-only /ui-gallery and /i18n-sample. Device + session tokens in a storage wrapper. - Image pos-terminal (terminal/Dockerfile, context client-services/); every frontend Dockerfile copies terminal/package.json for npm ci. - docker-compose(.dev).yml: service terminal; proxy publishes 8082. - Proxy (nginx-proxy/nginx.conf == install.sh heredoc, CS-5): server :8082, LAN-only allow/deny, WebSocket upgrade; the terminal upstream is resolved per request so the proxy still starts on a stack without the terminal container. - install.sh prints the screens address. - Tests: terminal unit tests + lint in run-all; new tests/e2e/stack.mjs (release images on one compose stack: :8082 serves the app, /api + WebSocket through both hops, 403 from a non-LAN docker network on 8082 and 8081, proxy up without terminal). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
// Pure parts of the terminal shell (plan step 3.1b).
|
|
import assert from 'node:assert/strict'
|
|
import { test } from 'node:test'
|
|
import { APPS, appLoader } from '../src/apps/registry.js'
|
|
import { DEVICE_KEY, SESSION_KEY, createDeviceStore } from '../src/device/storage.js'
|
|
|
|
test('the apps a screen can run: KDS, counter POS, customer display (signage + menu tablet in phase 5)', () => {
|
|
assert.deepEqual(Object.keys(APPS).sort(), ['customer_display', 'kds', 'pos_counter'])
|
|
assert.equal(typeof appLoader('kds'), 'function')
|
|
assert.equal(appLoader('signage'), null)
|
|
assert.equal(appLoader('toString'), null) // never a prototype member
|
|
})
|
|
|
|
function memoryStorage() {
|
|
const m = new Map()
|
|
return { getItem: k => (m.has(k) ? m.get(k) : null), setItem: (k, v) => m.set(k, String(v)), removeItem: k => m.delete(k), m }
|
|
}
|
|
|
|
test('device store keeps the device and session tokens; forget() clears both', () => {
|
|
const s = memoryStorage()
|
|
const d = createDeviceStore(s)
|
|
assert.equal(d.deviceToken(), null)
|
|
d.setDeviceToken('dev-1')
|
|
d.setSessionToken('jwt-1')
|
|
assert.equal(s.m.get(DEVICE_KEY), 'dev-1')
|
|
assert.equal(d.sessionToken(), 'jwt-1')
|
|
d.setSessionToken(null)
|
|
assert.equal(s.m.has(SESSION_KEY), false)
|
|
d.setSessionToken('jwt-2')
|
|
d.forget()
|
|
assert.equal(d.deviceToken(), null)
|
|
assert.equal(d.sessionToken(), null)
|
|
})
|
|
|
|
test('device store survives a storage that throws (private mode)', () => {
|
|
const broken = { getItem() { throw new Error('denied') }, setItem() { throw new Error('denied') }, removeItem() { throw new Error('denied') } }
|
|
const d = createDeviceStore(broken)
|
|
d.setDeviceToken('x')
|
|
assert.equal(d.deviceToken(), null)
|
|
assert.equal(createDeviceStore(null).sessionToken(), null)
|
|
})
|