so tests stay with branches and code

This commit is contained in:
jamesread 2021-10-18 06:59:28 +01:00
parent 03d7250cf6
commit 636af5df90
15 changed files with 1511 additions and 0 deletions

2
integration-tests/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
results
node_modules

View File

@ -0,0 +1,14 @@
container:
rm -rf *.tar.gz
mv dist/*.tar.gz ./
tar xavf OliveTin-*linux-amd64.tar.gz
docker rm -f olivetin && docker rmi -f olivetin
docker build -t olivetin:latest OliveTin-*linux-amd64/
docker create --name olivetin -p 1337:1337 -v `pwd`/config/:/config/ olivetin
cypress:
npm install
./cypressRun.sh "general"
./cypressRun.sh "hiddenNav"
.PHONY: cypress container

View File

@ -0,0 +1 @@
# OliveTin-integration-tests

View File

@ -0,0 +1,53 @@
# There is a built-in micro proxy that will host the webui and REST API all on
# one port (this is called the "Single HTTP Frontend") and means you just need
# one open port in the container/firewalls/etc.
#
# Listen on all addresses available, port 1337
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
# Choose from INFO (default), WARN and DEBUG
logLevel: "DEBUG"
# Actions (buttons) to show up on the WebUI:
actions:
# This will send 1 ping (-c 1)
# Docs: https://docs.olivetin.app/action-ping.html
- title: Ping Google.com
shell: ping google.com -c 1
icon: ping
# Restart lightdm on host "overseer"
# Docs: https://docs.olivetin.app/action-ping.html
- title: restart lightdm
icon: poop
shell: ssh root@overseer 'service lightdm restart'
- title: sleep 2 seconds
shell: sleep 2
icon: "&#x1F971"
- title: sleep 5 seconds (timeout)
shell: sleep 5
icon: "&#x1F62A"
# OliveTin can run long-running jobs like Ansible playbooks.
#
# For such jobs, you will need to install ansible-playbook on the host where
# you are running OliveTin, or in the container.
#
# You probably want a much longer timeout as well (so that ansible completes).
- title: "Run Ansible Playbook"
icon: "&#x1F1E6"
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
timeout: 120
# OliveTin can control containers - docker is just a command line app.
#
# However, if you are running in a container you will need to do some setup,
# see the docs below.
#
# Docs: https://docs.olivetin.app/action-container-control.html
- title: Restart Plex
icon: smile
shell: docker restart plex

View File

@ -0,0 +1,14 @@
# There is a built-in micro proxy that will host the webui and REST API all on
# one port (this is called the "Single HTTP Frontend") and means you just need
# one open port in the container/firewalls/etc.
#
# Listen on all addresses available, port 1337
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
hideNavigation: true
# Actions (buttons) to show up on the WebUI:
actions:
- title: Ping example.com
shell: ping example.com -c 1
icon: ping

View File

@ -0,0 +1,53 @@
# There is a built-in micro proxy that will host the webui and REST API all on
# one port (this is called the "Single HTTP Frontend") and means you just need
# one open port in the container/firewalls/etc.
#
# Listen on all addresses available, port 1337
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
# Choose from INFO (default), WARN and DEBUG
logLevel: "DEBUG"
# Actions (buttons) to show up on the WebUI:
actions:
# This will send 1 ping (-c 1)
# Docs: https://docs.olivetin.app/action-ping.html
- title: Ping Google.com
shell: ping google.com -c 1
icon: ping
# Restart lightdm on host "overseer"
# Docs: https://docs.olivetin.app/action-ping.html
- title: restart lightdm
icon: poop
shell: ssh root@overseer 'service lightdm restart'
- title: sleep 2 seconds
shell: sleep 2
icon: "&#x1F971"
- title: sleep 5 seconds (timeout)
shell: sleep 5
icon: "&#x1F62A"
# OliveTin can run long-running jobs like Ansible playbooks.
#
# For such jobs, you will need to install ansible-playbook on the host where
# you are running OliveTin, or in the container.
#
# You probably want a much longer timeout as well (so that ansible completes).
- title: "Run Ansible Playbook"
icon: "&#x1F1E6"
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
timeout: 120
# OliveTin can control containers - docker is just a command line app.
#
# However, if you are running in a container you will need to do some setup,
# see the docs below.
#
# Docs: https://docs.olivetin.app/action-container-control.html
- title: Restart Plex
icon: smile
shell: docker restart plex

View File

@ -0,0 +1,5 @@
{
"baseUrl": "http://localhost:1337",
"screenshotsFolder": "results/screenshots/",
"videosFolder": "results/videos/"
}

View File

@ -0,0 +1,21 @@
describe('Homepage rendering', () => {
beforeEach(() => {
cy.visit("/")
});
it("Footer contains promo", () => {
cy.get('footer').contains("OliveTin")
})
it('Default buttons are rendered', () => {
cy.get("#rootGroup button").should('have.length', 6)
})
it('Switcher navigation is visible', () => {
cy.get('#switcher').then($el => {
expect(Cypress.dom.isHidden($el)).to.be.false
})
})
});

View File

@ -0,0 +1,17 @@
describe('Hidden Nav', () => {
beforeEach(() => {
cy.visit("/")
});
it("Footer contains promo", () => {
cy.get('footer').contains("OliveTin")
})
it('Switcher navigation is hidden', () => {
cy.get('#switcher').then($el => {
expect(Cypress.dom.isHidden($el)).to.be.true
})
})
});

View File

@ -0,0 +1,22 @@
/// <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}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -0,0 +1,26 @@
// ***********************************************
// 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) => { ... })

View 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')

11
integration-tests/cypressRun.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -o xtrace
echo "Running config $1"
cp -f config/config{.$1,}.yaml
docker start olivetin
NO_COLOR=1 ./node_modules/.bin/cypress run --headless -s cypress/integration/$1/* || true
docker kill olivetin

1237
integration-tests/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
{
"name": "olivetin-integration-tests",
"version": "1.0.0",
"repository": "https://github.com/OliveTin/OliveTin-integration-tests",
"description": "The cypress WebUI tests",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cypress": "^8.3.0"
}
}