diff --git a/tests/cypress/integration/issue_1391_delete_point.js b/tests/cypress/integration/issue_1391_delete_point.js new file mode 100644 index 00000000..d174a6e9 --- /dev/null +++ b/tests/cypress/integration/issue_1391_delete_point.js @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('When delete a point, the required point is deleted.', () => { + + const issueId = '1391' + const labelName = `Issue ${issueId}` + const taskName = `New annotation task for ${labelName}` + const attrName = `Attr for ${labelName}` + const textDefaultValue = 'Some default value for type Text' + const image = `image_${issueId}.png` + const width = 800 + const height = 800 + const posX = 10 + const posY = 10 + const color = 'white' + let pointsСoordinatesBeforeDeletePoint = [] + let pointsСoordinatesAfterDeletePoint = [] + + before(() => { + cy.visit('auth/login') + cy.login() + cy.imageGenerator('cypress/fixtures', image, width, height, color, posX, posY, labelName) + cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, image) + cy.openTaskJob(taskName) + }) + + describe(`Testing issue "${issueId}"`, () => { + it('Crearte polyline', () => { + cy.createPolyline('Shape', [ + {x: 309, y: 250}, + {x: 309, y: 350}, + {x: 309, y: 450} + ]) + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POLYLINE SHAPE') + }) + it('Get points coordinates from created polyline', () => { + cy.get('#cvat_canvas_shape_1').should('have.prop', 'animatedPoints') + .then(($pointsСoordinates) => { + for (let i of $pointsСoordinates) { + pointsСoordinatesBeforeDeletePoint.push(`${i.x}, ${i.y}`) + } + }) + }) + it('Remove the second point from created polyline', () => { + cy.get('#cvat_canvas_shape_1') + .trigger('mousemove', {force: true}) + .trigger('mouseover', {force: true}) + cy.get('.svg_select_points').then(points => { + cy.get(points).eq(0).then(point1 => { + cy.get(point1) + .rightclick() + }) + cy.get(points).eq(1).then(point2 => { + cy.get(point2) + .rightclick({force: true}) + }) + cy.contains('Delete point') + .click() + }) + }) + it('Get points coordinates from turned out polyline', () => { + cy.get('#cvat_canvas_shape_1').should('have.prop', 'animatedPoints') + .then(($pointsСoordinates) => { + for (let i of $pointsСoordinates) { + pointsСoordinatesAfterDeletePoint.push(`${i.x}, ${i.y}`) + } + }) + }) + it('Coordinate of second point before delete not in coordinates array after delete', () => { + cy.get(pointsСoordinatesBeforeDeletePoint).then(point => { + cy.expect(pointsСoordinatesAfterDeletePoint).not.contain(point[1]) + }) + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 84f85708..20eb9b60 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -210,3 +210,22 @@ Cypress.Commands.add('updateAttributes', (additionalAttrName, typeAttribute, add cy.get('.ant-select-dropdown').last().contains(typeAttribute).click() cy.get('[placeholder="Default value"]').first().type(additionalValue) }) + +Cypress.Commands.add('createPolyline', (mode, + pointsMap) => { + cy.get('.cvat-draw-polyline-control').click() + cy.contains('Draw new polyline') + .parents('.cvat-draw-shape-popover-content') + .within(() => { + cy.get('button') + .contains(mode) + .click({force: true}) + }) + pointsMap.forEach(element => { + cy.get('.cvat-canvas-container') + .click(element.x, element.y) + }) + cy.get('.cvat-canvas-container') + .trigger('keydown', {key: 'n'}) + .trigger('keyup', {key: 'n'}) +})