tests: use timeout to avoid cli run fails

This commit is contained in:
braks
2023-05-25 20:48:26 +02:00
committed by Braks
parent 1a083fc861
commit 9bf9c644be
8 changed files with 92 additions and 85 deletions
+4 -15
View File
@@ -531,8 +531,8 @@ importers:
specifier: workspace:* specifier: workspace:*
version: link:../tooling/tsconfig version: link:../tooling/tsconfig
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: ^4.2.2 specifier: ^4.2.3
version: 4.2.3(vite@4.3.5)(vue@3.2.47) version: 4.2.3(vite@4.3.7)(vue@3.2.47)
cypress: cypress:
specifier: ^12.12.0 specifier: ^12.12.0
version: 12.12.0 version: 12.12.0
@@ -543,8 +543,8 @@ importers:
specifier: ^4.9.5 specifier: ^4.9.5
version: 4.9.5 version: 4.9.5
vite: vite:
specifier: ^4.3.5 specifier: ^4.3.7
version: 4.3.5 version: 4.3.7(@types/node@18.15.12)
vue: vue:
specifier: ^3.2.25 specifier: ^3.2.25
version: 3.2.47 version: 3.2.47
@@ -3068,17 +3068,6 @@ packages:
vue: 3.2.47 vue: 3.2.47
dev: true 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): /@vitejs/plugin-vue@4.2.3(vite@4.3.7)(vue@3.2.47):
resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==} resolution: {integrity: sha512-R6JDUfiZbJA9cMiguQ7jxALsgiprjBeHL5ikpXfJCH62pPHtI+JdJ5xWj6Ev73yXSlYl86+blXn1kZHQ7uElxw==}
engines: {node: ^14.18.0 || >=16.0.0} engines: {node: ^14.18.0 || >=16.0.0}
@@ -1,4 +1,4 @@
import { isEdge, useVueFlow } from '@vue-flow/core' import { useVueFlow } from '@vue-flow/core'
import { getElements } from '../../../utils' import { getElements } from '../../../utils'
const { nodes, edges } = getElements() const { nodes, edges } = getElements()
@@ -24,21 +24,24 @@ describe('Store Action: `addSelectedEdges`', () => {
}) })
it('adds `selected` class to edges', () => { it('adds `selected` class to edges', () => {
cy.get('.vue-flow__edge').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, edge) => { setTimeout(() => {
const edgeId = edge.getAttribute('data-id') cy.get('.vue-flow__edge').then((els) => {
const storedEdge = store.findEdge(edgeId!) 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) { if (index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true) expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected') expect(edge).to.have.class('selected')
} else { } else {
expect(!!storedEdge?.selected).to.eq(false) expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected') expect(edge).to.not.have.class('selected')
} }
})
}) })
}) }, 1)
}) })
}) })
@@ -29,14 +29,17 @@ describe('Store Action: `removeEdges`', () => {
}) })
it('removes edges from DOM', () => { it('removes edges from DOM', () => {
cy.get('.vue-flow__edge').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, edge) => { setTimeout(() => {
const edgeId = edge.getAttribute('data-id') cy.get('.vue-flow__edge').then((els) => {
const storedEdge = store.findEdge(edgeId) els.each((index, edge) => {
const edgeId = edge.getAttribute('data-id')
const storedEdge = store.findEdge(edgeId)
expect(deletedEdges).to.not.include(edgeId) expect(deletedEdges).to.not.include(edgeId)
expect(storedEdge).to.not.eq(undefined) expect(storedEdge).to.not.eq(undefined)
})
}) })
}) }, 1)
}) })
}) })
@@ -27,21 +27,24 @@ describe('Store Action: `removeSelectedEdges`', () => {
}) })
it('removes `selected` class from edges', () => { it('removes `selected` class from edges', () => {
cy.get('.vue-flow__edge').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, edge) => { setTimeout(() => {
const edgeId = edge.getAttribute('data-id') cy.get('.vue-flow__edge').then((els) => {
const storedEdge = store.findEdge(edgeId!) 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) { if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedEdge?.selected).to.eq(true) expect(!!storedEdge?.selected).to.eq(true)
expect(edge).to.have.class('selected') expect(edge).to.have.class('selected')
} else { } else {
expect(!!storedEdge?.selected).to.eq(false) expect(!!storedEdge?.selected).to.eq(false)
expect(edge).to.not.have.class('selected') expect(edge).to.not.have.class('selected')
} }
})
}) })
}) }, 1)
}) })
}) })
@@ -24,21 +24,24 @@ describe('Store Action: `addSelectedNodes`', () => {
}) })
it('adds `selected` class to nodes', () => { it('adds `selected` class to nodes', () => {
cy.get('.vue-flow__node').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, node) => { setTimeout(() => {
const nodeId = node.getAttribute('data-id') cy.get('.vue-flow__node').then((els) => {
const storedNode = store.findNode(nodeId!) 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) { if (index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true) expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected') expect(node).to.have.class('selected')
} else { } else {
expect(!!storedNode?.selected).to.eq(false) expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected') expect(node).to.not.have.class('selected')
} }
})
}) })
}) }, 1)
}) })
}) })
@@ -29,14 +29,17 @@ describe('Store Action: `removeNodes`', () => {
}) })
it('removes nodes from DOM', () => { it('removes nodes from DOM', () => {
cy.get('.vue-flow__node').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, node) => { setTimeout(() => {
const nodeId = node.getAttribute('data-id') cy.get('.vue-flow__node').then((els) => {
const storedNode = store.findNode(nodeId) els.each((index, node) => {
const nodeId = node.getAttribute('data-id')
const storedNode = store.findNode(nodeId)
expect(deletedNodes).to.not.include(nodeId) expect(deletedNodes).to.not.include(nodeId)
expect(storedNode).to.not.eq(undefined) expect(storedNode).to.not.eq(undefined)
})
}) })
}) }, 1)
}) })
}) })
@@ -27,21 +27,24 @@ describe('Store Action: `removeSelectedNodes`', () => {
}) })
it('removes `selected` class from nodes', () => { it('removes `selected` class from nodes', () => {
cy.get('.vue-flow__node').then((els) => { // todo: can we avoid the timeout? without it, the test fails in ci
els.each((index, node) => { setTimeout(() => {
const nodeId = node.getAttribute('data-id') cy.get('.vue-flow__node').then((els) => {
const storedNode = store.findNode(nodeId!) 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) { if (index >= randomNumber2 && index < randomNumber) {
expect(!!storedNode?.selected).to.eq(true) expect(!!storedNode?.selected).to.eq(true)
expect(node).to.have.class('selected') expect(node).to.have.class('selected')
} else { } else {
expect(!!storedNode?.selected).to.eq(false) expect(!!storedNode?.selected).to.eq(false)
expect(node).to.not.have.class('selected') expect(node).to.not.have.class('selected')
} }
})
}) })
}) }, 1)
}) })
}) })
+3 -3
View File
@@ -5,7 +5,7 @@
"scripts": { "scripts": {
"test": "cypress run --component", "test": "cypress run --component",
"open": "cypress open", "open": "cypress open",
"lint": "eslint --ext .js,.ts,.vue ./" "lint": "eslint --ext .js,.ts ./"
}, },
"dependencies": { "dependencies": {
"@vue-flow/background": "workspace:*", "@vue-flow/background": "workspace:*",
@@ -16,11 +16,11 @@
"devDependencies": { "devDependencies": {
"@tooling/eslint-config": "workspace:*", "@tooling/eslint-config": "workspace:*",
"@tooling/tsconfig": "workspace:*", "@tooling/tsconfig": "workspace:*",
"@vitejs/plugin-vue": "^4.2.2", "@vitejs/plugin-vue": "^4.2.3",
"cypress": "^12.12.0", "cypress": "^12.12.0",
"eslint-plugin-cypress": "^2.13.3", "eslint-plugin-cypress": "^2.13.3",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"vite": "^4.3.5", "vite": "^4.3.7",
"vue": "^3.2.25" "vue": "^3.2.25"
} }
} }