Created e2e tests for node interactions

This commit is contained in:
Peter
2023-10-25 16:57:22 +02:00
parent eca85310e1
commit 45ae126d43
7 changed files with 303 additions and 63 deletions
@@ -41,6 +41,7 @@ const initialNodes: Node[] = [
data: { label: 'Node 4' },
position: { x: 400, y: 200 },
className: 'light',
connectable: false,
},
];
@@ -0,0 +1,26 @@
<script lang="ts">
import type { NodeProps } from '@xyflow/svelte';
type $$Props = NodeProps;
</script>
<div class="container">
<div class="drag-handle custom-drag-handle" />
</div>
<style>
.container {
width: 100px;
height: 50px;
background: red;
display: flex;
align-items: center;
justify-content: center;
}
.drag-handle {
display: inline-block;
width: 25px;
height: 25px;
background-color: green;
}
</style>
@@ -3,10 +3,16 @@
import { initialNodes, initialEdges } from './nodesAndEdges';
import { SvelteFlow } from '@xyflow/svelte';
import DragHandleNode from './DragHandleNode.svelte';
import '@xyflow/svelte/dist/style.css';
const nodes = writable(initialNodes);
const edges = writable(initialEdges);
const nodeTypes = {
DragHandleNode
};
</script>
<SvelteFlow {nodes} {edges} fitView />
<SvelteFlow {nodes} {nodeTypes} {edges} fitView />
@@ -2,50 +2,61 @@ import type { Edge, Node } from '@xyflow/svelte';
export const initialNodes: Node[] = [
{
id: '1',
data: { label: '1' },
id: 'Node-1',
data: { label: 'Node-1' },
position: { x: 0, y: 0 },
class: 'test-class',
type: 'input',
class: 'playwright-test-class-123',
style: 'background-color: red;'
},
{
id: '2',
data: { label: '2' },
id: 'Node-2',
type: 'output',
data: { label: 'Node-2' },
position: { x: -100, y: 100 }
},
{
id: '3',
data: { label: '3' },
id: 'Node-3',
data: { label: 'Node-3' },
position: { x: 100, y: 100 }
},
{
id: '4',
data: { label: '4' },
position: { x: 0, y: 200 }
id: 'Node-4',
data: { label: 'Node-4' },
position: { x: 0, y: 200 },
type: 'output'
},
{
id: 'drag-handle',
data: { label: 'Drag Handle' },
position: { x: 200, y: 0 },
type: 'DragHandleNode',
dragHandle: '.custom-drag-handle'
},
{
id: 'notConnectable',
type: 'output',
data: { label: 'notConnectable' },
position: { x: 0, y: 300 },
connectable: false
},
{
id: 'notDraggable',
data: { label: 'notDraggable' },
position: { x: 0, y: 300 },
position: { x: 0, y: 400 },
draggable: false
},
{
id: 'notSelectable',
data: { label: 'notSelectable' },
position: { x: 0, y: 400 },
selectable: false
},
{
id: 'notConnectable',
data: { label: 'notConnectable' },
position: { x: 0, y: 500 },
connectable: false
selectable: false
},
{
id: 'notDeletable',
data: { label: 'notDeletable' },
position: { x: 0, y: 600 },
connectable: false
deletable: false
},
{
id: 'hidden',
@@ -59,15 +70,15 @@ export const initialEdges: Edge[] = [
{
id: '1-2',
type: 'default',
source: '1',
target: '2',
source: 'Node-1',
target: 'Node-2',
label: 'edge'
},
{
id: '1-3',
type: 'default',
source: '1',
target: '3',
source: 'Node-1',
target: 'Node-3',
label: 'edge'
}
];