tests: use timeout to avoid cli run fails

This commit is contained in:
braks
2023-05-17 19:16:41 +02:00
committed by Braks
parent 1a083fc861
commit 9bf9c644be
8 changed files with 92 additions and 85 deletions

19
pnpm-lock.yaml generated
View File

@@ -531,8 +531,8 @@ importers:
specifier: workspace:*
version: link:../tooling/tsconfig
'@vitejs/plugin-vue':
specifier: ^4.2.2
version: 4.2.3(vite@4.3.5)(vue@3.2.47)
specifier: ^4.2.3
version: 4.2.3(vite@4.3.7)(vue@3.2.47)
cypress:
specifier: ^12.12.0
version: 12.12.0
@@ -543,8 +543,8 @@ importers:
specifier: ^4.9.5
version: 4.9.5
vite:
specifier: ^4.3.5
version: 4.3.5
specifier: ^4.3.7
version: 4.3.7(@types/node@18.15.12)
vue:
specifier: ^3.2.25
version: 3.2.47
@@ -3068,17 +3068,6 @@ packages:
vue: 3.2.47
dev: true
/@vitejs/plugin-vue@4.2.3(vite@4.3.5)(vue@3.2.47):
resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==}
engines: {node: ^14.18.0 || >=16.0.0}
peerDependencies:
vite: ^4.0.0
vue: ^3.2.25
dependencies:
vite: 4.3.5
vue: 3.2.47
dev: true
/@vitejs/plugin-vue@4.2.3(vite@4.3.7)(vue@3.2.47):
resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==}
engines: {node: ^14.18.0 || >=16.0.0}

View File

@@ -1,4 +1,4 @@
import { isEdge, useVueFlow } from '@vue-flow/core'
import { useVueFlow } from '@vue-flow/core'
import { getElements } from '../../../utils'
const { nodes, edges } = getElements()
@@ -24,21 +24,24 @@ describe('Store Action: `addSelectedEdges`', () => {
})
it('adds `selected` class to edges', () => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId!)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId!)
expect(storedEdge).to.not.eq(undefined)
expect(storedEdge).to.not.eq(undefined)
if (index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected')
} else {
expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected')
}
if (index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected')
} else {
expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected')
}
})
})
})
}, 1)
})
})

View File

@@ -29,14 +29,17 @@ describe('Store Action: `removeEdges`', () => {
})
it('removes edges from DOM', () => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId)
expect(deletedEdges).to.not.include(edgeId)
expect(storedEdge).to.not.eq(undefined)
expect(deletedEdges).to.not.include(edgeId)
expect(storedEdge).to.not.eq(undefined)
})
})
})
}, 1)
})
})

View File

@@ -27,21 +27,24 @@ describe('Store Action: `removeSelectedEdges`', () => {
})
it('removes `selected` class from edges', () => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId!)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__edge').then((els) => {
els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId!)
expect(storedEdge && isEdge(storedEdge)).to.eq(true)
expect(storedEdge && isEdge(storedEdge)).to.eq(true)
if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected')
} else {
expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected')
}
if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected')
} else {
expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected')
}
})
})
})
}, 1)
})
})

View File

@@ -24,21 +24,24 @@ describe('Store Action: `addSelectedNodes`', () => {
})
it('adds `selected` class to nodes', () => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId!)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId!)
expect(storedNode && isNode(storedNode)).to.eq(true)
expect(storedNode && isNode(storedNode)).to.eq(true)
if (index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected')
} else {
expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected')
}
if (index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected')
} else {
expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected')
}
})
})
})
}, 1)
})
})

View File

@@ -29,14 +29,17 @@ describe('Store Action: `removeNodes`', () => {
})
it('removes nodes from DOM', () => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId)
expect(deletedNodes).to.not.include(nodeId)
expect(storedNode).to.not.eq(undefined)
expect(deletedNodes).to.not.include(nodeId)
expect(storedNode).to.not.eq(undefined)
})
})
})
}, 1)
})
})

View File

@@ -27,21 +27,24 @@ describe('Store Action: `removeSelectedNodes`', () => {
})
it('removes `selected` class from nodes', () => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId!)
// todo: can we avoid the timeout? without it, the test fails in ci
setTimeout(() => {
cy.get('.vue-flow__node').then((els) => {
els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId!)
expect(storedNode && isNode(storedNode)).to.eq(true)
expect(storedNode && isNode(storedNode)).to.eq(true)
if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected')
} else {
expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected')
}
if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected')
} else {
expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected')
}
})
})
})
}, 1)
})
})

View File

@@ -5,7 +5,7 @@
"scripts": {
"test": "cypress run --component",
"open": "cypress open",
"lint": "eslint --ext .js,.ts,.vue ./"
"lint": "eslint --ext .js,.ts ./"
},
"dependencies": {
"@vue-flow/background": "workspace:*",
@@ -16,11 +16,11 @@
"devDependencies": {
"@tooling/eslint-config": "workspace:*",
"@tooling/tsconfig": "workspace:*",
"@vitejs/plugin-vue": "^4.2.2",
"@vitejs/plugin-vue": "^4.2.3",
"cypress": "^12.12.0",
"eslint-plugin-cypress": "^2.13.3",
"typescript": "^4.9.5",
"vite": "^4.3.5",
"vite": "^4.3.7",
"vue": "^3.2.25"
}
}