From 28cb45d92e0d5ed4a4b2c0bc83a0bd5b160f1ce2 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 15 Feb 2021 11:44:37 +0300 Subject: [PATCH] Update Cypress test. Object make a copy. (#2739) * Update Cypress test. Make a copy for all object types. * Some fix. * Add make a copy for a tag. --- .../case_37_object_make_copy.js | 152 ++++++++++++++---- 1 file changed, 118 insertions(+), 34 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_37_object_make_copy.js b/tests/cypress/integration/actions_tasks_objects/case_37_object_make_copy.js index 7dc32ada2409..a57f2256896e 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_37_object_make_copy.js +++ b/tests/cypress/integration/actions_tasks_objects/case_37_object_make_copy.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -12,17 +12,57 @@ context('Object make a copy.', () => { points: 'By 2 Points', type: 'Shape', labelName: labelName, - firstX: 400, + firstX: 100, firstY: 100, - secondX: 500, - secondY: 200, + secondX: 150, + secondY: 150, }; + const createCuboidShape2Points = { + points: 'From rectangle', + type: 'Shape', + labelName: labelName, + firstX: 200, + firstY: 100, + secondX: 250, + secondY: 150, + }; + const createPolygonShape = { + reDraw: false, + type: 'Shape', + labelName: labelName, + pointsMap: [ + { x: 300, y: 100 }, + { x: 350, y: 100 }, + { x: 350, y: 150 }, + ], + complete: true, + numberOfPoints: null, + }; + const createPolylinesShape = { + type: 'Shape', + labelName: labelName, + pointsMap: [ + { x: 400, y: 100 }, + { x: 450, y: 100 }, + { x: 450, y: 150 }, + ], + complete: true, + numberOfPoints: null, + }; + const createPointsShape = { + type: 'Shape', + labelName: labelName, + pointsMap: [{ x: 500, y: 100 }], + complete: true, + numberOfPoints: null, + }; + const countObject = 5; - function checkObjectArrSize(expectedValue) { + function checkObjectArrSize(expectedValueShape, expectedValueSidebar) { cy.get('.cvat_canvas_shape').then(($cvatCanvasShape) => { cy.get('.cvat-objects-sidebar-state-item').then(($cvatObjectsSidebarStateItem) => { - expect($cvatCanvasShape.length).be.equal(expectedValue); - expect($cvatObjectsSidebarStateItem.length).be.equal(expectedValue); + expect($cvatCanvasShape.length).be.equal(expectedValueShape); + expect($cvatObjectsSidebarStateItem.length).be.equal(expectedValueSidebar); }); }); } @@ -47,42 +87,86 @@ context('Object make a copy.', () => { before(() => { cy.openTaskJob(taskName); cy.createRectangle(rectangleShape2Points); + cy.createCuboid(createCuboidShape2Points); + cy.createPolygon(createPolygonShape); + cy.createPolyline(createPolylinesShape); + cy.createPoint(createPointsShape); + cy.createTag(labelName); }); describe(`Testing case "${caseId}"`, () => { it('Make a copy via sidebar.', () => { - cy.get('#cvat-objects-sidebar-state-item-1').within(() => { - cy.get('[aria-label="more"]').trigger('mouseover'); - }); - cy.get('.cvat-object-item-menu').within(() => { - cy.contains('button', 'Make a copy').click(); - }); - cy.get('.cvat-canvas-container').click(); + let coordX = 100; + let coordY = 300; + for (let id = 1; id < countObject + 2; id++) { + cy.get(`#cvat-objects-sidebar-state-item-${id}`).within(() => { + cy.get('[aria-label="more"]').trigger('mouseover').wait(300); // Wait dropdown menu transition + }); + cy.get('.cvat-object-item-menu').last().should('be.visible').contains('button', 'Make a copy').click(); // Get the tast element from cvat-object-item-menu array + cy.get('.cvat-canvas-container').click(coordX, coordY); + cy.get('.cvat-canvas-container').click(); + coordX += 100; + } }); - it('Object attributes are the same.', () => { - checkObjectArrSize(2); - compareObjectsAttr('#cvat_canvas_shape_1', '#cvat_canvas_shape_2'); - compareObjectsSidebarAttr('#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-2'); + it('After copying via sidebar, the attributes of the objects are the same.', () => { + checkObjectArrSize(10, 12); + for (let id = 1; id < countObject; id++) { + compareObjectsAttr(`#cvat_canvas_shape_${id}`, `#cvat_canvas_shape_${id + countObject + 1}`); // Parameters id 1 equal patameters id 7, 2 to 8, etc. + } + for (let idSidebar = 1; idSidebar < 7; idSidebar++) { + compareObjectsSidebarAttr( + `#cvat-objects-sidebar-state-item-${idSidebar}`, + `#cvat-objects-sidebar-state-item-${idSidebar + countObject + 1}`, + ); // Parameters sidebar id 1 equal patameters sidebar id 7, 2 to 8, etc. + } }); - it('Make a copy via object context menu.', () => { - cy.get('#cvat_canvas_shape_1') - .trigger('mousemove') - .should('have.class', 'cvat_canvas_shape_activated') - .rightclick(); - cy.get('.cvat-canvas-context-menu').within(() => { - cy.get('[aria-label="more"]').trigger('mouseover'); - }); - cy.get('.cvat-object-item-menu').contains('button', 'Make a copy').click({ force: true }); - cy.get('.cvat-canvas-container').click(500, 500); - cy.get('.cvat-canvas-container').click(300, 500); //deactivate all objects and hide context menu + // Disabled part of the test for the Firefox browser due to possible problems positioning the element and completing the trigger() construct for moving the mouse cursor over the element. + it('Make a copy via object context menu.', { browser: '!firefox' }, () => { + let coordX = 100; + let coordY = 400; + for (let id = 1; id < countObject; id++) { + // Point doesn't have a context menu + if (id === 4) { + cy.get(`#cvat_canvas_shape_${id}`) + .trigger('mousemove', 'right') + .should('have.class', 'cvat_canvas_shape_activated') + .rightclick('right'); // When click in the center of polyline: is being covered by another element: { - checkObjectArrSize(3); - compareObjectsAttr('#cvat_canvas_shape_1', '#cvat_canvas_shape_3'); - compareObjectsSidebarAttr('#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-3'); - }); + it( + 'After copying via object context menu, the attributes of the objects are the same.', + { browser: '!firefox' }, + () => { + checkObjectArrSize(14, 16); // The point and tag was not copied via the object's context menu + for (let id = 1; id < countObject; id++) { + compareObjectsAttr(`#cvat_canvas_shape_${id}`, `#cvat_canvas_shape_${id + countObject + 7}`); // Parameters id 1 equal patameters id 13, 2 to 14, etc. + } + for (let idSidebar = 1; idSidebar < 6; idSidebar++) { + compareObjectsSidebarAttr( + `#cvat-objects-sidebar-state-item-${idSidebar}`, + `#cvat-objects-sidebar-state-item-${idSidebar + countObject + 6}`, + ); // Parameters sidebar id 1 equal patameters sidebar id 13, 2 to 14, etc. + } + }, + ); }); });