feat(tests): add fitView tests

This commit is contained in:
braks
2023-07-22 21:10:51 +02:00
committed by Braks
parent faee0e3ddc
commit db4c2da9a5
2 changed files with 48 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ export default defineConfig({
screenshotOnRunFailure: false,
retries: 2,
defaultCommandTimeout: 1000,
component: {
devServer: {
framework: 'vue',

View File

@@ -0,0 +1,47 @@
import { useVueFlow } from '@vue-flow/core'
import { getElements } from '../../../utils'
const { nodes, edges } = getElements(2, 2)
describe('Viewport Helper: `fitView`', () => {
const store = useVueFlow({ id: 'test' })
it('fits view', () => {
cy.vueFlow({
nodes,
edges,
fitViewOnInit: false,
})
cy.tryAssertion(() => {
cy.transformationPane().should('have.css', 'transform', `matrix(1, 0, 0, 1, 0, 0)`)
}).then(() => {
cy.wrap(store.fitView()).then(() => {
cy.tryAssertion(() => {
cy.transformationPane().should(
'have.css',
'transform',
`matrix(${store.viewport.value.zoom}, 0, 0, ${store.viewport.value.zoom}, ${store.viewport.value.x}, ${store.viewport.value.y})`,
)
})
})
})
})
it('does not fit view when no node exist', () => {
cy.vueFlow({
nodes: [],
edges: [],
})
cy.tryAssertion(() => {
cy.transformationPane().should('have.css', 'transform', `matrix(1, 0, 0, 1, 0, 0)`)
}).then(() => {
cy.wrap(store.fitView()).then(() => {
cy.tryAssertion(() => {
cy.transformationPane().should('have.css', 'transform', `matrix(1, 0, 0, 1, 0, 0)`)
})
})
})
})
})