Unverified Commit ff31d252 authored by Nicolas Giard's avatar Nicolas Giard Committed by GitHub

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
parent c2a07736
extends:
- requarks
- plugin:vue/strongly-recommended
- plugin:cypress/recommended
env:
node: true
jest: true
......
{
"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"
}
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
/// <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')
})
})
/// <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
}
// ***********************************************
// 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) => { ... })
// ***********************************************************
// 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",
"build": "webpack --profile --config dev/webpack/webpack.prod.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": {
"type": "git",
......@@ -229,12 +230,14 @@
"core-js": "3.6.5",
"css-loader": "3.5.3",
"cssnano": "4.1.10",
"cypress": "4.7.0",
"d3": "5.16.0",
"duplicate-package-checker-webpack-plugin": "3.0.0",
"epic-spinners": "1.1.0",
"eslint": "7.1.0",
"eslint-config-requarks": "1.0.7",
"eslint-config-standard": "14.1.1",
"eslint-plugin-cypress": "2.11.1",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment