Cypress tests via Firefox browser. (#2092)

* Cypress tests via Firefox browser.

Added browser verification functionality.
Added user and tasks removing functionality.

* Applying comments.

Co-authored-by: Dmitry Kruchinin <dmitryx.kruchinin@intel.com>
main
Dmitry Kruchinin 6 years ago committed by GitHub
parent 82ea219602
commit 8207eaeaba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -10,6 +10,7 @@
},
"testFiles": [
"auth_page.js",
"issue_*.js"
"issue_*.js",
"remove_users_tasks.js"
]
}

@ -0,0 +1,69 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/
/// <reference types="cypress" />
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}`
}
})
}
})
})
})

@ -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()
})
}
})

Loading…
Cancel
Save