Skip to content

Commit

Permalink
Add cypress support (#1951)
Browse files Browse the repository at this point in the history
* Adding cypress support for running tests in the CI.

Modifications:
- .travis.yml: adding command for run testin via cypress
- Dockerfile.ci: addin install necessary package for correct cypress
works. Adding install cypress via npm.
- docker-compose.ci.yml: Starting necessary docker containers for
cypress testing.
- tests/cypress.json: Cypress configuration file
- tests/cypress/integration/auth_page.js: little bit fix.
- CONTRIBUTING.md: add documentation how to run cypress tests locally

* Add documentation how to run cypress tests locally. Remove wait() from
auth_page.js.

* Add run cypress in CI with the different config file cypress_ci.json

Update CONTRIBUTING.md.

Co-authored-by: Dmitry Kruchinin <dmitryx.kruchinin@intel.com>
  • Loading branch information
dvkruchinin and Dmitry Kruchinin authored Jul 29, 2020
1 parent 0de65e7 commit 6eb777a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
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 --config-file=cypress_ci.json'

after_success:
# https://coveralls-python.readthedocs.io/en/latest/usage/multilang.html
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ 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).
- 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
3 changes: 3 additions & 0 deletions tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:8080"
}
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()
})
})
4 changes: 4 additions & 0 deletions tests/cypress_ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"video": false,
"baseUrl": "http://cvat_ui"
}

0 comments on commit 6eb777a

Please sign in to comment.