From 7e7b650a6b72825ddb8243fbcb69fac2e0a308e7 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 14 Sep 2020 08:28:50 +0300 Subject: [PATCH] Cypress test to check creating and deleting an annotation task. (#2158) Co-authored-by: Dmitry Kruchinin --- tests/cypress.json | 1 + .../integration/case_1_create_delete_task.js | 46 +++++++++++++++++++ tests/cypress/support/commands.js | 25 ++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/cypress/integration/case_1_create_delete_task.js diff --git a/tests/cypress.json b/tests/cypress.json index 73741d19..09429d82 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -11,6 +11,7 @@ "testFiles": [ "auth_page.js", "issue_*.js", + "case_*.js", "remove_users_tasks.js" ] } diff --git a/tests/cypress/integration/case_1_create_delete_task.js b/tests/cypress/integration/case_1_create_delete_task.js new file mode 100644 index 00000000..e89448fe --- /dev/null +++ b/tests/cypress/integration/case_1_create_delete_task.js @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +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;') + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 20eb9b60..c5fbc563 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -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() + }) +})