Skip to content

Commit

Permalink
ops: basic Cypress testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kerberizer committed Dec 12, 2024
1 parent 80bd694 commit 30319d7
Show file tree
Hide file tree
Showing 10 changed files with 2,096 additions and 58 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
with:
submodules: recursive

- name: Run Cypress
uses: cypress-io/[email protected]
with:
start: npm run build-serve
wait-on: http://127.0.0.1:50722/templates/

# TODO: Temporary solution for using different backends.
- name: Set up appropriate backend
run: >-
Expand Down
16 changes: 16 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},

component: {
devServer: {
framework: "react",
bundler: "vite",
},
},
});
19 changes: 19 additions & 0 deletions cypress/e2e/basic.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const testURLRoot = 'http://127.0.0.1:50722/templates/'

describe('Basic site functionality', () => {

it('displays the under development notice', () => {
cy.intercept({
method: 'GET',
url: '/template',
hostname: 'api-test.ramanchada.ideaconsult.net',
}, {
fixture: 'json/bk_rcapi_template_default.json',
})
cy.visit(testURLRoot)
cy.get("#root > div > p")
.should('have.class', 'underDev')
.and('be.visible')
})

})
28 changes: 28 additions & 0 deletions cypress/fixtures/json/bk_rcapi_template_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"template": [
{
"uri": "https://api.ramanchada.ideaconsult.net/template/26475cb3-a4e8-4b25-844a-87e3b244d73c",
"uuid": "26475cb3-a4e8-4b25-844a-87e3b244d73c",
"METHOD": "Dose response - change with your assay",
"timestamp": "2024-12-05T16:09:30.677691",
"PROTOCOL_CATEGORY_CODE": "ENM_0000068_SECTION",
"EXPERIMENT": "Generic dose response template",
"template_name": "Dose response template with plate layout",
"template_status": "FINALIZED",
"template_author": " NJ",
"template_acknowledgment": "enanomapper"
},
{
"uri": "https://api.ramanchada.ideaconsult.net/template/8eb6a363-d1c3-4380-8562-2651db4d227b",
"uuid": "8eb6a363-d1c3-4380-8562-2651db4d227b",
"METHOD": "Raman spectrum",
"timestamp": "2024-06-25T12:50:34.656448",
"PROTOCOL_CATEGORY_CODE": "ANALYTICAL_METHODS_SECTION",
"EXPERIMENT": "CHARISMA ",
"template_name": "Raman spectra",
"template_status": "DRAFT",
"template_author": "Nina Jeliazkova",
"template_acknowledgment": "CHARISMA"
}
]
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -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) => { ... })
12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
27 changes: 27 additions & 0 deletions cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ***********************************************************
// This example support/component.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')

import { mount } from 'cypress/react18'

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(<MyComponent />)
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
Loading

0 comments on commit 30319d7

Please sign in to comment.