get group resize, enter and exit working

This commit is contained in:
matei jordache
2026-03-27 14:13:09 -07:00
parent 98d36eb327
commit 1eda4030d1
11 changed files with 362 additions and 24 deletions

View File

@@ -0,0 +1,8 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { SOCKET_COMPATIBILITY } from '../src/constants.js';
test('SAVE_VALUE accepts ANNOTATION_SOURCE inputs', () => {
assert.equal(SOCKET_COMPATIBILITY.SAVE_VALUE.has('ANNOTATION_SOURCE'), true);
});

View File

@@ -0,0 +1,26 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
GROUP_DRAG_RELEASE_DISTANCE,
getPointDistanceOutsideRect,
shouldReleaseFromGroup,
} from '../src/groupDrag.js';
test('getPointDistanceOutsideRect returns zero inside the rect', () => {
const rect = { left: 10, top: 20, right: 110, bottom: 120 };
assert.equal(getPointDistanceOutsideRect(rect, { x: 60, y: 70 }), 0);
});
test('shouldReleaseFromGroup waits for a small overshoot before releasing', () => {
const rect = { left: 10, top: 20, right: 110, bottom: 120 };
assert.equal(
shouldReleaseFromGroup(rect, { x: 110 + GROUP_DRAG_RELEASE_DISTANCE - 1, y: 70 }),
false,
);
assert.equal(
shouldReleaseFromGroup(rect, { x: 110 + GROUP_DRAG_RELEASE_DISTANCE, y: 70 }),
true,
);
});

View File

@@ -0,0 +1,26 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { getGroupMinimumSize } from '../src/groupSizing.js';
test('getGroupMinimumSize keeps the base minimum for empty groups', () => {
assert.deepEqual(getGroupMinimumSize([]), { width: 260, height: 180 });
});
test('getGroupMinimumSize grows to fit child bounds plus padding', () => {
const nodes = [
{
position: { x: 24, y: 60 },
style: { width: 180, height: 100 },
},
{
position: { x: 260, y: 150 },
style: { width: 220, height: 140 },
},
];
assert.deepEqual(getGroupMinimumSize(nodes), {
width: 504,
height: 314,
});
});