Skip to content

Commit 9fdfa7c

Browse files
Add Cypress tests (#8)
* Add first Cypress unit test * Auto-run Cypress unit tests * Fix Cypress env setting * Simplify sleep step * Skip dependency installation via Cypress * Fix wrong job creation * Build Cypress * Update Cypress config * Remove Docker image caching (not working) * Run Cypress tests using Firefox * Move Cypress config * Reorganise Cypress unit tests * Avoid Cypress GPU error * Ignore Cypress support file * Add default Cypress support file * Add E2E support file * Reorganise E2E tests * Fix Flower unit test * Add Cypress tests * Add 404 test * Add wait commands * Add baseUrl * Remove wait commands * Store screnshots on failure only * Save screenshots even when Cypress fails * Fix baseUrl config * Improve tests * Get Docker Compose logs * Set up test mode * Fix tests * Fix baseUrl * Improve tests on shiny apps * Remove shiny app shortcut tests (not working) * Fix some test issues * Minor tests
1 parent 8c6ad46 commit 9fdfa7c

4 files changed

Lines changed: 107 additions & 8 deletions

File tree

.github/workflows/check.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,38 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- name: Check out the repo
13-
uses: actions/checkout@v2
12+
- name: Checkout repo
13+
uses: actions/checkout@v3
1414

1515
- name: Setup project
16-
run: ./setup.sh
17-
18-
- name: Build the Docker Compose stack
16+
run: ./setup-testing-mode.sh
17+
18+
- name: Build Docker Compose stack
1919
run: docker compose up -d
2020

2121
- name: Sleep
22-
uses: jakejarvis/wait-action@master
23-
with:
24-
time: '60s'
22+
run: sleep 10s
23+
shell: bash
2524

2625
- name: Check running containers
2726
run: docker ps
27+
28+
- name: Run Cypress unit tests
29+
uses: cypress-io/github-action@v5
30+
with:
31+
install: false
32+
build: npm i -D cypress
33+
browser: firefox
34+
env:
35+
CYPRESS_VIDEO: false
36+
ELECTRON_EXTRA_LAUNCH_ARGS: '--disable-gpu'
37+
38+
- name: Store Cypress screenshots
39+
if: always()
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: screenshots
43+
path: cypress/screenshots
44+
45+
- name: Docker Compose logs
46+
run: docker compose logs

cypress.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
// These settings apply everywhere unless overridden
5+
defaultCommandTimeout: 5000,
6+
viewportWidth: 1000,
7+
viewportHeight: 600,
8+
// Viewport settings overridden for component tests
9+
component: {
10+
viewportWidth: 500,
11+
viewportHeight: 500,
12+
},
13+
// Command timeout overridden for E2E tests
14+
e2e: {
15+
defaultCommandTimeout: 10000,
16+
baseUrl: 'http://localhost',
17+
},
18+
})

cypress/e2e/tests.cy.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
describe('ShinyProxy', () => {
2+
it('main', () => {
3+
cy.visit('/')
4+
cy.screenshot()
5+
cy.contains('psichomics')
6+
cy.contains('cTRAP')
7+
})
8+
9+
it('psichomics', () => {
10+
cy.visit('/psichomics')
11+
cy.wait(30000)
12+
cy.url().should('include', '/app/psichomics')
13+
cy.screenshot()
14+
})
15+
16+
it('cTRAP', () => {
17+
cy.visit('/cTRAP')
18+
cy.wait(30000)
19+
cy.url().should('include', '/app/cTRAP')
20+
cy.screenshot()
21+
})
22+
})
23+
24+
describe('Flower dashboard', () => {
25+
it('open', () => {
26+
cy.visit('http://localhost:5555/flower/dashboard')
27+
cy.screenshot()
28+
cy.contains('celery@ctrap').click()
29+
cy.screenshot()
30+
})
31+
})
32+
33+
describe('Grafana', () => {
34+
it('open', () => {
35+
cy.visit('http://localhost:3000')
36+
cy.screenshot()
37+
})
38+
})
39+
40+
describe('Prometheus', () => {
41+
it('open', () => {
42+
cy.visit('http://localhost:9090')
43+
cy.screenshot()
44+
})
45+
})
46+
47+
// Issues with setting up Plausible because of password issues :(
48+
// describe('Plausible', () => {
49+
// it('open', () => {
50+
// cy.visit('http://localhost:8000/login')
51+
// cy.screenshot()
52+
// })
53+
// })
54+
55+
describe('404', () => {
56+
it('open', () => {
57+
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
58+
cy.visit('/404', {failOnStatusCode: false})
59+
cy.screenshot()
60+
})
61+
})

cypress/support/e2e.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// DO NOT DELETE THIS FILE: required for Cypress to run unit tests

0 commit comments

Comments
 (0)