@@ -339,13 +339,20 @@ export function BoardPage(page: Page, browser: Browser) {
339339 // Connection-related methods
340340 async selectConnectTool ( ) {
341341 await page . locator ( ".tool.connect" ) . click ( )
342+ await waitForThrottle ( )
343+ } ,
344+ async selectDefaultTool ( ) {
345+ await page . locator ( ".tool.select, .tool.pan" ) . first ( ) . click ( )
346+ await waitForThrottle ( )
342347 } ,
343348 async createConnection ( fromItem : Locator , toItem : Locator ) {
344349 return await test . step ( "Create connection" , async ( ) => {
345350 await this . selectConnectTool ( )
346351 await fromItem . click ( )
352+ await waitForThrottle ( )
347353 await toItem . click ( )
348354 await waitForThrottle ( )
355+ await this . selectDefaultTool ( ) // Reset to default tool
349356 } )
350357 } ,
351358 getConnections ( ) {
@@ -360,6 +367,14 @@ export function BoardPage(page: Page, browser: Browser) {
360367 getConnectionNode ( nth : number = 0 ) {
361368 return this . getConnectionNodes ( ) . nth ( nth )
362369 } ,
370+ getConnectionFromNode ( connectionIndex : number = 0 ) {
371+ // Each connection has 2 nodes: "from" and "to", so "from" is at connectionIndex*2
372+ return this . getConnectionNodes ( ) . nth ( connectionIndex * 2 )
373+ } ,
374+ getConnectionToNode ( connectionIndex : number = 0 ) {
375+ // Each connection has 2 nodes: "from" and "to", so "to" is at connectionIndex*2+1
376+ return this . getConnectionNodes ( ) . nth ( connectionIndex * 2 + 1 )
377+ } ,
363378 async assertConnectionExists ( count : number = 1 ) {
364379 await expect ( this . getConnections ( ) ) . toHaveCount ( count )
365380 } ,
@@ -369,9 +384,11 @@ export function BoardPage(page: Page, browser: Browser) {
369384 async selectConnection ( nth : number = 0 ) {
370385 await this . getConnection ( nth ) . click ( )
371386 } ,
372- async dragConnectionEndpoint ( connectionNodeNth : number , x : number , y : number ) {
373- return await test . step ( `Drag connection endpoint to (${ x } , ${ y } )` , async ( ) => {
374- const connectionNode = this . getConnectionNode ( connectionNodeNth )
387+ async dragConnectionEndpoint ( connectionIndex : number , endpoint : "from" | "to" , x : number , y : number ) {
388+ return await test . step ( `Drag connection ${ endpoint } endpoint to (${ x } , ${ y } )` , async ( ) => {
389+ const connectionNode = endpoint === "from" ?
390+ this . getConnectionFromNode ( connectionIndex ) :
391+ this . getConnectionToNode ( connectionIndex )
375392 await dragElementOnBoard ( connectionNode , x , y )
376393 } )
377394 } ,
0 commit comments