tests: use transform matrix to confirm node positions

This commit is contained in:
braks
2024-01-29 21:56:44 +01:00
committed by Braks
parent 3d362cb2d3
commit 8a888a9194
2 changed files with 18 additions and 11 deletions
+1 -1
View File
@@ -969,7 +969,7 @@ export function useActions(
until(() => viewportHelper.value.initialized) until(() => viewportHelper.value.initialized)
.toBe(true) .toBe(true)
.then(async () => { .then(() => {
setTimeout(() => { setTimeout(() => {
state.hooks.paneReady.trigger({ state.hooks.paneReady.trigger({
id, id,
+17 -10
View File
@@ -17,16 +17,23 @@ describe('Render Basic Example', () => {
cy.get('.vue-flow__node').should('have.length', nodes.length) 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 edges', () => {
cy.get('.vue-flow__edge').should('have.length', edges.length)
})
it('renders correct node labels', () => it('renders correct node labels', () => {
cy.get('.vue-flow__node').each((node) => expect(nodes.some((el) => el.label === node.text())).to.be.true)) cy.get('.vue-flow__node').each((node) => expect(nodes.some((el) => el.label === node.text())).to.be.true)
})
it('renders nodes at correct position', () => it('renders nodes at correct position', () => {
cy cy.get('.vue-flow__node').each((el) => {
.get('.vue-flow__node') const node = nodes.find((node) => node.id === el.attr('data-id'))!
.each(
(node) => expect(node).to.exist
expect(nodes.some((el) => el.position.x === node.position().left && el.position.y === node.position().top)).to.be.true,
)) expect(el)
.to.have.css('transform')
.and.match(new RegExp(`matrix\\(1, 0, 0, 1, ${node.position.x}, ${node.position.y}\\)`))
})
})
}) })