tests: add connectOnClick test

This commit is contained in:
braks
2022-10-13 11:25:55 +02:00
committed by Braks
parent 1e5a77d608
commit 655a27d572
2 changed files with 17 additions and 6 deletions

View File

@@ -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)
})
})

View File

@@ -45,7 +45,7 @@ describe('Check if edges are updatable', () => {
edgeAnchor
.trigger('mousedown', {
which: 1,
button: 0,
force: true,
view: win,
})