@@ -17,7 +17,8 @@ import type { Capability, Clickable } from '~/extension';
1717import { SVGMetadata , type PEdge , type PNode } from '~/glsp/graph' ;
1818import type { ConstructorA } from '~/types' ;
1919import { expect } from '../../../test' ;
20- import { RoutingPointCapability } from '../routing' ;
20+ import { assertIsDefined } from '../../../utils' ;
21+ import { RoutingPointCapability , type RoutingPoint , type RoutingPointKind } from '../routing' ;
2122
2223/**
2324 * Elements can be resized by using the resize handles.
@@ -39,20 +40,30 @@ export function useReconnectCapability<TBase extends ConstructorA<PEdge & Clicka
3940) : Capability < TBase , ReconnectCapability > {
4041 abstract class Mixin extends Base implements ReconnectCapability {
4142 async reconnectSource ( node : PNode & Clickable ) : Promise < void > {
42- await this . reconnect ( node , 0 ) ;
43+ await this . reconnect ( node , 'source' ) ;
4344 await expect ( this . locate ( ) ) . toHaveAttribute ( SVGMetadata . Edge . sourceId , await node . idAttr ( ) ) ;
4445 }
4546
4647 async reconnectTarget ( node : PNode & Clickable ) : Promise < void > {
47- await this . reconnect ( node , - 1 ) ;
48+ await this . reconnect ( node , 'target' ) ;
4849 await expect ( this . locate ( ) ) . toHaveAttribute ( SVGMetadata . Edge . targetId , await node . idAttr ( ) ) ;
4950 }
5051
51- private async reconnect ( node : PNode & Clickable , index : number ) : Promise < void > {
52+ protected async reconnect ( node : PNode & Clickable , dataKind : RoutingPointKind ) : Promise < void > {
5253 const routingPoints = this . routingPoints ( ) ;
5354 await routingPoints . enable ( ) ;
54- const points = await routingPoints . points ( ) ;
55- await points . at ( index ) ! . dragTo ( node . locate ( ) , { force : true } ) ;
55+ let point : RoutingPoint | undefined ;
56+ if ( dataKind === 'source' ) {
57+ point = await routingPoints . sourceHandle ( ) ;
58+ } else if ( dataKind === 'target' ) {
59+ point = await routingPoints . targetHandle ( ) ;
60+ }
61+
62+ assertIsDefined ( point , `Routing point of kind ${ dataKind } not found` ) ;
63+
64+ await this . page . pause ( ) ;
65+ await point . dragTo ( node . locate ( ) , { force : true } ) ;
66+ await this . page . pause ( ) ;
5667 await node . click ( ) ;
5768 await expect ( node ) . toBeSelected ( ) ;
5869 }
0 commit comments