Skip to content

Commit e10663a

Browse files
committed
tests: add custom edge test
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent c4c4c66 commit e10663a

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import type { EdgeComponent } from '@vue-flow/core'
2+
import { BaseEdge, getBezierPath } from '@vue-flow/core'
3+
import { h, markRaw } from 'vue'
4+
5+
const CustomEdge: EdgeComponent = (props) => {
6+
const path = getBezierPath(props)
7+
return h(BaseEdge as any, { path: path[0], class: 'test-custom-edge' })
8+
}
9+
10+
describe('Check if custom nodes are rendered', () => {
11+
beforeEach(() => {
12+
cy.vueFlow({
13+
fitViewOnInit: false,
14+
modelValue: [
15+
{
16+
id: '1',
17+
label: 'Node 1',
18+
position: { x: 0, y: 0 },
19+
},
20+
{
21+
id: '2',
22+
type: 'output',
23+
label: 'Node 2',
24+
position: { x: 300, y: 300 },
25+
},
26+
{
27+
id: 'e1-2',
28+
source: '1',
29+
target: '2',
30+
type: 'custom',
31+
},
32+
],
33+
edgeTypes: {
34+
custom: markRaw(CustomEdge),
35+
},
36+
})
37+
})
38+
39+
it('renders custom edge', () => {
40+
cy.get('.vue-flow__edge-custom').should('have.length', 1)
41+
42+
cy.get('.test-custom-edge').should('have.length', 1)
43+
})
44+
})

tests/cypress/component/2-vue-flow/customNode.cy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CustomNode: NodeComponent = defineComponent(() => {
77
h('div', { class: 'vue-flow__node-default' }, [
88
h(Handle as any, { id: 'handle-1', position: 'left', type: 'target', style: { top: '5px' } }),
99
h(Handle as any, { id: 'handle-2', position: 'left', type: 'target', style: { bottom: '-10px' } }),
10-
'Custom Node',
10+
h('div', { class: 'test-custom-node' }, 'Custom Node'),
1111
h(Handle as any, { id: 'handle-3', position: 'right' }),
1212
])
1313
})
@@ -32,11 +32,14 @@ describe('Check if custom nodes are rendered', () => {
3232
nodeTypes: {
3333
custom: markRaw(CustomNode),
3434
},
35-
autoConnect: true,
3635
})
3736
})
3837

3938
it('renders custom node', () => {
4039
cy.get('.vue-flow__node-custom').should('have.length', 1)
40+
41+
cy.get('.test-custom-node').should('have.length', 1).should('contain', 'Custom Node')
42+
43+
cy.get('.vue-flow__node-custom').should('have.css', 'transform', 'matrix(1, 0, 0, 1, 300, 300)')
4144
})
4245
})

0 commit comments

Comments
 (0)