From 2d9b83479fb41eb036af0517cbfd865572c50afc Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Wed, 20 Jan 2021 15:45:20 +0300 Subject: [PATCH 1/2] Cypress test. Add/delete labels and attributes. --- .../case_41_add_delete_label_attribute.js | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js b/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js new file mode 100644 index 000000000000..60dbd89b61b7 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js @@ -0,0 +1,76 @@ +// Copyright (C) 2021 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +context('Add/delete labels and attributes.', () => { + const caseId = '41'; + const labelName = `Case ${caseId}`; + const attrName = `Attr for ${labelName}`; + const textDefaultValue = 'Some default value for type Text'; + + before(() => { + cy.visit('auth/login'); + cy.login(); + }); + + describe(`Testing "${labelName}"`, () => { + it('Go to create task page. Open label constructor.', () => { + cy.get('#cvat-create-task-button').click(); + cy.get('.cvat-constructor-viewer-new-item').click(); + }); + + it('Start adding a label. Press Cancel. The label is not created.', () => { + cy.get('[placeholder="Label name"]').type(labelName); + cy.contains('[type="button"]', 'Cancel').click(); + cy.get('.cvat-constructor-viewer-item').should('not.exist'); + }); + + it('Start adding a label. Start adding an attribute. Press Cancel. The label is not created.', () => { + cy.get('.cvat-constructor-viewer-new-item').click(); + cy.get('[placeholder="Label name"]').type(labelName); + cy.get('.cvat-new-attribute-button').click(); + cy.get('.cvat-attribute-name-input').type(attrName); + cy.get('.cvat-attribute-type-input').click(); + cy.get('.cvat-attribute-type-input-text').click(); + cy.get('.cvat-attribute-values-input').type(textDefaultValue); + cy.contains('[type="button"]', 'Cancel').click(); + cy.get('.cvat-constructor-viewer-item').should('not.exist'); + }); + + it('Start adding a label. Add an attribute. Press Done. The label should be created.', () => { + cy.get('.cvat-constructor-viewer-new-item').click(); + cy.get('[placeholder="Label name"]').type(labelName); + cy.get('.cvat-new-attribute-button').click(); + cy.get('.cvat-attribute-name-input').type(attrName); + cy.get('.cvat-attribute-type-input').click(); + cy.get('.cvat-attribute-type-input-text').click(); + cy.get('.cvat-attribute-values-input').type(textDefaultValue); + cy.contains('[type="submit"]', 'Done').click(); + cy.get('.cvat-constructor-viewer-item').should('exist'); + }); + + it('Start to edit the label. Attribute should be exist. Remove the atrribute. Press Done.', () => { + cy.get('.cvat-constructor-viewer-item').find('[aria-label="edit"]').click(); + cy.get('.cvat-attribute-inputs-wrapper') + .should('exist') + .within(() => { + cy.get('.cvat-delete-attribute-button').click(); + }); + cy.get('.cvat-attribute-inputs-wrapper').should('not.exist'); + cy.contains('[type="submit"]', 'Done').click(); + }); + + it('Start to edit the created label. Attribute should not be exist. Press Cancel.', () => { + cy.get('.cvat-constructor-viewer-item').find('[aria-label="edit"]').click(); + cy.get('.cvat-attribute-inputs-wrapper').should('not.exist'); + cy.contains('[type="button"]', 'Cancel').click(); + }); + + it('Delete the added label. The label removed.', () => { + cy.get('.cvat-constructor-viewer-item').find('[aria-label="close"]').click(); + cy.get('.cvat-constructor-viewer-item').should('not.exist'); + }); + }); +}); From c786362032e44d18bb30c0575720f65c2ecef861 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Thu, 21 Jan 2021 15:31:30 +0300 Subject: [PATCH 2/2] Apply comments. --- .../case_41_add_delete_label_attribute.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js b/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js index 60dbd89b61b7..82db7dae033c 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js +++ b/tests/cypress/integration/actions_tasks_objects/case_41_add_delete_label_attribute.js @@ -13,15 +13,12 @@ context('Add/delete labels and attributes.', () => { before(() => { cy.visit('auth/login'); cy.login(); + cy.get('#cvat-create-task-button').click(); }); describe(`Testing "${labelName}"`, () => { - it('Go to create task page. Open label constructor.', () => { - cy.get('#cvat-create-task-button').click(); - cy.get('.cvat-constructor-viewer-new-item').click(); - }); - it('Start adding a label. Press Cancel. The label is not created.', () => { + cy.get('.cvat-constructor-viewer-new-item').click(); // Open label constructor cy.get('[placeholder="Label name"]').type(labelName); cy.contains('[type="button"]', 'Cancel').click(); cy.get('.cvat-constructor-viewer-item').should('not.exist'); @@ -51,7 +48,7 @@ context('Add/delete labels and attributes.', () => { cy.get('.cvat-constructor-viewer-item').should('exist'); }); - it('Start to edit the label. Attribute should be exist. Remove the atrribute. Press Done.', () => { + it('Start to edit the label. Attribute should exist. Remove the atrribute. Press Done.', () => { cy.get('.cvat-constructor-viewer-item').find('[aria-label="edit"]').click(); cy.get('.cvat-attribute-inputs-wrapper') .should('exist') @@ -60,9 +57,7 @@ context('Add/delete labels and attributes.', () => { }); cy.get('.cvat-attribute-inputs-wrapper').should('not.exist'); cy.contains('[type="submit"]', 'Done').click(); - }); - - it('Start to edit the created label. Attribute should not be exist. Press Cancel.', () => { + // After deleting the attribute and saving the changes, check that the attribute is missing. cy.get('.cvat-constructor-viewer-item').find('[aria-label="edit"]').click(); cy.get('.cvat-attribute-inputs-wrapper').should('not.exist'); cy.contains('[type="button"]', 'Cancel').click();