Skip to content
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

Add cypress support #1951

Merged
merged 3 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ script:
# FIXME: Git package and application name conflict in PATH and try to leave only one python test execution
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps && coverage run -a manage.py test --pattern="_test*.py" cvat/apps/dataset_manager/tests cvat/apps/engine/tests utils/cli && coverage run -a manage.py test datumaro/ && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && coveralls-lcov -v -n ./reports/coverage/lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json'
# Run cypress tests
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd ~/tests && ./node_modules/.bin/cypress run --headless --browser chrome'

after_success:
# https://coveralls-python.readthedocs.io/en/latest/usage/multilang.html
Expand Down
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ curl https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_co
export AUTO_SEGMENTATION_PATH="/path/to/dir" # dir must contain mask_rcnn_coco.h5 file
```

### Run Cypress tests
- Install Сypress as described in the [documentation](https://docs.cypress.io/guides/getting-started/installing-cypress.html).
- Setting the address of the local CVAT server:
Change value for ``baseUrl`` parameter in the ``<cvat_local_repository>/tests/cypress.json``

Example:
```sh
"baseUrl": "http://localhost:8080"
```
- Run cypress tests:
```sh
cd <cvat_local_repository>/tests
<cypress_installation_directory>/node_modules/.bin/cypress run --headless --browser chrome
```
For more information, see the [documentation](https://docs.cypress.io/).

## JavaScript/Typescript coding style

We use the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) for JavaScript code with a
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &
nodejs \
python3-dev \
ruby \
xvfb \
&& \
rm -rf /var/lib/apt/lists/*;

Expand All @@ -36,6 +37,7 @@ RUN mkdir -p tests && cd tests && npm install \
karma-junit-reporter \
karma-qunit \
qunit; \
CI=true npm install cypress; \
echo "export PATH=~/tests/node_modules/.bin:${PATH}" >> ~/.bashrc;

ENTRYPOINT []
2 changes: 2 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
dockerfile: Dockerfile.ci
depends_on:
- cvat
- cvat_ui
- cvat_proxy
environment:
COVERALLS_REPO_TOKEN:
TRAVIS:
Expand Down
4 changes: 4 additions & 0 deletions tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"video": false,
"baseUrl": "http://cvat_ui"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest setup default baseUrl to "http://localhost:3000", create another file (like cypress_ci.json) and add parameter --config-file=cypress_ci.json to the command on CI. In this case users do not need change something by default (like described in CONTRIBUTING.md)

https://docs.cypress.io/guides/references/configuration.html#Options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree, thanks. This is the more correct way. I'll do it now.

}
6 changes: 3 additions & 3 deletions tests/cypress/integration/auth_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

describe('Check server availability', () => {
it('Server web interface is available', () => {
cy.visit('http://localhost:8080')
cy.visit('/')
})

it('"/auth/login" contains in the URL', () => {
cy.url().should('include', '/auth/login')
})

it('"Sign in" buttun is exists', () => {
it('"Sign in" button is exists', () => {
cy.get('[type="submit"]')
})

Expand All @@ -27,7 +27,7 @@ describe('Check server availability', () => {
cy.get('[type="password"]')
})

it('Click to "Sign in" buttun', () => {
it('Click to "Sign in" button', () => {
cy.get('[type="submit"]').click()
})
})