tests: update handle ids in tests

This commit is contained in:
braks
2024-06-06 10:45:38 +02:00
committed by Braks
parent 660831cc37
commit 82d99915d3
4 changed files with 26 additions and 32 deletions
@@ -51,7 +51,7 @@ describe('Store Action: `startConnection`, `updateConnection`, `endConnection`',
store.endConnection() store.endConnection()
expect(store.connectionStartHandle.value).to.equal(null) expect(store.connectionStartHandle.value).to.equal(null)
expect(store.connectionPosition.value).to.deep.equal({ x: NaN, y: NaN }) expect(store.connectionPosition.value).to.deep.equal({ x: Number.NaN, y: Number.NaN })
cy.viewPort().find('.vue-flow__connection').should('not.exist') cy.viewPort().find('.vue-flow__connection').should('not.exist')
}) })
@@ -6,15 +6,15 @@ describe('Check if nodes can be connected', () => {
beforeEach(() => { beforeEach(() => {
cy.vueFlow({ cy.vueFlow({
fitViewOnInit: false, fitViewOnInit: false,
modelValue: [ nodes: [
{ {
id: '1', id: '1',
label: 'Node 1', data: { label: 'Node 1' },
position: { x: 0, y: 0 }, position: { x: 0, y: 0 },
}, },
{ {
id: '2', id: '2',
label: 'Node 2', data: { label: 'Node 2' },
position: { x: 300, y: 300 }, position: { x: 300, y: 300 },
}, },
], ],
@@ -57,11 +57,8 @@ describe('Check if nodes can be connected', () => {
expect(edge.source).to.eq('1') expect(edge.source).to.eq('1')
expect(edge.target).to.eq('2') expect(edge.target).to.eq('2')
const sourceHandleId = `1__handle-bottom` expect(edge.sourceHandle).to.eq(null)
const targetHandleId = `2__handle-top` expect(edge.targetHandle).to.eq(null)
expect(edge.sourceHandle).to.eq(sourceHandleId)
expect(edge.targetHandle).to.eq(targetHandleId)
}) })
}) })
@@ -98,11 +95,8 @@ describe('Check if nodes can be connected', () => {
expect(edge.source).to.eq('1') expect(edge.source).to.eq('1')
expect(edge.target).to.eq('2') expect(edge.target).to.eq('2')
const sourceHandleId = `1__handle-bottom` expect(edge.sourceHandle).to.eq(null)
const targetHandleId = `2__handle-top` expect(edge.targetHandle).to.eq(null)
expect(edge.sourceHandle).to.eq(sourceHandleId)
expect(edge.targetHandle).to.eq(targetHandleId)
}) })
}) })
}) })
@@ -6,18 +6,18 @@ const connectionLineId = 'test-custom-connection-line'
describe('Custom Connection Line', () => { describe('Custom Connection Line', () => {
it('renders a custom connection line component', () => { it('renders a custom connection line component', () => {
const CustomConnectionLine = defineComponent({ const CustomConnectionLine = defineComponent<ConnectionLineProps>({
props: ['sourceNode', 'sourceHandle', 'targetNode', 'targetHandle', 'sourceX', 'sourceY', 'targetX', 'targetY'], props: ['sourceNode', 'sourceHandle', 'targetNode', 'targetHandle', 'sourceX', 'sourceY', 'targetX', 'targetY'] as any,
emits: ['change'], emits: ['change'],
setup(props, { emit }) { setup(props, { emit }) {
watch( watch(
() => props, () => props,
() => { (currProps) => {
emit('change', { emit('change', {
sourceNodeId: props.sourceNode?.id, sourceNodeId: currProps.sourceNode?.id,
sourceHandleId: props.sourceHandle.id, sourceHandleId: currProps.sourceHandle?.id ?? null,
targetNodeId: props.targetNode?.id, targetNodeId: currProps.targetNode?.id,
targetHandleId: props.targetHandle?.id, targetHandleId: currProps.targetHandle?.id ?? null,
}) })
}, },
{ immediate: true, deep: true }, { immediate: true, deep: true },
@@ -37,16 +37,16 @@ describe('Custom Connection Line', () => {
{ {
autoConnect: true, autoConnect: true,
fitViewOnInit: false, fitViewOnInit: false,
modelValue: [ nodes: [
{ {
id: '1', id: '1',
label: 'Node 1', data: { label: 'Node 1' },
position: { x: 0, y: 0 }, position: { x: 0, y: 0 },
}, },
{ {
id: '2', id: '2',
type: 'output', type: 'output',
label: 'Node 2', data: { label: 'Node 2' },
position: { x: 300, y: 300 }, position: { x: 300, y: 300 },
}, },
], ],
@@ -79,9 +79,9 @@ describe('Custom Connection Line', () => {
cy.get('@onChangeSpy').should('have.been.calledWith', { cy.get('@onChangeSpy').should('have.been.calledWith', {
sourceNodeId: '1', sourceNodeId: '1',
sourceHandleId: '1__handle-bottom', sourceHandleId: null,
targetNodeId: '2', targetNodeId: '2',
targetHandleId: '2__handle-top', targetHandleId: null,
}) })
sourceHandle.trigger('mouseup', { sourceHandle.trigger('mouseup', {
@@ -11,20 +11,20 @@ describe('isValidConnection Prop', () => {
beforeEach(() => { beforeEach(() => {
cy.vueFlow({ cy.vueFlow({
modelValue: [ nodes: [
{ {
id: 'A', id: 'A',
label: 'Node A', data: { label: 'Node A' },
position: { x: 0, y: 0 }, position: { x: 0, y: 0 },
}, },
{ {
id: 'B', id: 'B',
label: 'Node B', data: { label: 'Node B' },
position: { x: 300, y: 300 }, position: { x: 300, y: 300 },
}, },
{ {
id: 'C', id: 'C',
label: 'Node C', data: { label: 'Node C' },
position: { x: 300, y: 0 }, position: { x: 300, y: 0 },
}, },
], ],
@@ -76,8 +76,8 @@ describe('isValidConnection Prop', () => {
view: win, view: win,
}) })
cy.get('.vue-flow__edge[data-id="vueflow__edge-AA__handle-bottom-BB__handle-top"]').should('exist') cy.get('.vue-flow__edge[data-id="vueflow__edge-A-B"]').should('exist')
cy.get('.vue-flow__edge[data-id="vueflow__edge-AA__handle-bottom-CC__handle-top"]').should('not.exist') cy.get('.vue-flow__edge[data-id="vueflow__edge-A-C"]').should('not.exist')
}) })
}) })
}) })