From b2deaceb3745f6adfacd43b4875cdb9a684bc7bb Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin Date: Mon, 24 Aug 2020 18:52:56 +0300 Subject: [PATCH] Cypress tests for issues 1882, 1886. --- .../issue_1882_polygon_interpolation.js | 72 ++++++++++++++++ ...e_1886_point_coordinates_not_duplicated.js | 84 +++++++++++++++++++ tests/cypress/support/commands.js | 22 +++++ 3 files changed, 178 insertions(+) create mode 100644 tests/cypress/integration/issue_1882_polygon_interpolation.js create mode 100644 tests/cypress/integration/issue_1886_point_coordinates_not_duplicated.js diff --git a/tests/cypress/integration/issue_1882_polygon_interpolation.js b/tests/cypress/integration/issue_1882_polygon_interpolation.js new file mode 100644 index 000000000000..3933836c6a6e --- /dev/null +++ b/tests/cypress/integration/issue_1882_polygon_interpolation.js @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('The points of the previous polygon mustn\'t appear while polygon\'s interpolation.', () => { + + const issueId = '1882' + 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' + + 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('Create a poligon', () => { + cy.createPolygon('Track', [ + {x: 309, y: 431}, + {x: 360, y: 500}, + {x: 320, y: 300}, + ]) + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POLYGON TRACK') + }) + it('Redraw the polygon', () => { + cy.get('#cvat_canvas_shape_1') + .trigger('mousemove', {force: true}) + .trigger('keydown', {key: 'n', shiftKey: true}) + .trigger('keyup', {force: true}, {key: 'n', shiftKey: true}) + cy.createPolygon('Track', [ + {x: 359, y: 431}, + {x: 410, y: 500}, + {x: 370, y: 300}, + ], + false, true) + }) + it('Activate auto bordering mode', () => { + cy.get('.cvat-right-header') + .find('.cvat-header-menu-dropdown') + .trigger('mouseover', {which: 1}) + cy.get('.anticon-setting') + .click() + cy.get('.ant-modal-content').within(() => { + cy.contains('Workspace').click() + cy.get('.cvat-workspace-settings-autoborders').within(() => { + cy.get('[type="checkbox"]').check() + }) + cy.contains('button', 'Close').click() + }) + }) + it('Old points invisible', () => { + cy.get('.cvat_canvas_autoborder_point') + .should('not.exist') + }) + }) +}) diff --git a/tests/cypress/integration/issue_1886_point_coordinates_not_duplicated.js b/tests/cypress/integration/issue_1886_point_coordinates_not_duplicated.js new file mode 100644 index 000000000000..eb7fa36ad0f6 --- /dev/null +++ b/tests/cypress/integration/issue_1886_point_coordinates_not_duplicated.js @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Point coordinates are not duplicated while polygon\'s interpolation.', () => { + + const issueId = '1886' + 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 imagesCount = 4 + let images = [] + for ( let i = 1; i <= imagesCount; i++) { + images.push(`image_${issueId}_${i}.png`) + } + const width = 800 + const height = 800 + const posX = 10 + const posY = 10 + const color = 'white' + const archiveName = `images_issue_${issueId}.zip` + const archivePath = `cypress/fixtures/${archiveName}` + const imagesFolder = `cypress/fixtures/image_issue_${issueId}` + const directoryToArchive = imagesFolder + let pointsСoordinates = [] + + before(() => { + cy.visit('auth/login') + cy.login() + for (let img of images) { + cy.imageGenerator(imagesFolder, img, width, height, color, posX, posY, labelName) + } + cy.createZipArchive(directoryToArchive, archivePath) + cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName) + cy.openTaskJob(taskName) + }) + + describe(`Testing issue "${issueId}"`, () => { + it('Create a poligon', () => { + cy.createPolygon('Track', [ + {x: 300, y: 450}, + {x: 400, y: 450}, + {x: 400, y: 550}, + ]) + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POLYGON TRACK') + }) + it('Go next with a step', () => { + cy.get('.cvat-player-forward-button').click() + cy.get('.cvat-player-frame-selector').within(() => { + cy.get('input[role="spinbutton"]') + .should('have.value', '3') + }) + }) + it('Set a keyframe for the polygon', () => { + cy.get('#cvat-objects-sidebar-state-item-1').within(() => { + cy.get('[data-icon="star"]').click() + }) + }) + it('Go to previous frame and getting point`s coordinates', () => { + cy.get('.cvat-player-previous-button').click() + cy.get('.cvat-player-frame-selector').within(() => { + cy.get('input[role="spinbutton"]') + .should('have.value', '2') + }) + cy.get('#cvat_canvas_shape_1').should('have.prop', 'animatedPoints') + .then(($pointsСoordinates) => { + for (let i of $pointsСoordinates) { + pointsСoordinates.push(`${i.x}, ${i.y}`) + } + }) + }) + it('The coordinates of the points are not duplicated', () => { + for(let i = 0; i < pointsСoordinates.length - 1; i++) { + cy.expect(pointsСoordinates[i]).not.equal(pointsСoordinates[i+1]) + } + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 8284843356b2..05fdc9f3584a 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -129,3 +129,25 @@ Cypress.Commands.add('shapeGrouping', (firstX, firstY, lastX, lastY) => { .trigger('keydown', {key: 'g'}) .trigger('keyup', {key: 'g'}) }) + +Cypress.Commands.add('createPolygon', ( mode, + pointsMap, + complete=true, + reDraw=false) => { + if (!reDraw) { + cy.get('.cvat-draw-polygon-control').click() + cy.get('.cvat-draw-shape-popover-content') + .find('button') + .contains(mode) + .click({force: true}) + } + pointsMap.forEach(element => { + cy.get('.cvat-canvas-container') + .click(element.x, element.y) + }) + if (complete) { + cy.get('.cvat-canvas-container') + .trigger('keydown', {key: 'n'}) + .trigger('keyup', {key: 'n'}) + } +})