diff --git a/.travis.yml b/.travis.yml index 68533c0d..9acef6b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ cache: - ~/.cache addons: + firefox: "latest" apt: packages: - libgconf-2-4 @@ -43,7 +44,8 @@ script: - docker exec -it cvat bash -ic "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell" # Install Cypress and run tests - cd ./tests && npm install - - $(npm bin)/cypress run --headless --browser chrome && cd .. + - $(npm bin)/cypress run --headless --browser chrome + - $(npm bin)/cypress run --headless --browser firefox && cd .. after_success: # https://coveralls-python.readthedocs.io/en/latest/usage/multilang.html diff --git a/tests/cypress.json b/tests/cypress.json index 59316936..73741d19 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -10,6 +10,7 @@ }, "testFiles": [ "auth_page.js", - "issue_*.js" + "issue_*.js", + "remove_users_tasks.js" ] } diff --git a/tests/cypress/integration/remove_users_tasks.js b/tests/cypress/integration/remove_users_tasks.js new file mode 100644 index 00000000..711b4e09 --- /dev/null +++ b/tests/cypress/integration/remove_users_tasks.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +let authKey = '' + +describe('Delete users and tasks created during the test run.', () => { + it('Get token', () => { + cy.request({ + method: 'POST', + url: '/api/v1/auth/login', + body: { + username: Cypress.env('user'), + password: Cypress.env('password') + } + }) + .then(async (responce) => { + authKey = await responce['body']['key'] + }) + }) + it('Get a list of users and delete all except id:1', () => { + cy.request({ + url: '/api/v1/users', + headers: { + Authorization: `Token ${authKey}` + } + }) + .then(async (responce) => { + const responceResult = await responce['body']['results'] + for (let user of responceResult) { + let userId = user['id'] + if (userId !== 1) { + cy.request({ + method: 'DELETE', + url: `/api/v1/users/${userId}`, + headers: { + Authorization: `Token ${authKey}` + } + }) + } + } + }) + }) + it('Get a list of tasks and delete them all', ()=> { + cy.request({ + url: '/api/v1/tasks?page_size=1000', + headers: { + Authorization: `Token ${authKey}` + } + }) + .then(async (responce) => { + const responceResult = await responce['body']['results'] + for (let tasks of responceResult) { + let taskId = tasks['id'] + cy.request({ + method: 'DELETE', + url: `/api/v1/tasks/${taskId}`, + headers: { + Authorization: `Token ${authKey}` + } + }) + } + }) + }) +}) diff --git a/tests/cypress/support/index.js b/tests/cypress/support/index.js index bf9295aa..b23790a4 100644 --- a/tests/cypress/support/index.js +++ b/tests/cypress/support/index.js @@ -5,3 +5,16 @@ */ import './commands' + +before(() => { + if (Cypress.browser.name === 'firefox') { + cy.visit('/') + cy.get('.ant-modal-body').within(() => { + cy.get('.ant-modal-confirm-title') + .should('contain', 'Unsupported platform detected') + cy.get('.ant-modal-confirm-btns') + .contains('OK') + .click() + }) + } +})