Cypress test to check creating and deleting an annotation task. (#2158)

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

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

@ -0,0 +1,46 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/
/// <reference types="cypress" />
context('Create and delete a annotation task', () => {
const caseId = '1'
const labelName = `Case ${caseId}`
const taskName = `New annotation task for ${labelName}`
const attrName = `Attr for ${labelName}`
const textDefaultValue = 'Some default value for type Text'
const image = `image_${labelName.replace(' ', '_').toLowerCase()}.png`
const width = 800
const height = 800
const posX = 10
const posY = 10
const color = 'gray'
let taskID = ''
before(() => {
cy.visit('auth/login')
cy.login()
cy.imageGenerator('cypress/fixtures', image, width, height, color, posX, posY, labelName)
})
describe(`Testing "${labelName}"`, () => {
it('Create a task', () => {
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, image)
})
it('Delete the created task', () => {
cy.getTaskID(taskName).then($taskID => {
cy.deleteTask(taskName, $taskID)
taskID = $taskID
})
})
it('Deleted task not exist', () => {
cy.contains('strong', `#${taskID}: `)
.parents('.cvat-tasks-list-item')
.should('have.attr', 'style', 'pointer-events: none; opacity: 0.5;')
})
})
})

@ -229,3 +229,28 @@ Cypress.Commands.add('createPolyline', (mode,
.trigger('keydown', {key: 'n'})
.trigger('keyup', {key: 'n'})
})
Cypress.Commands.add('getTaskID', (taskName) => {
cy.contains('strong', taskName)
.parents('.cvat-tasks-list-item').within(() => {
cy.get('span').invoke('text')
.then((text)=>{
return String(text.match(/^#\d+\:/g)).replace(/[^\d]/g, '')
})
})
})
Cypress.Commands.add('deleteTask', (taskName, taskID) => {
cy.contains('strong', taskName)
.parents('.cvat-tasks-list-item')
.find('.cvat-menu-icon')
.trigger('mouseover')
cy.get('.cvat-actions-menu')
.contains('Delete')
.click()
cy.get('.ant-modal-content')
.should('contain', `The task ${taskID} will be deleted`).within(() => {
cy.contains('button', 'Delete')
.click()
})
})

Loading…
Cancel
Save