Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 282f471

Browse files
Copilotraimohanska
andcommitted
Improve connection test methods and endpoint handling
Co-authored-by: raimohanska <[email protected]>
1 parent 77647e9 commit 282f471

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

playwright/src/pages/BoardPage.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
},

playwright/src/tests/board.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test.describe("Basic board functionality", () => {
8181
await test.step("Modify connection by dragging endpoint", async () => {
8282
const note3 = await board.createNoteWithText(100, 400, "New Target")
8383
// Drag the connection endpoint to the new note
84-
await board.dragConnectionEndpoint(1, 100, 400) // Move the 'to' endpoint
84+
await board.dragConnectionEndpoint(0, "to", 100, 400) // Move the 'to' endpoint of first connection
8585
await board.assertConnectionExists(1)
8686
})
8787

0 commit comments

Comments
 (0)