Skip to content

Commit

Permalink
Cypress test. Undo and redo feature. (#2535)
Browse files Browse the repository at this point in the history
* add test

* step for create objects moved to before function

Co-authored-by: Dmitriy Oparin <[email protected]>
  • Loading branch information
DmitriyOparin and Dmitriy Oparin authored Dec 11, 2020
1 parent 09cf807 commit 6e5f683
Showing 1 changed file with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

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

0 comments on commit 6e5f683

Please sign in to comment.