-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a few simple test cases #1041
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,16 +46,31 @@ jobs: | |
conda install -c conda-forge mamba | ||
mamba env update --file conda-environment.yml --name base | ||
pip install -e . | ||
|
||
- name: Cache UI dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
ui/node_modules | ||
key: cache-${{ runner.os }}-${{ hashFiles('ui/package-lock.json') }} | ||
|
||
- name: Install UI dependencies | ||
run: npm install --prefix ./ui --legacy-peer-deps | ||
|
||
- name: Build UI | ||
run: | | ||
npm install --prefix ./ui | ||
npm run --prefix ./ui build | ||
run: npm run --prefix ./ui build | ||
env: | ||
DISABLE_ESLINT_PLUGIN: true | ||
- name: Run mxcube backend | ||
run: | | ||
mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug & | ||
- name: Cypress run | ||
uses: cypress-io/github-action@v5 | ||
|
||
- name: Run MXCuBE backend | ||
run: mxcubeweb-server -r ./test/HardwareObjectsMockup.xml/ --static-folder $(pwd)/ui/build/ -L debug & | ||
|
||
- name: Run Cypress | ||
run: npm run --prefix ./ui e2e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script is called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I see, sorry for the confusion |
||
|
||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
working-directory: ./ui | ||
name: cypress | ||
path: cypress/debug |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ jobs: | |
- name: Install dependencies | ||
run: | | ||
pip install -e . | ||
npm install --prefix ./ui | ||
npm install --prefix ./ui --legacy-peer-deps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a flag for NPM to disregard peer deps warnings and install any missing peer deps automatically. With There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, ok |
||
- name: Check formatting | ||
run: npm run --prefix ./ui prettier | ||
|
@@ -84,7 +84,7 @@ jobs: | |
- name: Install dependencies | ||
run: | | ||
pip install -e . | ||
npm install --prefix ./ui | ||
npm install --prefix ./ui --legacy-peer-deps | ||
- name: Lint | ||
run: npm run --prefix ./ui eslint |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
# testing | ||
/coverage | ||
/cypress/debug | ||
|
||
# production | ||
/build | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
describe('login', () => { | ||
it("can't login with invalid credentials", () => { | ||
cy.login('idte0', '0000'); | ||
cy.findByText('Could not authenticate').should('be.visible'); | ||
}); | ||
|
||
it('can login with valid credentials', () => { | ||
cy.login(); | ||
cy.findByRole('link', { name: 'MXCuBE-Web (OSC)' }).should('be.visible'); | ||
}); | ||
}); | ||
|
||
describe('app', () => { | ||
it('loads the login page', () => { | ||
cy.visit('http://localhost:8081'); | ||
cy.get('input[placeholder*="Login ID"]').should('be.visible'); | ||
cy.get('input[placeholder*="Password"]').should('be.visible'); | ||
cy.get('button[type=submit]').should('be.visible'); | ||
beforeEach(() => { | ||
cy.login(); | ||
cy.findByRole('link', { name: 'MXCuBE-Web (OSC)' }).should('be.visible'); | ||
}); | ||
|
||
it('displays collection page', () => { | ||
cy.findByRole('button', { name: /Beamline Actions/u }).should('be.visible'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import '@testing-library/cypress/add-commands'; | ||
|
||
Cypress.Commands.add('login', (username = 'idtest0', password = '0000') => { | ||
cy.visit('/'); | ||
cy.findByRole('heading', { name: 'MXCuBE' }).should('be.visible'); | ||
cy.findByLabelText('Login ID').type(username); | ||
cy.findByLabelText('Password').type(password); | ||
cy.findByRole('button', { name: 'Sign in' }).click(); | ||
}); |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This action was also installing dependencies. In fact, it's quite the behemoth: it does the caching, the installation, can even run a dev server ... I prefer to make all these steps explicit for maintainability (e.g. so we won't have to remember to configure it properly if we switch to
pnpm
in the future, for instance).