Files
bonaminandClaude Opus 5.5 8abe4d92d3 feat(waiter): what a waiter may do comes from permission keys (platform-v2 step 4.3)
- Payments: ordering.orders.close checked on pay/close and the counter POS
  (waiters have it by default, owner decision); pay-offline always recorded.
- The venue switches waiter_cancellations / price_adjust / revert are gone:
  ordering.orders.cancel, ordering.prices.modify and the new
  ordering.payments.revert (overridable) decide; moves/split/transfer/merge
  need ordering.orders.open; discounts pricing.discounts.apply; chat chat.use.
- Venue role defaults: role_permissions (Alembic 0024), role_template(role, db),
  GET/PUT /api/waiters/roles/{role}/permissions applying the change to everyone
  with the role; manager Settings -> Operation -> "What each role may do".
  0024 also grants the new key to existing owners and store managers.
- Bootstrap `approvable`; @xenia/access useAllowed(key) -> yes/approve/no.
  The waiter shows each action by key, "with a manager's approval (PIN)" where
  allowed; GET /api/orders/cancel-permissions removed.
- Tests: test_waiter_keys.py (11), access allowed(), waiter.mjs +5, manager.mjs +3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 00:54:08 +02:00

29 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict'
import { test } from 'node:test'
import { allowed, can } from '../src/hooks.js'
const held = new Set(['reports.view', 'catalog.menu.manage'])
test('one key', () => {
assert.equal(can(held, 'reports.view'), true)
assert.equal(can(held, 'core.staff.manage'), false)
})
test('a list means any of them (like require_any), or all with all=true', () => {
assert.equal(can(held, ['core.staff.manage', 'reports.view']), true)
assert.equal(can(held, ['core.staff.manage', 'reports.view'], true), false)
assert.equal(can(held, ['reports.view', 'catalog.menu.manage'], true), true)
})
test('an empty list asks for nothing', () => {
assert.equal(can(new Set(), []), true)
})
test('allowed: held, a manager may approve, or no (plan step 4.3)', () => {
const approvable = new Set(['ordering.orders.cancel'])
assert.equal(allowed(held, approvable, 'reports.view'), 'yes')
assert.equal(allowed(held, approvable, 'ordering.orders.cancel'), 'approve')
assert.equal(allowed(held, approvable, 'pricing.discounts.apply'), 'no')
assert.equal(allowed(held, undefined, 'ordering.orders.cancel'), 'no')
})