Skip to content

Commit 82d9991

Browse files
committed
tests: update handle ids in tests
1 parent 660831c commit 82d9991

File tree

4 files changed

+26
-32
lines changed

4 files changed

+26
-32
lines changed

tests/cypress/component/1-store/edges/connection.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('Store Action: `startConnection`, `updateConnection`, `endConnection`',
5151
store.endConnection()
5252

5353
expect(store.connectionStartHandle.value).to.equal(null)
54-
expect(store.connectionPosition.value).to.deep.equal({ x: NaN, y: NaN })
54+
expect(store.connectionPosition.value).to.deep.equal({ x: Number.NaN, y: Number.NaN })
5555

5656
cy.viewPort().find('.vue-flow__connection').should('not.exist')
5757
})

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ describe('Check if nodes can be connected', () => {
66
beforeEach(() => {
77
cy.vueFlow({
88
fitViewOnInit: false,
9-
modelValue: [
9+
nodes: [
1010
{
1111
id: '1',
12-
label: 'Node 1',
12+
data: { label: 'Node 1' },
1313
position: { x: 0, y: 0 },
1414
},
1515
{
1616
id: '2',
17-
label: 'Node 2',
17+
data: { label: 'Node 2' },
1818
position: { x: 300, y: 300 },
1919
},
2020
],
@@ -57,11 +57,8 @@ describe('Check if nodes can be connected', () => {
5757
expect(edge.source).to.eq('1')
5858
expect(edge.target).to.eq('2')
5959

60-
const sourceHandleId = `1__handle-bottom`
61-
const targetHandleId = `2__handle-top`
62-
63-
expect(edge.sourceHandle).to.eq(sourceHandleId)
64-
expect(edge.targetHandle).to.eq(targetHandleId)
60+
expect(edge.sourceHandle).to.eq(null)
61+
expect(edge.targetHandle).to.eq(null)
6562
})
6663
})
6764

@@ -98,11 +95,8 @@ describe('Check if nodes can be connected', () => {
9895
expect(edge.source).to.eq('1')
9996
expect(edge.target).to.eq('2')
10097

101-
const sourceHandleId = `1__handle-bottom`
102-
const targetHandleId = `2__handle-top`
103-
104-
expect(edge.sourceHandle).to.eq(sourceHandleId)
105-
expect(edge.targetHandle).to.eq(targetHandleId)
98+
expect(edge.sourceHandle).to.eq(null)
99+
expect(edge.targetHandle).to.eq(null)
106100
})
107101
})
108102
})

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ const connectionLineId = 'test-custom-connection-line'
66

77
describe('Custom Connection Line', () => {
88
it('renders a custom connection line component', () => {
9-
const CustomConnectionLine = defineComponent({
10-
props: ['sourceNode', 'sourceHandle', 'targetNode', 'targetHandle', 'sourceX', 'sourceY', 'targetX', 'targetY'],
9+
const CustomConnectionLine = defineComponent<ConnectionLineProps>({
10+
props: ['sourceNode', 'sourceHandle', 'targetNode', 'targetHandle', 'sourceX', 'sourceY', 'targetX', 'targetY'] as any,
1111
emits: ['change'],
1212
setup(props, { emit }) {
1313
watch(
1414
() => props,
15-
() => {
15+
(currProps) => {
1616
emit('change', {
17-
sourceNodeId: props.sourceNode?.id,
18-
sourceHandleId: props.sourceHandle.id,
19-
targetNodeId: props.targetNode?.id,
20-
targetHandleId: props.targetHandle?.id,
17+
sourceNodeId: currProps.sourceNode?.id,
18+
sourceHandleId: currProps.sourceHandle?.id ?? null,
19+
targetNodeId: currProps.targetNode?.id,
20+
targetHandleId: currProps.targetHandle?.id ?? null,
2121
})
2222
},
2323
{ immediate: true, deep: true },
@@ -37,16 +37,16 @@ describe('Custom Connection Line', () => {
3737
{
3838
autoConnect: true,
3939
fitViewOnInit: false,
40-
modelValue: [
40+
nodes: [
4141
{
4242
id: '1',
43-
label: 'Node 1',
43+
data: { label: 'Node 1' },
4444
position: { x: 0, y: 0 },
4545
},
4646
{
4747
id: '2',
4848
type: 'output',
49-
label: 'Node 2',
49+
data: { label: 'Node 2' },
5050
position: { x: 300, y: 300 },
5151
},
5252
],
@@ -79,9 +79,9 @@ describe('Custom Connection Line', () => {
7979

8080
cy.get('@onChangeSpy').should('have.been.calledWith', {
8181
sourceNodeId: '1',
82-
sourceHandleId: '1__handle-bottom',
82+
sourceHandleId: null,
8383
targetNodeId: '2',
84-
targetHandleId: '2__handle-top',
84+
targetHandleId: null,
8585
})
8686

8787
sourceHandle.trigger('mouseup', {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ describe('isValidConnection Prop', () => {
1111

1212
beforeEach(() => {
1313
cy.vueFlow({
14-
modelValue: [
14+
nodes: [
1515
{
1616
id: 'A',
17-
label: 'Node A',
17+
data: { label: 'Node A' },
1818
position: { x: 0, y: 0 },
1919
},
2020
{
2121
id: 'B',
22-
label: 'Node B',
22+
data: { label: 'Node B' },
2323
position: { x: 300, y: 300 },
2424
},
2525
{
2626
id: 'C',
27-
label: 'Node C',
27+
data: { label: 'Node C' },
2828
position: { x: 300, y: 0 },
2929
},
3030
],
@@ -76,8 +76,8 @@ describe('isValidConnection Prop', () => {
7676
view: win,
7777
})
7878

79-
cy.get('.vue-flow__edge[data-id="vueflow__edge-AA__handle-bottom-BB__handle-top"]').should('exist')
80-
cy.get('.vue-flow__edge[data-id="vueflow__edge-AA__handle-bottom-CC__handle-top"]').should('not.exist')
79+
cy.get('.vue-flow__edge[data-id="vueflow__edge-A-B"]').should('exist')
80+
cy.get('.vue-flow__edge[data-id="vueflow__edge-A-C"]').should('not.exist')
8181
})
8282
})
8383
})

0 commit comments

Comments
 (0)