diff --git a/tests/cypress/integration/case_9_cuboid_shape_track_label.js b/tests/cypress/integration/case_9_cuboid_shape_track_label.js new file mode 100644 index 00000000..3d594c98 --- /dev/null +++ b/tests/cypress/integration/case_9_cuboid_shape_track_label.js @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Actions on Cuboid', () => { + + const caseId = '9' + 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 createCuboidShape2Points = { + points: 'From rectangle', + type: 'Shape', + switchLabel: false, + firstX: 250, + firstY: 350, + secondX: 350, + secondY: 450 + } + const createCuboidShape4Points = { + points: 'By 4 Points', + type: 'Shape', + switchLabel: false, + firstX: 400, + firstY: 350, + secondX: 500, + secondY: 350, + thirdX: 500, + thirdY: 450, + fourthX: 400, + fourthY: 450 + } + const createCuboidTrack2Points = { + points: 'From rectangle', + type: 'Track', + switchLabel: false, + firstX: createCuboidShape2Points.firstX, + firstY: createCuboidShape2Points.firstY - 150, + secondX: createCuboidShape2Points.secondX, + secondY: createCuboidShape2Points.secondY -150 + } + const createCuboidTrack4Points = { + points: 'By 4 Points', + type: 'Track', + switchLabel: false, + firstX: createCuboidShape4Points.firstX, + firstY: createCuboidShape4Points.firstY - 150, + secondX: createCuboidShape4Points.secondX - 100, + secondY: createCuboidShape4Points.secondY - 50, + thirdX: createCuboidShape4Points.thirdX, + thirdY: createCuboidShape4Points.thirdY - 150, + fourthX: createCuboidShape4Points.fourthX, + fourthY: createCuboidShape4Points.fourthY - 150 + } + const createCuboidShape2PointsNewLabel = { + labelName: newLabelName, + points: 'From rectangle', + type: 'Shape', + switchLabel: true, + firstX: createCuboidShape2Points.firstX, + firstY: createCuboidShape2Points.firstY + 150, + secondX: createCuboidShape2Points.secondX, + secondY: createCuboidShape2Points.secondY + 150 + } + const createCuboidShape4PointsNewLabel = { + labelName: newLabelName, + points: 'By 4 Points', + type: 'Shape', + switchLabel: true, + firstX: createCuboidShape4Points.firstX, + firstY: createCuboidShape4Points.firstY + 150, + secondX: createCuboidShape4Points.secondX, + secondY: createCuboidShape4Points.secondY + 150, + thirdX: createCuboidShape4Points.thirdX, + thirdY: createCuboidShape4Points.thirdY + 150, + fourthX: createCuboidShape4Points.fourthX, + fourthY: createCuboidShape4Points.fourthY + 150 + } + + 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 Cuboid shape in two ways (From rectangle, by 4 points)', () => { + cy.createCuboid(createCuboidShape2Points) + cy.get('#cvat_canvas_shape_1') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'CUBOID SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createCuboid(createCuboidShape4Points) + cy.get('#cvat_canvas_shape_2') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-2') + .should('contain', '2').and('contain', 'CUBOID SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a Cuboid track in two ways (From rectangle, by 4 points)', () => { + cy.createCuboid(createCuboidTrack2Points) + cy.get('#cvat_canvas_shape_3') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-3') + .should('contain', '3').and('contain', 'CUBOID TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + cy.createCuboid(createCuboidTrack4Points) + cy.get('#cvat_canvas_shape_4') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-4') + .should('contain', '4').and('contain', 'CUBOID TRACK').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', labelName) + }) + }) + it('Draw a new Cuboid shape in two ways (From rectangle, by 4 points) with second label', () => { + cy.createCuboid(createCuboidShape2PointsNewLabel) + cy.get('#cvat_canvas_shape_5') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-5') + .should('contain', '5').and('contain', 'CUBOID SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', newLabelName) + }) + cy.createCuboid(createCuboidShape4PointsNewLabel) + cy.get('#cvat_canvas_shape_6') + .should('exist').and('be.visible') + cy.get('#cvat-objects-sidebar-state-item-6') + .should('contain', '6').and('contain', 'CUBOID SHAPE').within(() => { + cy.get('.ant-select-selection-selected-value') + .should('contain', newLabelName) + }) + + }) + }) +}) diff --git a/tests/cypress/integration/issue_1568_cuboid_dump_annotation.js b/tests/cypress/integration/issue_1568_cuboid_dump_annotation.js index 1a21471f..2a7ea283 100644 --- a/tests/cypress/integration/issue_1568_cuboid_dump_annotation.js +++ b/tests/cypress/integration/issue_1568_cuboid_dump_annotation.js @@ -19,6 +19,15 @@ context('Dump annotation if cuboid created', () => { const posX = 10 const posY = 10 const color = 'gray' + const createCuboidShape2Points = { + points: 'From rectangle', + type: 'Shape', + switchLabel: false, + firstX: 250, + firstY: 350, + secondX: 350, + secondY: 450 + } before(() => { cy.visit('auth/login') @@ -30,7 +39,7 @@ context('Dump annotation if cuboid created', () => { describe(`Testing issue "${issueId}"`, () => { it('Create a cuboid', () => { - cy.createCuboid('Shape', 309, 431, 616, 671) + cy.createCuboid(createCuboidShape2Points) cy.get('#cvat-objects-sidebar-state-item-1') .should('contain', '1').and('contain', 'CUBOID SHAPE') }) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 71de2335..50ea068d 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -202,19 +202,31 @@ Cypress.Commands.add('changeAnnotationMode', (mode) => { .should('contain.text', mode) }) -Cypress.Commands.add('createCuboid', (mode, firstX, firstY, lastX, lastY) => { +Cypress.Commands.add('createCuboid', (createCuboidParams) => { cy.get('.cvat-draw-cuboid-control').click() + if (createCuboidParams.switchLabel) { + cy.switchLabel(createCuboidParams.labelName) + } + cy.get('.cvat-draw-shape-popover-content') + .contains(createCuboidParams.points) + .click() cy.contains('Draw new cuboid') .parents('.cvat-draw-shape-popover-content') .within(() => { cy.get('button') - .contains(mode) + .contains(createCuboidParams.type) .click({force: true}) }) cy.get('.cvat-canvas-container') - .click(firstX, firstY) + .click(createCuboidParams.firstX, createCuboidParams.firstY) cy.get('.cvat-canvas-container') - .click(lastX, lastY) + .click(createCuboidParams.secondX, createCuboidParams.secondY) + if (createCuboidParams.points === 'By 4 Points') { + cy.get('.cvat-canvas-container') + .click(createCuboidParams.thirdX, createCuboidParams.thirdY) + cy.get('.cvat-canvas-container') + .click(createCuboidParams.fourthX, createCuboidParams.fourthY) + } }) Cypress.Commands.add('updateAttributes', (multiAttrParams) => {