diff --git a/tests/cypress/integration/actions_tasks_objects/case_13_merge_split_features.js b/tests/cypress/integration/actions_tasks_objects/case_13_merge_split_features.js index d67ec05b..4db92a6a 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_13_merge_split_features.js +++ b/tests/cypress/integration/actions_tasks_objects/case_13_merge_split_features.js @@ -35,23 +35,22 @@ context('Merge/split features', () => { cy.openTaskJob(taskName); }); - function checkFrameNumber(frameNum) { + function goCheckFrameNumber(frameNum) { cy.get('.cvat-player-frame-selector').within(() => { - cy.get('input[role="spinbutton"]').should('have.value', frameNum); + cy.get('input[role="spinbutton"]').clear().type(`${frameNum}{Enter}`).should('have.value', frameNum); }); } describe(`Testing case "${caseId}"`, () => { it('Create rectangle shape on first frame', () => { - checkFrameNumber(frameNum); + goCheckFrameNumber(frameNum); cy.createRectangle(createRectangleShape2Points); cy.get('#cvat_canvas_shape_1').should('have.attr', 'x').then(xCoords => { xCoordinatesObjectFirstFrame = Math.floor(xCoords); }); }); it('Create rectangle shape on third frame with another position', () => { - cy.get('.cvat-player-next-button').click().click(); - checkFrameNumber(frameNum + 2); + goCheckFrameNumber(frameNum + 2); cy.createRectangle(createRectangleShape2PointsSecond); cy.get('#cvat_canvas_shape_2').should('have.attr', 'x').then(xCoords => { xCoordinatesObjectThirdFrame = Math.floor(xCoords); @@ -60,8 +59,7 @@ context('Merge/split features', () => { it('Merge the objects with "Merge button"', () => { cy.get('.cvat-merge-control').click(); cy.get('#cvat_canvas_shape_2').click(); - cy.get('.cvat-player-previous-button').click().click(); - checkFrameNumber(frameNum); + goCheckFrameNumber(frameNum); cy.get('#cvat_canvas_shape_1').click(); cy.get('.cvat-merge-control').click(); }); @@ -70,24 +68,20 @@ context('Merge/split features', () => { cy.get('#cvat-objects-sidebar-state-item-3').should('contain', '3').and('contain', 'RECTANGLE TRACK').within(() => { cy.get('.cvat-object-item-button-keyframe-enabled').should('exist'); }); - cy.get('.cvat-player-next-button').click().click(); - checkFrameNumber(frameNum + 2); + goCheckFrameNumber(frameNum + 2); cy.get('#cvat_canvas_shape_3').should('exist').and('be.visible'); cy.get('#cvat-objects-sidebar-state-item-3').should('contain', '3').and('contain', 'RECTANGLE TRACK').within(() => { cy.get('.cvat-object-item-button-keyframe-enabled').should('exist'); }); }); it('On the second frame and on the fourth frame the track is invisible', () => { - cy.get('.cvat-player-previous-button').click(); - checkFrameNumber(frameNum + 1); + goCheckFrameNumber(frameNum + 1); cy.get('#cvat_canvas_shape_3').should('exist').and('be.hidden'); - cy.get('.cvat-player-next-button').click().click(); - checkFrameNumber(frameNum + 3); + goCheckFrameNumber(frameNum + 3); cy.get('#cvat_canvas_shape_3').should('exist').and('be.hidden'); }); it('Go to the second frame and remove "outside" flag from the track. The track now visible.', () => { - cy.get('.cvat-player-previous-button').click().click(); - checkFrameNumber(frameNum + 1); + goCheckFrameNumber(frameNum + 1); cy.get('#cvat-objects-sidebar-state-item-3').should('contain', '3').and('contain', 'RECTANGLE TRACK').within(() => { cy.get('.cvat-object-item-button-outside').click(); cy.get('.cvat-object-item-button-outside-enabled').should('not.exist'); @@ -106,7 +100,7 @@ context('Merge/split features', () => { }); it('On the fourth frame remove "keyframe" flag from the track. The track now visible and "outside" flag is disabled.', () => { cy.get('.cvat-player-next-button').click().click(); - checkFrameNumber(frameNum + 3); + goCheckFrameNumber(frameNum + 3); cy.get('#cvat-objects-sidebar-state-item-3').should('contain', '3').and('contain', 'RECTANGLE TRACK').within(() => { cy.get('.cvat-object-item-button-keyframe').click(); cy.get('.cvat-object-item-button-keyframe-enabled').should('not.exist'); diff --git a/tests/cypress/integration/actions_tasks_objects/issue_1425_highlighted_attribute_correspond_chosen_attribute.js b/tests/cypress/integration/actions_tasks_objects/issue_1425_highlighted_attribute_correspond_chosen_attribute.js index 34458402..991f91d6 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_1425_highlighted_attribute_correspond_chosen_attribute.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_1425_highlighted_attribute_correspond_chosen_attribute.js @@ -28,7 +28,7 @@ context('The highlighted attribute in AAM should correspond to the chosen attrib cy.createRectangle(createRectangleShape2Points); }); it('Go to AAM', () => { - cy.changeAnnotationMode('Attribute annotation', labelName); + cy.changeWorkspace('Attribute annotation', labelName); }); it('Check if highlighted attribute correspond to the chosen attribute in right panel', () => { cy.get('.cvat_canvas_text').within(() => { diff --git a/tests/cypress/integration/actions_tasks_objects/issue_1540_add_remove_tag.js b/tests/cypress/integration/actions_tasks_objects/issue_1540_add_remove_tag.js index 3f5d83be..f5a402ad 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_1540_add_remove_tag.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_1540_add_remove_tag.js @@ -17,11 +17,11 @@ context('Check if the UI not to crash after remove a tag', () => { describe(`Testing issue "${issueId}"`, () => { it('Add a tag', () => { - cy.changeAnnotationMode('Tag annotation'); + cy.changeWorkspace('Tag annotation'); cy.get('.cvat-tag-annotation-sidebar-buttons').within(() => { cy.get('button').contains('Add tag').click({ force: true }); }); - cy.changeAnnotationMode('Standard'); + cy.changeWorkspace('Standard'); }); it('Remove the tag', () => { cy.get('#cvat-objects-sidebar-state-item-1') diff --git a/tests/cypress/integration/actions_tasks_objects/issue_1750_err_aam_switch_frames.js b/tests/cypress/integration/actions_tasks_objects/issue_1750_err_aam_switch_frames.js index ea972d23..150911ba 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_1750_err_aam_switch_frames.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_1750_err_aam_switch_frames.js @@ -37,7 +37,7 @@ context('An error occurs in AAM when switching to 2 frames, if the frames have o cy.createRectangle(createRectangleShape2PointsSecond); }); it('Go to AAM', () => { - cy.changeAnnotationMode('Attribute annotation', labelName); + cy.changeWorkspace('Attribute annotation', labelName); }); it('Go to next frame', () => { cy.get('.cvat-player-next-button').click(); @@ -59,10 +59,7 @@ context('An error occurs in AAM when switching to 2 frames, if the frames have o }); it('Page with the error is missing', () => { cy.contains('Oops, something went wrong').should('not.exist'); - cy.get('.attribute-annotation-sidebar-basics-editor').within(() => { - cy.get('.ant-select-selection').click(); - }); - cy.get('.ant-select-dropdown-menu-item').contains(labelName).click(); + cy.changeLabelAAM(labelName); cy.get('.attribute-annotation-sidebar-object-switcher').should('contain', `${labelName} 2 [2/2]`); }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 076c246d..b81bfe72 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -122,12 +122,16 @@ Cypress.Commands.add('switchLabel', (labelName) => { }); Cypress.Commands.add('checkObjectParameters', (objectParameters, objectType) => { - cy.get('.cvat_canvas_shape').last().should('have.attr', 'id').then(($cvatCanvasShapeId) => { - const arrCvatCanvasShapeId = $cvatCanvasShapeId.split('_') - const idNumCanvasShape = arrCvatCanvasShapeId[arrCvatCanvasShapeId.length - 1] - cy.get(`#cvat_canvas_shape_${idNumCanvasShape}`).should('exist').and('be.visible'); - cy.get(`#cvat-objects-sidebar-state-item-${idNumCanvasShape}`) - .should('contain', idNumCanvasShape).and('contain', `${objectType} ${objectParameters.type.toUpperCase()}`).within(() => { + let listCanvasShapeId = []; + cy.document().then((doc) => { + const listCanvasShape = Array.from(doc.querySelectorAll('.cvat_canvas_shape')); + for (let i = 0; i < listCanvasShape.length; i++) { + listCanvasShapeId.push(listCanvasShape[i].id.match(/\d+$/)); + } + const maxId = Math.max(...listCanvasShapeId); + cy.get(`#cvat_canvas_shape_${maxId}`).should('exist').and('be.visible'); + cy.get(`#cvat-objects-sidebar-state-item-${maxId}`) + .should('contain', maxId).and('contain', `${objectType} ${objectParameters.type.toUpperCase()}`).within(() => { cy.get('.ant-select-selection-selected-value').should('have.text', selectedValueGlobal); }); }); @@ -217,17 +221,23 @@ Cypress.Commands.add('closeSettings', () => { }); }); -Cypress.Commands.add('changeAnnotationMode', (mode, labelName) => { +Cypress.Commands.add('changeWorkspace', (mode, labelName) => { cy.get('.cvat-workspace-selector').click(); cy.get('.ant-select-dropdown-menu-item').contains(mode).click(); cy.get('.cvat-workspace-selector').should('contain.text', mode); - if (mode === 'Attribute annotation') { - // Select the necessary label in any case - cy.get('.attribute-annotation-sidebar-basics-editor').within(() => { - cy.get('.ant-select-selection').click(); - }); - cy.get('.ant-select-dropdown-menu-item').contains(labelName).click(); - } + cy.changeLabelAAM(labelName); +}); + +Cypress.Commands.add('changeLabelAAM', (labelName) => { + cy.get('.cvat-workspace-selector').then((value) => { + const cvatWorkspaceSelectorValue = value.text(); + if (cvatWorkspaceSelectorValue === 'Attribute annotation') { + cy.get('.attribute-annotation-sidebar-basics-editor').within(() => { + cy.get('.ant-select-selection').click(); + }); + cy.get('.ant-select-dropdown-menu-item').contains(labelName).click(); + } + }); }); Cypress.Commands.add('createCuboid', (createCuboidParams) => {