feat: cypress E2E testing (#2002)
* feat: cypress * dev: move cypress in dev + setup bash script * fix: cypress docker network host * fix: override cypress baseUrl * fix: cypress ci-run.sh dir path * fix: cypress ci-run vars * fix: cypress missing group * fix: cypress path config * fix: cypress record key * fix: remove cypress run file * fix: cypress mssql delay * misc: use current docker build for cypress tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
extends:
|
extends:
|
||||||
- requarks
|
- requarks
|
||||||
- plugin:vue/strongly-recommended
|
- plugin:vue/strongly-recommended
|
||||||
|
- plugin:cypress/recommended
|
||||||
env:
|
env:
|
||||||
node: true
|
node: true
|
||||||
jest: true
|
jest: true
|
||||||
|
|||||||
10
cypress.json
Normal file
10
cypress.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"baseUrl": "http://localhost:3000",
|
||||||
|
"projectId": "r7qxah",
|
||||||
|
"fixturesFolder": false,
|
||||||
|
"integrationFolder": "dev/cypress/integration",
|
||||||
|
"pluginsFile": "dev/cypress/plugins/index.js",
|
||||||
|
"screenshotsFolder": "dev/cypress/screenshots",
|
||||||
|
"supportFile": "dev/cypress/support/index.js",
|
||||||
|
"videosFolder": "dev/cypress/videos"
|
||||||
|
}
|
||||||
31
dev/cypress/ci-setup.sh
Normal file
31
dev/cypress/ci-setup.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
case $TEST_MATRIX in
|
||||||
|
postgres)
|
||||||
|
echo "Using PostgreSQL..."
|
||||||
|
docker run -d -p 5432:5432 --name db --network="host" -e "POSTGRES_PASSWORD=Password123!" -e "POSTGRES_USER=wiki" -e "POSTGRES_DB=wiki" postgres:11
|
||||||
|
docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=postgres" -e "DB_HOST=localhost" -e "DB_PORT=5432" -e "DB_NAME=wiki" -e "DB_USER=wiki" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER
|
||||||
|
;;
|
||||||
|
mysql)
|
||||||
|
echo "Using MySQL..."
|
||||||
|
docker run -d -p 3306:3306 --name db --network="host" -e "MYSQL_ROOT_PASSWORD=Password123!" -e "MYSQL_USER=wiki" -e "MYSQL_PASSWORD=Password123!" -e "MYSQL_DATABASE=wiki" mysql:8
|
||||||
|
docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=mysql" -e "DB_HOST=localhost" -e "DB_PORT=3306" -e "DB_NAME=wiki" -e "DB_USER=wiki" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER
|
||||||
|
;;
|
||||||
|
mariadb)
|
||||||
|
echo "Using MariaDB..."
|
||||||
|
docker run -d -p 3306:3306 --name db --network="host" -e "MYSQL_ROOT_PASSWORD=Password123!" -e "MYSQL_USER=wiki" -e "MYSQL_PASSWORD=Password123!" -e "MYSQL_DATABASE=wiki" mariadb:10
|
||||||
|
docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=mariadb" -e "DB_HOST=localhost" -e "DB_PORT=3306" -e "DB_NAME=wiki" -e "DB_USER=wiki" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER
|
||||||
|
;;
|
||||||
|
mssql)
|
||||||
|
echo "Using MS SQL Server..."
|
||||||
|
docker run -d -p 1433:1433 --name db --network="host" -e "SA_PASSWORD=Password123!" -e "ACCEPT_EULA=wiki" -e "MYSQL_PASSWORD=Password123!" -e "MYSQL_DATABASE=wiki" mcr.microsoft.com/mssql/server:2019-latest
|
||||||
|
sleep 30
|
||||||
|
docker exec db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password123!" -Q 'CREATE DATABASE wiki'
|
||||||
|
docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=mssql" -e "DB_HOST=localhost" -e "DB_PORT=1433" -e "DB_NAME=wiki" -e "DB_USER=SA" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER
|
||||||
|
;;
|
||||||
|
sqlite)
|
||||||
|
echo "Using SQLite..."
|
||||||
|
docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=sqlite" -e "DB_FILEPATH=db.sqlite" requarks/wiki:canary-$BUILD_BUILDNUMBER
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid DB Type!"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
30
dev/cypress/integration/setup.spec.js
Normal file
30
dev/cypress/integration/setup.spec.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
|
describe('Setup', () => {
|
||||||
|
it('Load the setup page', () => {
|
||||||
|
cy.visit('/')
|
||||||
|
cy.contains('You are about to install Wiki.js').should('exist')
|
||||||
|
})
|
||||||
|
it('Enter administrator email address', () => {
|
||||||
|
cy.get('.v-input').contains('Administrator Email').next('input').click().type('test@example.com')
|
||||||
|
})
|
||||||
|
it('Enter a password', () => {
|
||||||
|
cy.get('.v-input').contains('Password').next('input').click().type('12345678')
|
||||||
|
cy.get('.v-input').contains('Confirm Password').next('input').click().type('12345678')
|
||||||
|
})
|
||||||
|
it('Enter a Site URL', () => {
|
||||||
|
cy.get('.v-input').contains('Site URL').next('input').click().clear().type('http://localhost:3000')
|
||||||
|
})
|
||||||
|
it('Disable Telemetry', () => {
|
||||||
|
cy.contains('Telemetry').next('.v-input').click()
|
||||||
|
})
|
||||||
|
it('Press Install', () => {
|
||||||
|
cy.get('.v-card__actions').find('button').click()
|
||||||
|
})
|
||||||
|
it('Wait for install success', () => {
|
||||||
|
cy.contains('Installation complete!', {timeout: 30000}).should('exist')
|
||||||
|
})
|
||||||
|
it('Redirect to login page', () => {
|
||||||
|
cy.location('pathname', {timeout: 10000}).should('include', '/login')
|
||||||
|
})
|
||||||
|
})
|
||||||
21
dev/cypress/plugins/index.js
Normal file
21
dev/cypress/plugins/index.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
// ***********************************************************
|
||||||
|
// This example plugins/index.js can be used to load plugins
|
||||||
|
//
|
||||||
|
// You can change the location of this file or turn off loading
|
||||||
|
// the plugins file with the 'pluginsFile' configuration option.
|
||||||
|
//
|
||||||
|
// You can read more here:
|
||||||
|
// https://on.cypress.io/plugins-guide
|
||||||
|
// ***********************************************************
|
||||||
|
|
||||||
|
// This function is called when a project is opened or re-opened (e.g. due to
|
||||||
|
// the project's config changing)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Cypress.PluginConfig}
|
||||||
|
*/
|
||||||
|
module.exports = (on, config) => {
|
||||||
|
// `on` is used to hook into various events Cypress emits
|
||||||
|
// `config` is the resolved Cypress config
|
||||||
|
}
|
||||||
25
dev/cypress/support/commands.js
Normal file
25
dev/cypress/support/commands.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// ***********************************************
|
||||||
|
// This example commands.js shows you how to
|
||||||
|
// create various custom commands and overwrite
|
||||||
|
// existing commands.
|
||||||
|
//
|
||||||
|
// For more comprehensive examples of custom
|
||||||
|
// commands please read more here:
|
||||||
|
// https://on.cypress.io/custom-commands
|
||||||
|
// ***********************************************
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -- This is a parent command --
|
||||||
|
// Cypress.Commands.add("login", (email, password) => { ... })
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -- This is a child command --
|
||||||
|
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -- This is a dual command --
|
||||||
|
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -- This will overwrite an existing command --
|
||||||
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||||
20
dev/cypress/support/index.js
Normal file
20
dev/cypress/support/index.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// ***********************************************************
|
||||||
|
// This example support/index.js is processed and
|
||||||
|
// loaded automatically before your test files.
|
||||||
|
//
|
||||||
|
// This is a great place to put global configuration and
|
||||||
|
// behavior that modifies Cypress.
|
||||||
|
//
|
||||||
|
// You can change the location of this file or turn off
|
||||||
|
// automatically serving support files with the
|
||||||
|
// 'supportFile' configuration option.
|
||||||
|
//
|
||||||
|
// You can read more here:
|
||||||
|
// https://on.cypress.io/configuration
|
||||||
|
// ***********************************************************
|
||||||
|
|
||||||
|
// Import commands.js using ES2015 syntax:
|
||||||
|
import './commands'
|
||||||
|
|
||||||
|
// Alternatively you can use CommonJS syntax:
|
||||||
|
// require('./commands')
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
"dev": "node dev",
|
"dev": "node dev",
|
||||||
"build": "webpack --profile --config dev/webpack/webpack.prod.js",
|
"build": "webpack --profile --config dev/webpack/webpack.prod.js",
|
||||||
"watch": "webpack --config dev/webpack/webpack.dev.js",
|
"watch": "webpack --config dev/webpack/webpack.dev.js",
|
||||||
"test": "eslint --format codeframe --ext .js,.vue . && pug-lint server/views && jest"
|
"test": "eslint --format codeframe --ext .js,.vue . && pug-lint server/views && jest",
|
||||||
|
"cypress:open": "cypress open"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -229,12 +230,14 @@
|
|||||||
"core-js": "3.6.5",
|
"core-js": "3.6.5",
|
||||||
"css-loader": "3.5.3",
|
"css-loader": "3.5.3",
|
||||||
"cssnano": "4.1.10",
|
"cssnano": "4.1.10",
|
||||||
|
"cypress": "4.7.0",
|
||||||
"d3": "5.16.0",
|
"d3": "5.16.0",
|
||||||
"duplicate-package-checker-webpack-plugin": "3.0.0",
|
"duplicate-package-checker-webpack-plugin": "3.0.0",
|
||||||
"epic-spinners": "1.1.0",
|
"epic-spinners": "1.1.0",
|
||||||
"eslint": "7.1.0",
|
"eslint": "7.1.0",
|
||||||
"eslint-config-requarks": "1.0.7",
|
"eslint-config-requarks": "1.0.7",
|
||||||
"eslint-config-standard": "14.1.1",
|
"eslint-config-standard": "14.1.1",
|
||||||
|
"eslint-plugin-cypress": "2.11.1",
|
||||||
"eslint-plugin-import": "2.20.2",
|
"eslint-plugin-import": "2.20.2",
|
||||||
"eslint-plugin-node": "11.1.0",
|
"eslint-plugin-node": "11.1.0",
|
||||||
"eslint-plugin-promise": "4.2.1",
|
"eslint-plugin-promise": "4.2.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user