From c126d2afeb30f1a255261b1b8be5ebd01b4455a9 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Fri, 25 Dec 2020 15:31:21 +0300 Subject: [PATCH] =?UTF-8?q?Cypress=20test.=20Button=20=E2=80=9CContinue?= =?UTF-8?q?=E2=80=9D=20in=20label=20editor.=20(#2570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kruchinin --- .../case_33_button_continue_label_editor.js | 34 +++++++++++++++++++ tests/cypress/support/commands.js | 26 ++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_33_button_continue_label_editor.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_33_button_continue_label_editor.js b/tests/cypress/integration/actions_tasks_objects/case_33_button_continue_label_editor.js new file mode 100644 index 00000000..4c38376e --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_33_button_continue_label_editor.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName } from '../../support/const'; + +context('Button "Continue" in label editor.', () => { + const caseId = '33'; + const additionalLabels = [ + `First label for case ${caseId}`, + `Second label for case ${caseId}`, + `Third label for case ${caseId}`, + ]; + + before(() => { + cy.openTask(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Adding multiple labels via the Continue button', () => { + cy.addNewLabelViaContinueButton(additionalLabels); + }); + + it('All labels cuccessfully added.', () => { + cy.collectLabelsName().then((labelNames) => { + expect(labelNames).to.include(additionalLabels[0]); + expect(labelNames).to.include(additionalLabels[1]); + expect(labelNames).to.include(additionalLabels[2]); + }); + }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 23106465..c067c135 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -438,7 +438,7 @@ Cypress.Commands.add('changeColorViaBadge', (labelColor) => { }); }); -Cypress.Commands.add('addNewLabel', (newLabelName, additionalAttrs, labelColor) => { +Cypress.Commands.add('collectLabelsName', () => { let listCvatConstructorViewerItemText = []; cy.get('.cvat-constructor-viewer').should('exist'); cy.document().then((doc) => { @@ -446,7 +446,13 @@ Cypress.Commands.add('addNewLabel', (newLabelName, additionalAttrs, labelColor) for (let i = 0; i < labels.length; i++) { listCvatConstructorViewerItemText.push(labels[i].textContent); } - if (listCvatConstructorViewerItemText.indexOf(newLabelName) === -1) { + return listCvatConstructorViewerItemText; + }); +}); + +Cypress.Commands.add('addNewLabel', (newLabelName, additionalAttrs, labelColor) => { + cy.collectLabelsName().then((labelsNames) => { + if (labelsNames.indexOf(newLabelName) === -1) { cy.contains('button', 'Add label').click(); cy.get('[placeholder="Label name"]').type(newLabelName); if (labelColor) { @@ -463,6 +469,22 @@ Cypress.Commands.add('addNewLabel', (newLabelName, additionalAttrs, labelColor) }); }); +Cypress.Commands.add('addNewLabelViaContinueButton', (additionalLabels) => { + cy.collectLabelsName().then((labelsNames) => { + if (additionalLabels.some((el) => labelsNames.indexOf(el) === -1)) { + cy.contains('button', 'Add label').click(); + for (let j = 0; j < additionalLabels.length; j++) { + cy.get('[placeholder="Label name"]').type(additionalLabels[j]); + if (j !== additionalLabels.length - 1) { + cy.contains('button', 'Continue').click(); + } else { + cy.contains('button', 'Done').click(); + } + } + } + }); +}); + Cypress.Commands.add('createTag', (labelName) => { cy.get('.cvat-setup-tag-control').click(); cy.switchLabel(labelName, 'tag');