From f39b80038463b861fb3a3ac1e38e88859ac3e011 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin Date: Tue, 28 Jul 2020 14:38:02 +0300 Subject: [PATCH 1/3] 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 --- .travis.yml | 2 ++ Dockerfile.ci | 2 ++ docker-compose.ci.yml | 2 ++ tests/cypress.json | 4 ++++ tests/cypress/integration/auth_page.js | 7 ++++--- 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 tests/cypress.json diff --git a/.travis.yml b/.travis.yml index a8715db3d1e..7f44b764b23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Dockerfile.ci b/Dockerfile.ci index 809c1d785d1..b4c24738d5e 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -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/*; @@ -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 [] diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index ac3a7c548e3..76f0804adb6 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -9,6 +9,8 @@ services: dockerfile: Dockerfile.ci depends_on: - cvat + - cvat_ui + - cvat_proxy environment: COVERALLS_REPO_TOKEN: TRAVIS: diff --git a/tests/cypress.json b/tests/cypress.json new file mode 100644 index 00000000000..ed68fd7c0bc --- /dev/null +++ b/tests/cypress.json @@ -0,0 +1,4 @@ +{ + "video": false, + "baseUrl": "http://cvat_ui" +} diff --git a/tests/cypress/integration/auth_page.js b/tests/cypress/integration/auth_page.js index 28e55304dea..94c5819425f 100644 --- a/tests/cypress/integration/auth_page.js +++ b/tests/cypress/integration/auth_page.js @@ -8,14 +8,15 @@ describe('Check server availability', () => { it('Server web interface is available', () => { - cy.visit('http://localhost:8080') + cy.visit('/') + cy.wait(30000) }) 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"]') }) @@ -27,7 +28,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() }) }) From 55a29f054ce544e852a8a42b7307ff52da5bbf1f Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin Date: Wed, 29 Jul 2020 13:34:31 +0300 Subject: [PATCH 2/3] Add documentation how to run cypress tests locally. Remove wait() from auth_page.js. --- CONTRIBUTING.md | 16 ++++++++++++++++ tests/cypress/integration/auth_page.js | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f97dade6a1a..09fff729350 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``/tests/cypress.json`` + +Example: +```sh + "baseUrl": "http://localhost:8080" +``` +- Run cypress tests: +```sh + cd /tests + /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 diff --git a/tests/cypress/integration/auth_page.js b/tests/cypress/integration/auth_page.js index 94c5819425f..a2120bb577e 100644 --- a/tests/cypress/integration/auth_page.js +++ b/tests/cypress/integration/auth_page.js @@ -9,7 +9,6 @@ describe('Check server availability', () => { it('Server web interface is available', () => { cy.visit('/') - cy.wait(30000) }) it('"/auth/login" contains in the URL', () => { From fcc85f9be4960bc12849735fbee3187ed6938b55 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin Date: Wed, 29 Jul 2020 14:53:56 +0300 Subject: [PATCH 3/3] Add run cypress in CI with the different config file cypress_ci.json Update CONTRIBUTING.md. --- .travis.yml | 2 +- CONTRIBUTING.md | 7 ------- tests/cypress.json | 3 +-- tests/cypress_ci.json | 4 ++++ 4 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 tests/cypress_ci.json diff --git a/.travis.yml b/.travis.yml index 7f44b764b23..855a9d7253e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ script: - 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' + - 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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 09fff729350..1c7c7ce5d6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,13 +170,6 @@ curl https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_co ### 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 ``/tests/cypress.json`` - -Example: -```sh - "baseUrl": "http://localhost:8080" -``` - Run cypress tests: ```sh cd /tests diff --git a/tests/cypress.json b/tests/cypress.json index ed68fd7c0bc..371abf5a85f 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -1,4 +1,3 @@ { - "video": false, - "baseUrl": "http://cvat_ui" + "baseUrl": "http://localhost:8080" } diff --git a/tests/cypress_ci.json b/tests/cypress_ci.json new file mode 100644 index 00000000000..ed68fd7c0bc --- /dev/null +++ b/tests/cypress_ci.json @@ -0,0 +1,4 @@ +{ + "video": false, + "baseUrl": "http://cvat_ui" +}