tests: add connectOnClick test

This commit is contained in:
braks
2022-10-13 23:23:43 +02:00
committed by Braks
parent 1e5a77d608
commit 655a27d572
2 changed files with 17 additions and 6 deletions
+16 -5
View File
@@ -22,17 +22,18 @@ describe('Check if nodes are connectable', () => {
}) })
}) })
it('creates connection', () => { it('creates connection by dragging', () => {
cy.window().then((win) => { cy.window().then((win) => {
const sourceHandle = cy.get(`[data-nodeid="1"].source`) const sourceHandle = cy.get(`[data-nodeid="1"].source`)
const targetHandle = cy.get(`[data-nodeid="2"].target`) const targetHandle = cy.get(`[data-nodeid="2"].target`)
targetHandle.then((handle) => { targetHandle.then((handle) => {
const target = handle[0] const target = handle[0]
const { x, y } = target.getBoundingClientRect() const { x, y } = target.getBoundingClientRect()
sourceHandle sourceHandle
.trigger('mousedown', { .trigger('mousedown', {
which: 1, button: 0,
force: true, force: true,
view: win, view: win,
}) })
@@ -48,10 +49,20 @@ describe('Check if nodes are connectable', () => {
view: win, view: win,
}) })
cy.wait(100).then(() => { cy.get('.vue-flow__edge').should('have.length', 1)
expect(store.edges.value).to.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)
})
}) })
@@ -45,7 +45,7 @@ describe('Check if edges are updatable', () => {
edgeAnchor edgeAnchor
.trigger('mousedown', { .trigger('mousedown', {
which: 1, button: 0,
force: true, force: true,
view: win, view: win,
}) })