From 655a27d572082cc3686890ef2f794f536ccf335d Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:25:55 +0200 Subject: [PATCH] tests: add connectOnClick test --- .../component/2-vue-flow/connect.cy.ts | 21 ++++++++++++++----- .../component/2-vue-flow/updateEdge.cy.ts | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/e2e/cypress/component/2-vue-flow/connect.cy.ts b/e2e/cypress/component/2-vue-flow/connect.cy.ts index cfe82642..e28993e9 100644 --- a/e2e/cypress/component/2-vue-flow/connect.cy.ts +++ b/e2e/cypress/component/2-vue-flow/connect.cy.ts @@ -22,17 +22,18 @@ describe('Check if nodes are connectable', () => { }) }) - it('creates connection', () => { + it('creates connection by dragging', () => { cy.window().then((win) => { const sourceHandle = cy.get(`[data-nodeid="1"].source`) const targetHandle = cy.get(`[data-nodeid="2"].target`) + targetHandle.then((handle) => { const target = handle[0] const { x, y } = target.getBoundingClientRect() sourceHandle .trigger('mousedown', { - which: 1, + button: 0, force: true, view: win, }) @@ -48,10 +49,20 @@ describe('Check if nodes are connectable', () => { view: win, }) - cy.wait(100).then(() => { - expect(store.edges.value).to.have.length(1) - }) + cy.get('.vue-flow__edge').should('have.length', 1) }) }) }) + + it('creates connection by clicking', () => { + store.connectOnClick.value = true + + const sourceHandle = cy.get(`[data-nodeid="1"].source`) + const targetHandle = cy.get(`[data-nodeid="2"].target`) + + sourceHandle.click() + targetHandle.click() + + cy.get('.vue-flow__edge').should('have.length', 1) + }) }) diff --git a/e2e/cypress/component/2-vue-flow/updateEdge.cy.ts b/e2e/cypress/component/2-vue-flow/updateEdge.cy.ts index 68581d44..9cdef0ab 100644 --- a/e2e/cypress/component/2-vue-flow/updateEdge.cy.ts +++ b/e2e/cypress/component/2-vue-flow/updateEdge.cy.ts @@ -45,7 +45,7 @@ describe('Check if edges are updatable', () => { edgeAnchor .trigger('mousedown', { - which: 1, + button: 0, force: true, view: win, })