tests: rename flow dir to vue-flow

This commit is contained in:
braks
2022-10-08 23:25:34 +02:00
committed by Braks
parent a6b6a83eb6
commit b547a1fb0c
4 changed files with 0 additions and 0 deletions
@@ -0,0 +1,32 @@
import { getElements } from '../../utils'
const { nodes, edges } = getElements()
describe('Render Basic Example', () => {
beforeEach(() => {
cy.vueFlow({
modelValue: [...nodes, ...edges],
})
})
it('renders a Vue Flow container', () => {
cy.get('.vue-flow').should('exist')
})
it('renders nodes', () => {
cy.get('.vue-flow__node').should('have.length', nodes.length)
})
it('renders edges', () => cy.get('.vue-flow__edge').should('have.length', edges.length))
it('renders correct node labels', () =>
cy.get('.vue-flow__node').each((node) => expect(nodes.some((el) => el.label === node.text())).to.be.true))
it('renders nodes at correct position', () =>
cy
.get('.vue-flow__node')
.each(
(node) =>
expect(nodes.some((el) => el.position.x === node.position().left && el.position.y === node.position().top)).to.be.true,
))
})
@@ -0,0 +1,57 @@
import { useVueFlow } from '@braks/vue-flow'
describe('Check if nodes are connectable', () => {
const store = useVueFlow({ id: 'test' })
beforeEach(() => {
cy.vueFlow({
fitViewOnInit: false,
modelValue: [
{
id: '1',
label: 'Node 1',
position: { x: 0, y: 0 },
},
{
id: '2',
label: 'Node 2',
position: { x: 300, y: 300 },
},
],
autoConnect: true,
})
})
it('creates connection', () => {
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,
force: true,
view: win,
})
.trigger('mousemove', {
clientX: x + 5,
clientY: y + 5,
force: true,
})
.trigger('mouseup', {
clientX: x + 5,
clientY: y + 5,
force: true,
view: win,
})
cy.wait(100).then(() => {
expect(store.edges.value).to.have.length(1)
})
})
})
})
})
@@ -0,0 +1,33 @@
import { getElements } from '../../utils'
const { nodes } = getElements(1, 1)
describe('Check if nodes are draggable', () => {
beforeEach(() => {
cy.vueFlow({
modelValue: [nodes[0]],
})
})
it('drags nodes', () => {
cy.window().then((win) => {
cy.get(`[data-id="${nodes[0].id}"]`)
.trigger('mousedown', {
which: 1,
force: true,
view: win,
})
.trigger('mousemove', {
clientX: 100,
clientY: 100,
force: true,
})
.trigger('mouseup', {
force: true,
view: win,
})
cy.get(`[data-id="${nodes[0].id}"]`).should('not.have.css', 'transform', 'matrix(1, 0, 0, 1, 0, 0)')
})
})
})
@@ -0,0 +1,73 @@
import { useVueFlow } from '@braks/vue-flow'
describe('Check if edges are updatable', () => {
const store = useVueFlow({ id: 'test' })
store.onEdgeUpdate((params) => store.updateEdge(params.edge, params.connection))
beforeEach(() => {
cy.vueFlow({
fitViewOnInit: false,
edgesUpdatable: true,
modelValue: [
{
id: '1',
label: 'Node 1',
position: { x: 0, y: 0 },
},
{
id: '2',
label: 'Node 2',
position: { x: 300, y: 300 },
},
{
id: '3',
label: 'Node 3',
position: { x: 300, y: 0 },
},
{
id: 'e1-2',
source: '1',
target: '2',
},
],
autoConnect: true,
})
})
it('updates edge', () => {
cy.window().then((win) => {
const edgeAnchor = cy.get('.vue-flow__edgeupdater[data-type="target"]')
const targetTargetHandle = cy.get(`[data-nodeid="3"].target`)
targetTargetHandle.then((handle) => {
const target = handle[0]
const { x, y } = target.getBoundingClientRect()
edgeAnchor
.trigger('mousedown', {
which: 1,
force: true,
view: win,
})
.trigger('mousemove', {
clientX: x + 5,
clientY: y + 5,
force: true,
})
.trigger('mouseup', {
clientX: x + 5,
clientY: y + 5,
force: true,
view: win,
})
cy.wait(100).then(() => {
const storedEdges = store.edges.value
expect(storedEdges).to.have.length(1)
expect(storedEdges[0].target).to.equal('3')
expect(storedEdges[0].source).to.equal('1')
})
})
})
})
})