feat: the table map (platform-v2 step 6.8, D-31)

- floor_plans / floor_items (0035), tables' plan_id + width/height/rotation/shape;
  /api/floor-plans (set-up, catalog.tables.manage, floor_plans.changed) and
  /api/floor-plans/live (each table's state, guests, waiters, time; zone rule)
- @xenia/floorplan: the drawing (Floor, Item, TableShape, FloorView) and its geometry
  (grid snap in whole cells, outlines, chairs), tested
- manager: Management -> Tables -> Floor plans (editor: drag, grid, irregular floor,
  walls/bar/labels/areas, background picture), Tables page List / Map
- counter POS: Tables List / Map; waiter: Map mode, the list stays the default
- tests: test_floor_plans.py, floor + geometry unit tests, manager/waiter/terminal e2e

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 17:00:45 +02:00
co-authored by Claude Opus 5.5
parent fd3254aa31
commit f4aae6abbc
47 changed files with 2102 additions and 8 deletions
+54
View File
@@ -953,6 +953,60 @@ try {
for (let i = 0; i < 20 && limits?.max_total_value_workday !== null; i++) { await sleep(250); limits = await api('GET', '/api/pricing/discount-settings/global', { token: boss }) }
r.check(`${pg} emptied: no limit`, limits?.max_total_value_workday === null, JSON.stringify(limits))
// ── 6.8: a floor plan drawn in the manager (the phones and the counter: waiter.mjs, terminal.mjs) ──
const fl = 'floor plans:'
await page.goto(`${APP}/management/tables`)
await page.getByTestId('tables-tab-floor').click()
await page.getByTestId('floor-new').first().click()
await page.getByTestId('floor-new-name').fill('E2E ground floor')
await page.getByTestId('floor-create').click()
await page.getByTestId('floor-editor').waitFor({ timeout: 10_000 })
const ownButtons = page.getByTestId('floor-own-tables').locator('button')
await ownButtons.first().waitFor({ timeout: 5000 })
const firstId = Number(await ownButtons.first().getAttribute('data-table'))
await ownButtons.first().click()
await page.keyboard.press('Escape')
await page.getByTestId('floor-canvas').click({ position: { x: 5, y: 5 } })
const secondId = Number(await ownButtons.first().getAttribute('data-table'))
await ownButtons.first().click()
await page.getByTestId('floor-shape-round').click()
await page.getByTestId('floor-canvas').click({ position: { x: 5, y: 5 } })
await page.getByTestId('floor-add-bar').click()
// drag the first table 150 px to the right
await page.locator(`[data-testid="floor-canvas"] [data-testid="floor-table"][data-table="${firstId}"]`).scrollIntoViewIfNeeded()
const tb = await page.locator(`[data-testid="floor-canvas"] [data-testid="floor-table"][data-table="${firstId}"]`).boundingBox()
await page.mouse.move(tb.x + tb.width / 2, tb.y + tb.height / 2)
await page.mouse.down()
await page.mouse.move(tb.x + tb.width / 2 + 75, tb.y + tb.height / 2, { steps: 5 })
await page.mouse.move(tb.x + tb.width / 2 + 150, tb.y + tb.height / 2 + 60, { steps: 5 })
await page.mouse.up()
// an irregular floor: a corner more, pulled in
await page.getByTestId('floor-shape-mode').click()
await page.getByTestId('floor-corner').nth(1).click()
await page.getByTestId('floor-corner-add').click()
await page.getByTestId('floor-corner').nth(2).scrollIntoViewIfNeeded()
const corner = await page.getByTestId('floor-corner').nth(2).boundingBox()
await page.mouse.move(corner.x + corner.width / 2, corner.y + corner.height / 2)
await page.mouse.down()
await page.mouse.move(corner.x - 120, corner.y + 10, { steps: 6 })
await page.mouse.up()
await page.getByTestId('floor-shape-mode').click()
await page.screenshot({ path: path.join(OUT, 'manager-floor-editor.png') })
await page.getByTestId('floor-save').click()
let saved = null
for (let i = 0; i < 30 && !(saved?.tables?.filter(x => x.plan_id != null).length >= 2); i++) { await sleep(250); saved = await api('GET', '/api/floor-plans', { token: boss }) }
const sp = saved.plans.find(x => x.name === 'E2E ground floor')
const placedNow = saved.tables.filter(x => x.plan_id === sp?.id)
const t1 = placedNow.find(x => x.id === firstId)
r.check(`${fl} drawn and saved: two tables (one round), the bar, a five-corner floor`, placedNow.length === 2 && placedNow.find(x => x.id === secondId)?.shape === 'round'
&& sp.items.some(i => i.kind === 'bar') && sp.outline?.length === 5, JSON.stringify({ placed: placedNow.map(x => [x.id, x.x, x.y, x.shape]), outline: sp?.outline }))
r.check(`${fl} the dragged table moved, on the grid`, t1 && t1.x > 600 && t1.x % 20 === 0, JSON.stringify(t1))
await page.goto(`${APP}/tables`)
await page.getByTestId('tables-view-map').click()
r.check(`${fl} the Tables page shows the plan live`, await page.locator('[data-testid="manager-floor"] [data-testid="floor-table"]').first().waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
&& await page.locator('[data-testid="manager-floor"] [data-testid="floor-table"]').count() >= 2)
await page.screenshot({ path: path.join(OUT, 'manager-floor-live.png') })
await api('PUT', '/api/platform/modules/connect_orders', { token: boss, body: { enabled: true } })
await page.goto(`${APP}/online-orders`)
await page.getByTestId('online-orders').waitFor({ timeout: 10_000 }).catch(() => {})