// Keyboard move plans: tree tests own the width math, not the choice of route. import assert from 'node:assert/strict'; import test from 'node:test'; import { loadMoves, tree } from './tiles-fixture.mjs'; const { moveToward } = await loadMoves(); const { leaf, split, tabs } = tree; // A two-column source row collapses on removal. The reorder route is what // lets the board restore the original widths instead of splitting the survivor. test('stepping a direct pane past a leaf requests a column reorder', () => { const a = leaf('a'); const b = leaf('b'); const section = { ...split('column', [leaf('c'), leaf('d')]), name: 'section', }; assert.deepEqual(moveToward(split('row', [a, b]), a.window, 'right'), { target: b.id, where: 'right', extend: 'reorder', }); const root = split('row', [a, section, b]); assert.deepEqual(moveToward(root, section.id, 'left'), { target: a.id, where: 'left', extend: 'reorder', }); const reordered = split('row', [section, a, b]); assert.equal(moveToward(reordered, section.id, 'left'), null); assert.equal(moveToward(reordered, b.window, 'right'), null); }); test('stepping into neighboring tabs or a stack is not a column reorder', () => { const a = leaf('a'); const b = leaf('b'); const c = leaf('c'); const group = tabs([b, c]); const stack = split('column', [b, c]); assert.deepEqual(moveToward(split('row', [a, group]), a.window, 'right'), { target: group.id, where: 'tab', index: 2, }); assert.deepEqual(moveToward(split('row', [a, stack]), a.window, 'right'), { target: c.id, where: 'bottom', }); assert.deepEqual(moveToward(split('row', [stack, a]), b.window, 'bottom'), { target: c.id, where: 'bottom', }); });