From 5290c440054d259b18ebf22b837918619319ae82 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 12 Oct 2020 09:15:31 +0300 Subject: [PATCH] Cypress test. Actions on points. (#2292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to draw a points shape/track Try to use parameter “number of points”, points drawing should automatically stop after this number of points is achieved Try to switch a label and draw one more points Check if everything works here Co-authored-by: Kruchinin --- .../case_12_points_shape_track_label.js | 167 ++++++++++++++++++ ..._1368_points_track_invisible_next_frame.js | 11 +- ...sue_1841_hidden_points_cuboids_grouping.js | 33 +++- tests/cypress/support/commands.js | 35 +++- 4 files changed, 233 insertions(+), 13 deletions(-) create mode 100644 tests/cypress/integration/case_12_points_shape_track_label.js diff --git a/tests/cypress/integration/case_12_points_shape_track_label.js b/tests/cypress/integration/case_12_points_shape_track_label.js new file mode 100644 index 00000000..ae7eeb6c --- /dev/null +++ b/tests/cypress/integration/case_12_points_shape_track_label.js @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Actions on points', () => { + + const caseId = '12' + 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 createPointsShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 200, y: 200}, + {x: 250, y: 200}, + {x: 250, y: 250}, + ], + complete: true, + numberOfPoints: null + } + const createPointsTrack = { + type: 'Track', + switchLabel: false, + pointsMap: [ + {x: 300, y: 200}, + {x: 350, y: 200}, + {x: 350, y: 350}, + ], + complete: true, + numberOfPoints: null + } + const createPointsShapePoints = { + 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 createPointsTrackPoints = { + 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 createPointsShapeSwitchLabel = { + type: 'Shape', + switchLabel: true, + labelName: newLabelName, + pointsMap: [ + {x: 600, y: 200}, + {x: 650, y: 200}, + {x: 650, y: 250}, + ], + complete: true, + numberOfPoints: null + } + const createPointsTrackSwitchLabel = { + 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 points shape, track', () => { + cy.createPoint(createPointsShape) + cy.get('#cvat_canvas_shape_1') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POINTS SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createPoint(createPointsTrack) + cy.get('#cvat_canvas_shape_2') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-2') + .should('contain', '2').and('contain', 'POINTS TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a points shape, track with use parameter "number of points"', () => { + cy.createPoint(createPointsShapePoints) + cy.get('#cvat_canvas_shape_3') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-3') + .should('contain', '3').and('contain', 'POINTS SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createPoint(createPointsTrackPoints) + cy.get('#cvat_canvas_shape_4') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-4') + .should('contain', '4').and('contain', 'POINTS TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a points shape, track with second label', () => { + cy.createPoint(createPointsShapeSwitchLabel) + cy.get('#cvat_canvas_shape_5') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-5') + .should('contain', '5').and('contain', 'POINTS SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', newLabelName) + }) + cy.createPoint(createPointsTrackSwitchLabel) + cy.get('#cvat_canvas_shape_6') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-6') + .should('contain', '6').and('contain', 'POINTS TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + }) +}) diff --git a/tests/cypress/integration/issue_1368_points_track_invisible_next_frame.js b/tests/cypress/integration/issue_1368_points_track_invisible_next_frame.js index d9fd151e..549713db 100644 --- a/tests/cypress/integration/issue_1368_points_track_invisible_next_frame.js +++ b/tests/cypress/integration/issue_1368_points_track_invisible_next_frame.js @@ -25,6 +25,15 @@ context('Points track it is still invisible on next frames', () => { const archivePath = `cypress/fixtures/${archiveName}` const imagesFolder = `cypress/fixtures/image_issue_${issueId}` const directoryToArchive = imagesFolder + const createPointsTrack = { + type: 'Track', + switchLabel: false, + pointsMap: [ + {x: 300, y: 410}, + ], + complete: true, + numberOfPoints: null + } before(() => { cy.visit('auth/login') @@ -39,7 +48,7 @@ context('Points track it is still invisible on next frames', () => { describe(`Testing issue "${issueId}"`, () => { it('Create a points track', () => { - cy.createPoint(300, 410, 'Track') + cy.createPoint(createPointsTrack) cy.get('#cvat-objects-sidebar-state-item-1') .should('contain', '1').and('contain', 'POINTS TRACK') }) diff --git a/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js b/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js index 890f36fb..e2ae6950 100644 --- a/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js +++ b/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js @@ -20,6 +20,33 @@ context('Hidden objects mustn\'t consider when we want to group visible objects const posY = 10 const color = 'white' let bgcolor = '' + const createFirstPointsShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 300, y: 410}, + ], + complete: true, + numberOfPoints: null + } + const createSecondPointsShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 350, y: 410}, + ], + complete: true, + numberOfPoints: null + } + const createThridPointsShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + {x: 400, y: 410}, + ], + complete: true, + numberOfPoints: null + } before(() => { cy.visit('auth/login') @@ -34,13 +61,13 @@ context('Hidden objects mustn\'t consider when we want to group visible objects cy.changeAppearance('Group') }) it('Create three points as different objects', () => { - cy.createPoint(300, 410) + cy.createPoint(createFirstPointsShape) cy.get('#cvat-objects-sidebar-state-item-1') .should('contain', '1').and('contain', 'POINTS SHAPE') - cy.createPoint(350, 410) + cy.createPoint(createSecondPointsShape) cy.get('#cvat-objects-sidebar-state-item-2') .should('contain', '2').and('contain', 'POINTS SHAPE') - cy.createPoint(400, 410) + cy.createPoint(createThridPointsShape) cy.get('#cvat-objects-sidebar-state-item-3') .should('contain', '3').and('contain', 'POINTS SHAPE') .should('have.attr', 'style').then(($bgcolor) => { diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index d9f52b28..b96b40d6 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -121,16 +121,33 @@ Cypress.Commands.add('switchLabel', (labelName) => { .click() }) -Cypress.Commands.add('createPoint', (posX, posY, type='Shape') => { +Cypress.Commands.add('createPoint', (createPointParams) => { cy.get('.cvat-draw-points-control').click() - cy.get('.cvat-draw-shape-popover-content') - .find('button') - .contains(type) - .click({force: true}) - cy.get('.cvat-canvas-container') - .click(posX, posY) - .trigger('keydown', {key: 'n'}) - .trigger('keyup', {key: 'n'}) + if (createPointParams.switchLabel) { + cy.switchLabel(createPointParams.labelName) + } + cy.contains('Draw new points') + .parents('.cvat-draw-shape-popover-content') + .within(() => { + if (createPointParams.numberOfPoints) { + createPointParams.complete = false + cy.get('.ant-input-number-input') + .clear() + .type(createPointParams.numberOfPoints) + } + cy.get('button') + .contains(createPointParams.type) + .click({force: true}) + }) + createPointParams.pointsMap.forEach(element => { + cy.get('.cvat-canvas-container') + .click(element.x, element.y) + }) + if (createPointParams.complete) { + cy.get('.cvat-canvas-container') + .trigger('keydown', {key: 'n'}) + .trigger('keyup', {key: 'n'}) + } }) Cypress.Commands.add('changeAppearance', (colorBy) => {