Cypress test. Button “Continue” in label editor. (#2570)

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

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

@ -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');

Loading…
Cancel
Save