From 295090461d8077081a55dff55e170d2007e9325b Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Fri, 9 Oct 2020 14:07:17 +0300 Subject: [PATCH] Cypress test. Actions on polylines. (#2269) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to draw a polylines shape/track Try to use parameter “number of points”, polylines drawing should automatically stop after this number of points is achieved Try to switch a label and draw one more polylines Check if everything works here Co-authored-by: Kruchinin --- ...e_11_polylines_shape_track_label_points.js | 168 ++++++++++++++++++ .../integration/issue_1391_delete_point.js | 17 +- tests/cypress/support/commands.js | 24 ++- 3 files changed, 197 insertions(+), 12 deletions(-) create mode 100644 tests/cypress/integration/case_11_polylines_shape_track_label_points.js diff --git a/tests/cypress/integration/case_11_polylines_shape_track_label_points.js b/tests/cypress/integration/case_11_polylines_shape_track_label_points.js new file mode 100644 index 00000000..914f9e6b --- /dev/null +++ b/tests/cypress/integration/case_11_polylines_shape_track_label_points.js @@ -0,0 +1,168 @@ +/* eslint-disable no-undef */ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Actions on polylines', () => { + + const caseId = '11' + const labelName = `Case ${caseId}` + const taskName = `New annotation task for ${labelName}` + const attrName = `Attr for ${labelName}` + const textDefaultValue = 'Some default value for type Text' + const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}` + const image = `${imageFileName}.png` + const newLabelName = `New ${labelName}` + const width = 800 + const height = 800 + const posX = 10 + const posY = 10 + const color = 'gray' + const createPolylinesShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 200, y: 200}, + {x: 250, y: 200}, + {x: 250, y: 250}, + ], + complete: true, + numberOfPoints: null + } + const createPolylinesTrack = { + type: 'Track', + switchLabel: false, + pointsMap: [ + {x: 300, y: 200}, + {x: 350, y: 200}, + {x: 350, y: 350}, + ], + complete: true, + numberOfPoints: null + } + const createPolylinesShapePoints = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 400, y: 200}, + {x: 450, y: 200}, + {x: 450, y: 250}, + {x: 400, y: 350}, + {x: 380, y: 330}, + ], + numberOfPoints: 5 + } + const createPolylinesTrackPoints = { + type: 'Track', + switchLabel: false, + pointsMap: [ + {x: 500, y: 200}, + {x: 550, y: 200}, + {x: 550, y: 250}, + {x: 500, y: 350}, + {x: 480, y: 330}, + ], + numberOfPoints: 5 + } + const createPolylinesShapeSwitchLabel = { + type: 'Shape', + switchLabel: true, + labelName: newLabelName, + pointsMap: [ + {x: 600, y: 200}, + {x: 650, y: 200}, + {x: 650, y: 250}, + ], + complete: true, + numberOfPoints: null + } + const createPolylinesTrackSwitchLabel = { + type: 'Track', + switchLabel: true, + labelName: newLabelName, + pointsMap: [ + {x: 700, y: 200}, + {x: 750, y: 200}, + {x: 750, y: 250}, + ], + complete: true, + numberOfPoints: null + } + + 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.openTask(taskName) + }) + + describe(`Testing case "${caseId}"`, () => { + it('Add new label', () => { + cy.contains('button', 'Add label').click() + cy.get('[placeholder="Label name"]').type(newLabelName) + cy.contains('button', 'Done').click() + }) + it('Open a job', () => { + cy.openJob() + }) + it('Draw a polylines shape, track', () => { + cy.createPolyline(createPolylinesShape) + cy.get('#cvat_canvas_shape_1') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POLYLINE SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createPolyline(createPolylinesTrack) + cy.get('#cvat_canvas_shape_2') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-2') + .should('contain', '2').and('contain', 'POLYLINE TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a polylines shape, track with use parameter "number of points"', () => { + cy.createPolyline(createPolylinesShapePoints) + cy.get('#cvat_canvas_shape_3') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-3') + .should('contain', '3').and('contain', 'POLYLINE SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createPolyline(createPolylinesTrackPoints) + cy.get('#cvat_canvas_shape_4') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-4') + .should('contain', '4').and('contain', 'POLYLINE TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a polylines shape, track with second label', () => { + cy.createPolyline(createPolylinesShapeSwitchLabel) + cy.get('#cvat_canvas_shape_5') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-5') + .should('contain', '5').and('contain', 'POLYLINE SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', newLabelName) + }) + cy.createPolyline(createPolylinesTrackSwitchLabel) + cy.get('#cvat_canvas_shape_6') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-6') + .should('contain', '6').and('contain', 'POLYLINE TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + }) +}) diff --git a/tests/cypress/integration/issue_1391_delete_point.js b/tests/cypress/integration/issue_1391_delete_point.js index d174a6e9..78d496f0 100644 --- a/tests/cypress/integration/issue_1391_delete_point.js +++ b/tests/cypress/integration/issue_1391_delete_point.js @@ -21,6 +21,17 @@ context('When delete a point, the required point is deleted.', () => { const color = 'white' let pointsСoordinatesBeforeDeletePoint = [] let pointsСoordinatesAfterDeletePoint = [] + const createPolylinesShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 309, y: 250}, + {x: 309, y: 350}, + {x: 309, y: 450} + ], + complete: true, + numberOfPoints: null + } before(() => { cy.visit('auth/login') @@ -32,11 +43,7 @@ context('When delete a point, the required point is deleted.', () => { describe(`Testing issue "${issueId}"`, () => { it('Crearte polyline', () => { - cy.createPolyline('Shape', [ - {x: 309, y: 250}, - {x: 309, y: 350}, - {x: 309, y: 450} - ]) + cy.createPolyline(createPolylinesShape) cy.get('#cvat-objects-sidebar-state-item-1') .should('contain', '1').and('contain', 'POLYLINE SHAPE') }) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 75578791..d9f52b28 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -243,23 +243,33 @@ Cypress.Commands.add('updateAttributes', (multiAttrParams) => { cy.get('[placeholder="Default value"]').first().type(multiAttrParams.additionalValue) }) -Cypress.Commands.add('createPolyline', (mode, - pointsMap) => { +Cypress.Commands.add('createPolyline', (createPolylineParams) => { cy.get('.cvat-draw-polyline-control').click() + if (createPolylineParams.switchLabel) { + cy.switchLabel(createPolylineParams.labelName) + } cy.contains('Draw new polyline') .parents('.cvat-draw-shape-popover-content') .within(() => { + if (createPolylineParams.numberOfPoints) { + createPolylineParams.complete = false + cy.get('.ant-input-number-input') + .clear() + .type(createPolylineParams.numberOfPoints) + } cy.get('button') - .contains(mode) + .contains(createPolylineParams.type) .click({force: true}) }) - pointsMap.forEach(element => { + createPolylineParams.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'}) + if (createPolylineParams.complete) { + cy.get('.cvat-canvas-container') + .trigger('keydown', {key: 'n'}) + .trigger('keyup', {key: 'n'}) + } }) Cypress.Commands.add('getTaskID', (taskName) => {