diff --git a/tests/cypress/integration/actions_objects/case_99_save_filtered_object_in_AAM.js b/tests/cypress/integration/actions_objects/case_99_save_filtered_object_in_AAM.js index eec69265..ad0ed608 100644 --- a/tests/cypress/integration/actions_objects/case_99_save_filtered_object_in_AAM.js +++ b/tests/cypress/integration/actions_objects/case_99_save_filtered_object_in_AAM.js @@ -9,6 +9,7 @@ import { labelName, taskName } from '../../support/const'; context('Save filtered object in AAM.', () => { const caseId = '99'; const newLabelName = `New label for case ${caseId}`; + let secondLabel = ''; const createCuboidShape2Points = { points: 'From rectangle', type: 'Shape', @@ -21,7 +22,30 @@ context('Save filtered object in AAM.', () => { before(() => { cy.openTask(taskName); - cy.addNewLabel(newLabelName); + cy.document().then((doc) => { + // Getting list of labels and create a label if neccessary + const labelsList = Array.from(doc.querySelectorAll('.cvat-constructor-viewer-item')); + if (labelsList.length < 2) { + cy.addNewLabel(newLabelName); + } + }); + cy.document().then((doc) => { + // Getting list of labels again + const labelsList = Array.from(doc.querySelectorAll('.cvat-constructor-viewer-item')); + for (let i = 0; i < labelsList.length; i++) { + if (labelsList[i].innerText === labelName) { + cy.get(labelsList[i]).then(($el) => { + // If "labelName" is not first in the labels list and previous element is not "Add label" button than getting previous label + if ($el.prev().length !== 0 && ! $el.prev().hasClass('cvat-constructor-viewer-new-item')) { + secondLabel = $el.prev().text(); + // If "labelName" is not last in the labels list than getting next label + } else if ($el.next().length !== 0) { + secondLabel = $el.next().text(); + } + }) + } + } + }); cy.openJob(); cy.createCuboid(createCuboidShape2Points); }); @@ -41,7 +65,7 @@ context('Save filtered object in AAM.', () => { it(`Go to AAM and change a label for the shape. Save the changes. UI is not failed.`, () => { cy.changeWorkspace('Attribute annotation'); - cy.changeLabelAAM(newLabelName); + cy.changeLabelAAM(secondLabel); cy.saveJob(); cy.get('#cvat_canvas_shape_1').should('not.exist'); cy.get('.attribute-annotations-sidebar-not-found-wrapper').should('exist'); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 9dc197fb..474f2358 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -597,6 +597,7 @@ Cypress.Commands.add('addNewLabel', (newLabelName, additionalAttrs, labelColor) } } cy.contains('button', 'Done').click(); + cy.get('.cvat-constructor-viewer').should('be.visible'); } }); });