refactor(cypress): update cypress, move testing to root level

This commit is contained in:
Christopher Möller
2022-07-26 18:20:52 +02:00
parent 09abf2823d
commit 141a9763f8
16 changed files with 871 additions and 39 deletions

11
cypress.config.js Normal file
View File

@@ -0,0 +1,11 @@
const { defineConfig } = require('cypress');
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
viewportWidth: 1280,
viewportHeight: 720,
video: false,
supportFile: false,
},
});

View File

@@ -1,6 +1,6 @@
describe('Basic Flow Rendering', () => {
before(() => {
cy.visit('/basic');
cy.visit('/');
});
it('renders a flow with three nodes', () => {
@@ -29,7 +29,9 @@ describe('Basic Flow Rendering', () => {
});
it('selects a node by click', () => {
cy.get('.react-flow__node:first').click({ force: true }).should('have.class', 'selected');
cy.get('.react-flow__node:first')
.click({ force: true })
.should('have.class', 'selected');
});
it('deselects node', () => {
@@ -38,7 +40,9 @@ describe('Basic Flow Rendering', () => {
});
it('selects an edge by click', () => {
cy.get('.react-flow__edge:first').click({ force: true }).should('have.class', 'selected');
cy.get('.react-flow__edge:first')
.click({ force: true })
.should('have.class', 'selected');
});
it('deselects edge', () => {
@@ -89,11 +93,15 @@ describe('Basic Flow Rendering', () => {
});
it('selects an edge', () => {
cy.get('.react-flow__edge:first').click({ force: true }).should('have.class', 'selected');
cy.get('.react-flow__edge:first')
.click({ force: true })
.should('have.class', 'selected');
});
it('drags a node', () => {
const styleBeforeDrag = Cypress.$('.react-flow__node:first').css('transform');
const styleBeforeDrag = Cypress.$('.react-flow__node:first').css(
'transform'
);
cy.drag('.react-flow__node:first', { x: 500, y: 25 }).then(($el) => {
const styleAfterDrag = $el.css('transform');
@@ -145,7 +153,9 @@ describe('Basic Flow Rendering', () => {
.wait(50)
.trigger('mouseup', { force: true, view: win })
.then(() => {
const styleAfterDrag = Cypress.$('.react-flow__viewport').css('transform');
const styleAfterDrag = Cypress.$('.react-flow__viewport').css(
'transform'
);
expect(styleBeforeDrag).to.not.equal(styleAfterDrag);
});
});
@@ -158,7 +168,9 @@ describe('Basic Flow Rendering', () => {
.trigger('wheel', 'topLeft', { deltaY: -200 })
.wait(50)
.then(() => {
const styleAfterZoom = Cypress.$('.react-flow__viewport').css('transform');
const styleAfterZoom = Cypress.$('.react-flow__viewport').css(
'transform'
);
expect(styleBeforeZoom).to.not.equal(styleAfterZoom);
});
});

View File

@@ -12,7 +12,8 @@
"scripts": {
"dev": "preconstruct watch",
"postinstall": "preconstruct dev",
"build": "preconstruct build"
"build": "preconstruct build",
"test": "cypress run --browser chrome"
},
"dependencies": {
"react": "^18.1.0",
@@ -25,6 +26,7 @@
"@babel/preset-typescript": "^7.17.12",
"@preconstruct/cli": "^2.1.8",
"autoprefixer": "^10.4.7",
"cypress": "^10.3.1",
"postcss": "^8.4.14",
"postcss-nested": "^5.0.6",
"typescript": "^4.7.4"

View File

@@ -1,7 +0,0 @@
{
"plugins": {
"autoprefixer" : {},
"postcss-nested": {}
}
}

View File

@@ -1,7 +0,0 @@
{
"baseUrl": "http://localhost:3000",
"viewportWidth": 1280,
"viewportHeight": 720,
"video": false,
"pluginsFile": false
}

View File

@@ -1,5 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

850
yarn.lock

File diff suppressed because it is too large Load Diff