tests: use transform matrix to confirm node positions

This commit is contained in:
braks
2024-01-29 19:13:44 +01:00
committed by Braks
parent 3d362cb2d3
commit 8a888a9194
2 changed files with 18 additions and 11 deletions

View File

@@ -969,7 +969,7 @@ export function useActions(
until(() => viewportHelper.value.initialized)
.toBe(true)
.then(async () => {
.then(() => {
setTimeout(() => {
state.hooks.paneReady.trigger({
id,

View File

@@ -17,16 +17,23 @@ describe('Render Basic Example', () => {
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', () =>
cy.get('.vue-flow__node').each((node) => expect(nodes.some((el) => el.label === node.text())).to.be.true))
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,
))
it('renders nodes at correct position', () => {
cy.get('.vue-flow__node').each((el) => {
const node = nodes.find((node) => node.id === el.attr('data-id'))!
expect(node).to.exist
expect(el)
.to.have.css('transform')
.and.match(new RegExp(`matrix\\(1, 0, 0, 1, ${node.position.x}, ${node.position.y}\\)`))
})
})
})