resolve todos

This commit is contained in:
peterkogo
2025-04-16 18:20:12 +02:00
parent 2474c8be14
commit 97c4e2b218
7 changed files with 34 additions and 29 deletions
@@ -61,7 +61,6 @@ export default function zoom(domNode: Element, params: ZoomParams) {
onDraggingChange onDraggingChange
}); });
//TODO: is this neccessary?
const viewport = panZoomInstance.getViewport(); const viewport = panZoomInstance.getViewport();
if ( if (
initialViewport.x !== viewport.x || initialViewport.x !== viewport.x ||
@@ -5,8 +5,7 @@
import type { NodeProps } from '$lib/types'; import type { NodeProps } from '$lib/types';
let { let {
// TODO: do we really want this!? data,
data = { label: 'Node' },
targetPosition = Position.Top, targetPosition = Position.Top,
sourcePosition = Position.Bottom sourcePosition = Position.Bottom
}: NodeProps = $props(); }: NodeProps = $props();
@@ -52,7 +52,6 @@
let labelledBy = $derived(`svelte-flow__minimap-desc-${store.flowId}`); let labelledBy = $derived(`svelte-flow__minimap-desc-${store.flowId}`);
// TODO: simplify this
let viewBB = $derived({ let viewBB = $derived({
x: -store.viewport.x / store.viewport.zoom, x: -store.viewport.x / store.viewport.zoom,
y: -store.viewport.y / store.viewport.zoom, y: -store.viewport.y / store.viewport.zoom,
@@ -11,6 +11,7 @@
} from '@xyflow/system'; } from '@xyflow/system';
import type { ResizeControlProps } from './types'; import type { ResizeControlProps } from './types';
import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte'; import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte';
import type { Node } from '$lib/types';
let { let {
nodeId, nodeId,
@@ -67,20 +68,31 @@
}; };
}, },
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => { onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
updateNode(id, (node) => ({ const changes = new Map<string, Partial<Node>>();
...node, let position = change.x && change.y ? { x: change.x, y: change.y } : undefined;
position: { x: change.x ?? node.position.x, y: change.y ?? node.position.y }, changes.set(id, { ...change, position });
width: change.width ?? node.width,
height: change.height ?? node.height
}));
// TODO: performance?
for (const childChange of childChanges) { for (const childChange of childChanges) {
updateNode(childChange.id, (node) => ({ changes.set(childChange.id, {
...node,
position: childChange.position position: childChange.position
})); });
} }
store.nodes = store.nodes.map((node) => {
const change = changes.get(node.id);
if (change) {
return {
...node,
position: {
x: change.position?.x ?? node.position.x,
y: change.position?.y ?? node.position.y
},
width: change.width ?? node.width,
height: change.height ?? node.height
};
}
return node;
});
} }
}); });
} }
-3
View File
@@ -112,7 +112,6 @@ test.describe('Edges', () => {
await page.mouse.down(); await page.mouse.down();
await page.mouse.up(); await page.mouse.up();
// TODO: times out on webkit
await expect(edge).toHaveClass(/selected/); await expect(edge).toHaveClass(/selected/);
await page.keyboard.press('d'); await page.keyboard.press('d');
@@ -139,12 +138,10 @@ test.describe('Edges', () => {
const edgeBox = await edge.boundingBox(); const edgeBox = await edge.boundingBox();
//FIXME: Negative values are not working. Investigate further
await page.mouse.move(edgeBox!.x + edgeBox!.width * 0.5 + 21, edgeBox!.y + edgeBox!.height * 0.5); await page.mouse.move(edgeBox!.x + edgeBox!.width * 0.5 + 21, edgeBox!.y + edgeBox!.height * 0.5);
await page.mouse.down(); await page.mouse.down();
await page.mouse.up(); await page.mouse.up();
// TODO: times out on webkit
await expect(edge).toHaveClass(/selected/); await expect(edge).toHaveClass(/selected/);
}); });
+3 -3
View File
@@ -145,7 +145,6 @@ test.describe('Nodes', () => {
expect(edges).toHaveLength(0); expect(edges).toHaveLength(0);
}); });
// TODO: pressing backspace creates problems on webkit
test('deletable=false prevents deletion', async ({ page }) => { test('deletable=false prevents deletion', async ({ page }) => {
const node = page.locator(`.${FRAMEWORK}-flow__node`).and(page.locator('[data-id="notDeletable"]')); const node = page.locator(`.${FRAMEWORK}-flow__node`).and(page.locator('[data-id="notDeletable"]'));
await expect(node).toHaveCSS('visibility', 'visible'); await expect(node).toHaveCSS('visibility', 'visible');
@@ -153,6 +152,7 @@ test.describe('Nodes', () => {
await expect(node).toBeAttached(); await expect(node).toBeAttached();
await node.click(); await node.click();
// pressing backspace breaks webkit
await page.keyboard.press('d'); await page.keyboard.press('d');
await expect(node).toBeAttached(); await expect(node).toBeAttached();
@@ -198,8 +198,8 @@ test.describe('Nodes', () => {
await firstOutputHandle.hover(); await firstOutputHandle.hover();
await page.mouse.down(); await page.mouse.down();
// TODO: Does not work in SvelteFlow for whatever reason!?
// await secondOutputHandle.hover(); // await secondOutputHandle.hover();
// Does not work in SvelteFlow for whatever reason!?
// but the following works... // but the following works...
const box = await secondOutputHandle.boundingBox(); const box = await secondOutputHandle.boundingBox();
await page.mouse.move(box!.x + 2, box!.y + 2); await page.mouse.move(box!.x + 2, box!.y + 2);
@@ -229,8 +229,8 @@ test.describe('Nodes', () => {
await firstInputHandle.hover(); await firstInputHandle.hover();
await page.mouse.down(); await page.mouse.down();
// TODO: Does not work in SvelteFlow for whatever reason!?
// await secondInputHandle.hover(); // await secondInputHandle.hover();
// Does not work in SvelteFlow for whatever reason!?
// but the following works... // but the following works...
const box = await secondInputHandle.boundingBox(); const box = await secondInputHandle.boundingBox();
await page.mouse.move(box!.x + 2, box!.y + 2); await page.mouse.move(box!.x + 2, box!.y + 2);
+8 -9
View File
@@ -172,13 +172,12 @@ test.describe('Pane non-default', () => {
}); });
}); });
test.describe('Pane activation keys', () => { // test.describe('Pane activation keys', () => {
test.beforeEach(async ({ page }) => { // test.beforeEach(async ({ page }) => {
// Go to the starting url before each test. // // Go to the starting url before each test.
await page.goto('/tests/generic/pane/activation-keys'); // await page.goto('/tests/generic/pane/activation-keys');
// Wait till the edges are rendered // // Wait till the edges are rendered
await page.waitForSelector('[data-id="first-edge"]', { timeout: 5000 }); // await page.waitForSelector('[data-id="first-edge"]', { timeout: 5000 });
}); // });
// TODO // });
});