feat(ui): add docking, viewport controls and composed settings

Add shared dock layouts, navigation cube, range bands, progress actions and comparison surfaces. Extend toolbar menus and loading composition, and align tokens, registry entries, documentation and the living catalog.
This commit is contained in:
Codex
2026-10-29 09:38:25 +03:00
parent a6e6c8f2d9
commit cb534dbe39
51 changed files with 2273 additions and 336 deletions
+54
View File
@@ -0,0 +1,54 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { SegmentedControl, SegmentedGroup, SegmentedButton, ProgressButton, LayerStackIndicator } from '../packages/ui-react/dist/index.js';
test('multiple segments allow all/none and never drop another active layer', () => {
let value = ['gaussian'];
const items = [{value:'gaussian',label:'Gaussian'},{value:'collision',label:'Коллизии'}];
const render = () => SegmentedControl({selectionMode:'multiple',value,items,label:'Слои',onChange:next=>{value=next;}});
render().props.children[1].props.onClick();
assert.deepEqual(value,['gaussian','collision']);
render().props.children[0].props.onClick();
assert.deepEqual(value,['collision']);
render().props.children[1].props.onClick();
assert.deepEqual(value,[]);
const html=renderToStaticMarkup(render());
assert.match(html,/role="group"/);
assert.doesNotMatch(html,/role="tab|aria-selected/);
assert.equal((html.match(/aria-pressed="false"/g)||[]).length,2);
});
test('single segment consumers retain one selected tab and scalar changes', () => {
let value='3d';
const element=SegmentedControl({value,items:[{value:'3d',label:'3D'},{value:'top',label:'Top'}],label:'View',onChange:next=>{value=next;}});
assert.match(renderToStaticMarkup(element),/role="tablist"/);
element.props.children[1].props.onClick();
assert.equal(value,'top');
});
test('pending progress preserves action name, rejects reentry and exposes a separate measured progressbar', () => {
const html=renderToStaticMarkup(createElement(ProgressButton,{label:'Проанализировать',icon:createElement(LayerStackIndicator),progress:{label:'Анализ поверхности · 29 / 96',value:29/96}}));
assert.match(html,/<button[^>]*aria-label="Проанализировать"[^>]*disabled=""/);
assert.match(html,/aria-busy="true"/);
assert.match(html,/aria-valuenow="30"/);
assert.match(html,/<\/button>[\s\S]*role="progressbar"/);
assert.match(html,/Анализ поверхности/);
const unknown=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ',progress:{label:'Подготовка'}}));
assert.doesNotMatch(unknown,/aria-valuenow/);
const idle=renderToStaticMarkup(createElement(ProgressButton,{label:'Анализ'}));
assert.doesNotMatch(idle,/disabled=""|role="progressbar"/);
});
test('mixed capsule keeps toggle and menu semantics distinct', () => {
const html=renderToStaticMarkup(createElement(SegmentedGroup,{label:'Layers'},
createElement(SegmentedButton,{active:true,'aria-pressed':true},'Gaussian'),
createElement(SegmentedButton,{'aria-expanded':false,'aria-haspopup':'dialog'},'Memory')));
assert.match(html,/role="group" aria-label="Layers"/);
assert.match(html,/aria-pressed="true"[^>]*data-active="true"/);
assert.match(html,/aria-expanded="false" aria-haspopup="dialog"/);
assert.equal((html.match(/aria-pressed/g)||[]).length,1);
assert.doesNotMatch(html,/role="tab/);
});
+12
View File
@@ -35,3 +35,15 @@ test("dense viewer controls remain a public Button and SegmentedControl contract
assert.match(docs, /size="dense"/);
assert.match(docs, /viewer/);
});
test("viewport controls share one scale without scaling nested controls twice", async () => {
const [tokens,styles,registrySource] = await Promise.all([
readFile(new URL("../packages/tokens/tokens.css",import.meta.url),"utf8"),
readFile(new URL("../packages/ui-core/styles.css",import.meta.url),"utf8"),
readFile(new URL("../registry/components.json",import.meta.url),"utf8"),
]);
assert.match(tokens,/--nodedc-viewport-control-scale: 0\.7/);
assert.match(styles,/zoom: var\(--nodedc-viewport-control-scale\)/);
assert.match(styles, /\.nodedc-segmented\) :is\([^}]+zoom: 1;/);
assert.ok(JSON.parse(registrySource).components.find(c=>c.id==='button').domContract.includes('nodedc-viewport-controls'));
});
+81
View File
@@ -0,0 +1,81 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {preferDockSizes,dockMinimum,constrainDockTree,balancedDockTree,decodeDockTree,dockIds,dockPosition,dockRects,moveDockPanel,pruneDockTree,reconcileDockTree,resizeDockSplit} from '../packages/ui-core/dist/dockTree.js';
const bounds={left:0,top:0,width:1200,height:800};
const initial=balancedDockTree(['a','b','c']);
const rects=tree=>dockRects(tree,bounds);
test('three asymmetric panes: center exchanges contents without changing slots',()=>{
const before=rects(initial),next=rects(moveDockPanel(initial,{activeId:'c',overId:'a',position:'center'}));
assert.deepEqual(next.c,before.a);assert.deepEqual(next.a,before.c);assert.deepEqual(next.b,before.b);
});
test('left to top/bottom edge of right pane gives one left and two right',()=>{
for(const position of ['top','bottom']){
const next=moveDockPanel(initial,{activeId:'a',overId:'c',position}),r=rects(next);
assert.deepEqual(r.b,{left:0,top:0,width:600,height:800});
assert.deepEqual(r.a,{left:600,top:position==='top'?0:400,width:600,height:400});
assert.deepEqual(r.c,{left:600,top:position==='top'?400:0,width:600,height:400});
}
});
test('right window moves to any edge of a left pane; left/right create a middle column',()=>{
for(const position of ['left','right','top','bottom']){
const next=moveDockPanel(initial,{activeId:'c',overId:'a',position}),r=rects(next);
assert.deepEqual(r.b,{left:0,top:400,width:1200,height:400});
assert.equal(position==='left'?r.c.left<r.a.left:position==='right'?r.c.left>r.a.left:position==='top'?r.c.top<r.a.top:r.c.top>r.a.top,true);
}
});
test('every source/destination/edge for 2..12 panes retains each identity and tiles the whole area',()=>{
for(let n=2;n<=12;n++){
const ids=Array.from({length:n},(_,i)=>String(i));let tree=balancedDockTree(ids);
for(const activeId of ids)for(const overId of ids)for(const position of ['center','left','right','top','bottom']){
tree=moveDockPanel(tree,{activeId,overId,position});
assert.deepEqual([...dockIds(tree)].sort(),[...ids].sort());
const panels=Object.values(rects(tree));
assert.ok(Math.abs(panels.reduce((total,r)=>total+r.width*r.height,0)-bounds.width*bounds.height)<1e-6);
for(let i=0;i<panels.length;i++)for(let j=i+1;j<panels.length;j++){
const a=panels[i],b=panels[j],overlapX=Math.min(a.left+a.width,b.left+b.width)-Math.max(a.left,b.left),overlapY=Math.min(a.top+a.height,b.top+b.height)-Math.max(a.top,b.top);
assert.ok(overlapX<1e-8||overlapY<1e-8);
}
}
}
});
test('pointer position alone selects edge; leaving workspace or source cancels',()=>{
const r={left:400,top:100,width:800,height:600};
assert.equal(dockPosition(r,405,400),'left');assert.equal(dockPosition(r,1195,400),'right');
assert.equal(dockPosition(r,800,105),'top');assert.equal(dockPosition(r,800,695),'bottom');
assert.equal(dockPosition(r,800,400),'center');assert.equal(dockPosition(r,399,400),null);
assert.equal(moveDockPanel(initial,{activeId:'a',overId:'a',position:'left'}),initial);
assert.equal(moveDockPanel(initial,{activeId:'missing',overId:'c',position:'center'}),initial);
});
test('resize, focus, persistence and new/missing sources preserve identity',()=>{
const changed=resizeDockSplit(initial,'0',63);
assert.equal(changed.first.ratio,63);assert.equal(initial.first.ratio,50);
assert.deepEqual(decodeDockTree(JSON.parse(JSON.stringify(changed))),changed);
assert.deepEqual(pruneDockTree(changed,['c']),{id:'c'});
const restored=reconcileDockTree(pruneDockTree(changed,['a','c']),['a','b','c','d']);
assert.deepEqual(dockIds(restored).sort(),['a','b','c','d']);
assert.deepEqual(decodeDockTree({axis:'x',ratio:50,first:{id:'a'},second:{id:'a'}}),{id:'a'});
assert.equal(decodeDockTree({axis:'x',ratio:Infinity}),null);
});
test('recursive minimums protect all columns and rows after extreme resize',()=>{
const t={axis:'x',ratio:99,first:{id:'scene'},second:{axis:'y',ratio:1,first:{id:'telemetry'},second:{id:'camera'}}};
for(let n=1;n<=8;n++){
const sizes={telemetry:{width:144+88*n,height:280}},minimum=dockMinimum(t,sizes);
for(const requested of [{width:1200,height:800},{width:100,height:100}]){
const b={left:0,top:0,width:Math.max(requested.width,minimum.width),height:Math.max(requested.height,minimum.height)};
const c=constrainDockTree(t,b,sizes),r=dockRects(c,b);
assert.ok(r.telemetry.width+1e-8>=sizes.telemetry.width);assert.ok(r.telemetry.height+1e-8>=280);
assert.ok(r.scene.width+1e-8>=160);assert.ok(r.camera.height+1e-8>=120);
assert.deepEqual(constrainDockTree(c,b,sizes),c);
}
}
});
test('new compact panel uses its preferred size without changing saved ratios',()=>{
const t={axis:'x',ratio:65,first:{id:'map'},second:{axis:'y',ratio:40,first:{id:'telemetry'},second:{id:'camera'}}};
const sizes={telemetry:{width:320,height:280}};
const initial=constrainDockTree(preferDockSizes(t,bounds,sizes),bounds,sizes),r=rects(initial);
assert.ok(Math.abs(r.telemetry.width-320)<1e-8);assert.ok(Math.abs(r.telemetry.height-280)<1e-8);
assert.deepEqual(preferDockSizes(t,bounds,{}),t);
});
+24
View File
@@ -0,0 +1,24 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {cubeRegions} from '../packages/ui-react/dist/NavigationCube.js';
test('cube exposes exactly 26 unique face/edge/corner directions over all sides',()=>{
const views=[[0,0,0,1],[0,1,0,0],[0,Math.SQRT1_2,0,Math.SQRT1_2],[0,-Math.SQRT1_2,0,Math.SQRT1_2],[Math.SQRT1_2,0,0,Math.SQRT1_2],[-Math.SQRT1_2,0,0,Math.SQRT1_2]];
const dirs=new Set(views.flatMap(q=>cubeRegions(q).map(r=>r.direction.join(','))));
assert.equal(dirs.size,26);assert.ok(!dirs.has('0,0,0'));
assert.deepEqual(cubeRegions([0,0,0,1]).filter(r=>r.faceLabel).map(r=>r.faceLabel),['FRONT']);
assert.deepEqual(cubeRegions([Math.SQRT1_2,0,0,Math.SQRT1_2]).filter(r=>r.faceLabel).map(r=>r.faceLabel),['BOTTOM']);
for(const q of views)for(const r of cubeRegions(q)){assert.ok(!r.polygon.includes('NaN'));assert.ok(r.label);}
});
test('labels are projected in each face plane with no mirrored front-facing text',()=>{
const q=[.28,-.36,.12,.88],regions=cubeRegions(q).filter(r=>r.faceLabel);
assert.equal(regions.length,3);
for(const r of regions){
const [a,b,c,d,e,f]=r.textMatrix;assert.ok(a*d-b*c>0);assert.ok(a*d-b*c<1);
assert.ok(r.textMatrix.every(Number.isFinite));assert.ok(Math.abs(b)+Math.abs(c)>0.05);
const points=r.polygon.split(' ').map(p=>p.split(',').map(Number));
assert.ok(Math.abs(points.reduce((n,p)=>n+p[0],0)/4-e)<1e-9);
assert.ok(Math.abs(points.reduce((n,p)=>n+p[1],0)/4-f)<1e-9);
}
assert.deepEqual(cubeRegions([0,0,0,1]).find(r=>r.faceLabel).textMatrix.map(n=>n||0),[1,0,0,1,60,60]);
});
+51 -36
View File
@@ -23,47 +23,33 @@ test("RangeControl keeps native drag semantics and exposes one persistent exact-
assert.doesNotMatch(markup, /nodedc-range__value-hit/);
});
test("vertical scale keeps endpoints outside and the label/value centered at every fill level", () => {
test("vertical scale exposes retained bounds without center text and follows every value", () => {
for (const [value, progress] of [[-1.2, 0], [25.15, 50], [51.5, 100]]) {
const markup = renderToStaticMarkup(createElement(RangeControl, {
label: "Срез", orientation: "vertical", value, min: -1.2, max: 51.5, step: "any",
formatValue: (n) => `${n.toFixed(1).replace('.', ',')} м`,
formatLimit: (n) => n.toFixed(1).replace('.', ','), onChange: () => {},
}));
const renderedProgress = Number(markup.match(/--nodedc-range-progress:([\d.]+)%/)?.[1]);
assert.ok(Math.abs(renderedProgress - progress) < 1e-9);
assert.match(markup, /aria-label="Срез" aria-orientation="vertical"/);
assert.match(markup, /min="-1.2" max="51.5" step="any"/);
assert.equal((markup.match(/nodedc-range-scale__limit--max">51,5<\/span>/g) ?? []).length, 1);
assert.equal((markup.match(/nodedc-range-scale__limit--min">-1,2<\/span>/g) ?? []).length, 1);
assert.match(markup, /<\/span><\/span><\/div><span class="nodedc-range-scale__limit/);
assert.equal((markup.match(/nodedc-range__label">Срез · /g) ?? []).length, 2);
assert.match(markup, /nodedc-range__fill-text" aria-hidden="true"/);
assert.doesNotMatch(markup, /nodedc-range__value|nodedc-range__editor|formatLimit=/);
for (const limitSide of ["left", "right"]) {
const markup = renderToStaticMarkup(createElement(RangeControl, {
label: "Срез", orientation: "vertical", limitSide, value, min: -1.2, max: 51.5, step: "any",
formatValue: n => `${n.toFixed(1)} м`, formatLimit: n => n.toFixed(1), onChange: () => {},
}));
const renderedProgress = Number(markup.match(/--nodedc-range-progress:([\d.]+)%/)?.[1]);
assert.ok(Math.abs(renderedProgress - progress) < 1e-9);
assert.ok(markup.includes(`data-limit-side="${limitSide}"`));
assert.ok(markup.includes(`nodedc-range-scale__limit--max">${value.toFixed(1)}</span>`));
assert.match(markup, /nodedc-range-scale__limit--min">-1.2<\/span>/);
assert.match(markup, /aria-label="Срез" aria-orientation="vertical"/);
assert.ok(markup.includes(`aria-valuetext="${value.toFixed(1)} м"`));
assert.match(markup, /min="-1.2" max="51.5" step="any"/);
assert.doesNotMatch(markup, /nodedc-range__label|nodedc-range__fill-text|nodedc-range__editor|formatLimit=/);
}
}
});
test("vertical scale mirrors only endpoint labels for the opposite scene edge", () => {
const markup = renderToStaticMarkup(createElement(RangeControl, {
label: "Срез", orientation: "vertical", limitSide: "left", value: 25.15, min: -1.2, max: 51.5,
step: "any", formatLimit: (n) => n.toFixed(1).replace('.', ','), onChange: () => {},
}));
assert.match(markup, /class="nodedc-range-scale" data-limit-side="left"/);
assert.match(markup, /nodedc-range-scale__limit--max">51,5<\/span>/);
assert.match(markup, /nodedc-range-scale__limit--min">-1,2<\/span>/);
});
test("vertical contrast clips both glyph layers and visible focus has no perimeter", async () => {
test("thin vertical rail retains a usable pointer target and boundary focus", async () => {
const styles = await readFile(new URL("../packages/ui-core/styles.css", import.meta.url), "utf8");
assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \.nodedc-range__fill-text \{ clip-path: inset\(calc\(100% - var\(--nodedc-range-progress\)\) 0 0 round var\(--nodedc-radius-circle\)\)/);
assert.match(styles, /\.nodedc-range-scale \{[^}]*width: calc\(var\(--nodedc-control-height\) \* 0\.4\)/);
assert.match(styles, /\.nodedc-range-scale__limit \{[^}]*left: calc\(100% \+ 0\.4rem\);[^}]*color: var\(--nodedc-text-primary\);[^}]*font-size: calc\(var\(--nodedc-font-size-xs\) \* 0\.9\)/);
assert.match(styles, /\.nodedc-range-scale\[data-limit-side="left"\] \.nodedc-range-scale__limit \{[^}]*right: calc\(100% \+ 0\.4rem\);[^}]*left: auto;[^}]*text-align: right/);
assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \.nodedc-range__label \{[^}]*font-size: calc\(var\(--nodedc-font-size-sm\) \* 0\.9\)/);
assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\] \{[^}]*border: 0; outline: 0; box-shadow: none;/);
assert.match(styles, /\.nodedc-range\[data-orientation="vertical"\]:has\(input:focus-visible\) \.nodedc-range__label \{ text-decoration: underline; text-decoration-thickness: 2px;/);
assert.doesNotMatch(styles, /\.nodedc-range\[data-orientation="vertical"\]:has\(input:focus-visible\) \{/);
assert.doesNotMatch(styles, /\.nodedc-range\[data-orientation="vertical"\]:focus-within/);
assert.match(styles, /width: calc\(var\(--nodedc-control-height\) \* 0\.2\)/);
assert.match(styles, /width: max\(100%, 24px\)/);
assert.match(styles, /limit--max \{ bottom: clamp\(/);
assert.match(styles, /range-scale:has\(input:focus-visible\) \.nodedc-range-scale__limit--max \{ text-decoration: underline/);
assert.match(styles, /data-orientation="vertical"\] \{[^}]*border: 0; outline: 0; box-shadow: none;/);
});
test("exact editing is a stable native caret field without remount, forced selection or a dark editor box", async () => {
@@ -102,3 +88,32 @@ test("exact editing is a stable native caret field without remount, forced selec
assert.match(windowComponent, /onCloseRef\.current\(\)/);
assert.doesNotMatch(windowComponent, /\[closeOnEscape, onClose, open, shouldLockBodyScroll, shouldTrapFocus\]/);
});
test("vertical band exposes two independent accessible boundaries", () => {
for (const value of [[-52, 500], [10, 35], [20, 20]]) {
const markup = renderToStaticMarkup(createElement(RangeControl, {
label: "Срез", orientation: "vertical", value, min: -52, max: 500, step: "any",
formatValue: n => `${n} м`, onChange: () => {},
}));
assert.equal((markup.match(/type="range"/g) ?? []).length, 2);
assert.match(markup, /aria-label="Срез: нижняя граница"/);
assert.match(markup, /aria-label="Срез: верхняя граница"/);
assert.ok(markup.includes(`aria-valuemax="${value[1]}"`));
assert.ok(markup.includes(`aria-valuemin="${value[0]}"`));
assert.doesNotMatch(markup, /nodedc-range__label|nodedc-range__editor/);
}
});
test("both boundaries move, clamp independently, separate after coincidence and restore endpoints", async () => {
const {moveRangeBoundary: move, nearestRangeBoundary: nearest} = await import("../packages/ui-react/dist/rangeBand.js");
let band = [-52, 500];
assert.equal(nearest(band, -40), 0); assert.equal(nearest(band, 450), 1);
band = move(band, 0, 10, -52, 500, "any"); assert.deepEqual(band, [10, 500]);
band = move(band, 1, 30, -52, 500, "any"); assert.deepEqual(band, [10, 30]);
band = move(band, 0, 50, -52, 500, "any"); assert.deepEqual(band, [30, 30]);
assert.equal(nearest(band, 20), 0); assert.equal(nearest(band, 40), 1);
band = move(band, 0, -100, -52, 500, "any");
band = move(band, 1, 600, -52, 500, "any"); assert.deepEqual(band, [-52, 500]);
assert.deepEqual(move([0, 10], 1, 7.3, 0, 10, .5), [0, 7.5]);
assert.deepEqual(move([0, 9], 1, 10.1, 0, 10.1, 3), [0, 10.1]);
});
+25
View File
@@ -0,0 +1,25 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {createElement as h} from 'react';
import {renderToStaticMarkup} from 'react-dom/server';
import {LoadingRegion,Description,SettingsCard,ComparisonTable} from '../packages/ui-react/dist/index.js';
test('composed loading draws exactly one owner even with multiple pending descendants',()=>{
const child=h(LoadingRegion,{loading:true,label:'child'},h('span',null,'retained'));
const markup=renderToStaticMarkup(h(LoadingRegion,{aggregate:true,loading:true,label:'equipment'},child,child,h(LoadingRegion,{aggregate:true,loading:true,label:'nested'},child)));
assert.equal((markup.match(/role="status"/g)||[]).length,1);assert.match(markup,/aria-label="equipment"/);assert.equal((markup.match(/retained/g)||[]).length,3);
});
test('independent surfaces keep their loaders and resolved content has no indicator',()=>{
const markup=renderToStaticMarkup(h('div',null,h(LoadingRegion,{loading:true,label:'a'}),h(LoadingRegion,{loading:true,label:'b'})));
assert.equal((markup.match(/role="status"/g)||[]).length,2);
assert.doesNotMatch(renderToStaticMarkup(h(LoadingRegion,{aggregate:true,loading:false,label:'done'},h(LoadingRegion,{loading:false,label:'child'},'ready'))),/role="status"/);
});
test('comparison has one label column, arbitrary entity columns and semantic headers',()=>{
for(const count of [1,2,3,4,8]){
const markup=renderToStaticMarkup(h(ComparisonTable,{label:'VESC',heading:'VESC',columns:Array.from({length:count},(_,i)=>({id:String(i),label:'id'+i})),rows:[{id:'position',label:'Расположение',cells:Array(count).fill('Левый')},{id:'current',label:'Ток',cells:[]}]}));
assert.equal((markup.match(/scope="col"/g)||[]).length,count+1);assert.equal((markup.match(/scope="row"/g)||[]).length,2);assert.equal((markup.match(/<td>/g)||[]).length,2*count);assert.match(markup,/tabindex="0"/);
}
});
test('SettingsCard and standalone explanatory paragraphs use one typography component',()=>{
assert.match(renderToStaticMarkup(h(Description,null,'help')),/class="nodedc-description"/);
assert.match(renderToStaticMarkup(h(SettingsCard,{title:'Settings',description:'help'})),/<p class="nodedc-description">help/);
});
+23
View File
@@ -0,0 +1,23 @@
import assert from "node:assert/strict";
import {test} from "node:test";
import {computeFloatingPosition,movingToMenu} from "../packages/ui-core/dist/index.js";
test("menus stay beyond the maximum magnified edge, including narrow windows",()=>{
for(const width of [320,640,1400])for(const size of [25,42,88]){
const anchor={left:width-12-size,right:width-12,top:200,bottom:225,width:size,height:25};
const p=computeFloatingPosition({anchor,surfaceWidth:220,surfaceHeight:400,placement:"left-start",flip:false,viewportWidth:width,viewportHeight:600});
assert.ok(p.left+Math.min(220,p.maxWidth)<=anchor.left-8+1e-9);
assert.ok(p.left>=8);assert.ok(p.top+Math.min(400,p.maxHeight)<=592);
const mirror={...anchor,left:12,right:12+size};
const q=computeFloatingPosition({anchor:mirror,surfaceWidth:220,surfaceHeight:400,placement:"right-start",flip:false,viewportWidth:width,viewportHeight:600});
assert.ok(q.left>=mirror.right+8);assert.ok(q.left+Math.min(220,q.maxWidth)<=width-8);
}
});
test("intent triangle protects diagonal entry but never blocks deliberate vertical or reverse motion",()=>{
const s={left:200,right:450,top:100,bottom:500,width:250,height:400},o={x:490,y:200};
assert.equal(movingToMenu(o,o,{x:480,y:210},s),true);
assert.equal(movingToMenu(o,o,{x:490,y:240},s),false);
assert.equal(movingToMenu(o,{x:480,y:210},{x:485,y:220},s),false);
assert.equal(movingToMenu(o,o,{x:480,y:600},s),false);
assert.equal(movingToMenu({x:150,y:200},{x:150,y:200},{x:160,y:210},s),true);
assert.equal(movingToMenu({x:300,y:550},{x:300,y:550},{x:310,y:540},s),true);
});