From 6e5f6834b9d46c6d4744fd372514990add5d98ea Mon Sep 17 00:00:00 2001 From: DmitriyOparin <35344996+DmitriyOparin@users.noreply.github.com> Date: Fri, 11 Dec 2020 12:44:47 +0300 Subject: [PATCH] Cypress test. Undo and redo feature. (#2535) * add test * step for create objects moved to before function Co-authored-by: Dmitriy Oparin --- .../case_27_undo_redo_feature.js | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_27_undo_redo_feature.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_27_undo_redo_feature.js b/tests/cypress/integration/actions_tasks_objects/case_27_undo_redo_feature.js new file mode 100644 index 000000000000..704fc66c2ab9 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_27_undo_redo_feature.js @@ -0,0 +1,82 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName, labelName } from '../../support/const'; + +context('Undo/redo feature', () => { + const caseId = '27'; + const firstRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 100, + firstY: 100, + secondX: 150, + secondY: 150, + }; + const secondRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 150, + firstY: 150, + secondX: 200, + secondY: 200, + }; + const thirdRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 200, + firstY: 200, + secondX: 250, + secondY: 250, + }; + + function checkExistObject(stateFirstObject, stateSecondObject, stateThirdObject) { + // check objects on background + cy.get('#cvat_canvas_shape_1').should(stateFirstObject); + cy.get('#cvat_canvas_shape_2').should(stateSecondObject); + cy.get('#cvat_canvas_shape_3').should(stateThirdObject); + // check objects on sidebar + cy.get('#cvat-objects-sidebar-state-item-1').should(stateFirstObject); + cy.get('#cvat-objects-sidebar-state-item-2').should(stateSecondObject); + cy.get('#cvat-objects-sidebar-state-item-3').should(stateThirdObject); + }; + + before(() => { + cy.openTaskJob(taskName); + + // create objects + cy.createRectangle(firstRectangleShape2Points); + cy.createRectangle(secondRectangleShape2Points); + cy.createRectangle(thirdRectangleShape2Points); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Undo objects', () => { + cy.contains('.cvat-annotation-header-button', 'Undo').click(); + checkExistObject('exist', 'exist', 'not.exist'); + + cy.contains('.cvat-annotation-header-button', 'Undo').click(); + checkExistObject('exist', 'not.exist', 'not.exist'); + + cy.get('body').type('{ctrl}{z}'); + checkExistObject('not.exist', 'not.exist', 'not.exist'); + }); + + it('Redo objects', () => { + cy.contains('.cvat-annotation-header-button', 'Redo').click(); + checkExistObject('exist', 'not.exist', 'not.exist'); + + cy.get('body').type('{ctrl}{shift}{z}'); + checkExistObject('exist', 'exist', 'not.exist'); + + cy.get('body').type('{ctrl}{y}'); + checkExistObject('exist', 'exist', 'exist'); + }); + }); +});