Skip to content

Commit

Permalink
Cypress test for case 9. (#2262)
Browse files Browse the repository at this point in the history
Try to draw a cuboid shape in two ways (by 2 points, by 4 points)
Try to draw a cuboid track
Try to switch a label and draw one more cuboid
Check if objects are drawn and they are shapes/tracks with right labels

Co-authored-by: Kruchinin <[email protected]>
  • Loading branch information
dvkruchinin and Kruchinin authored Oct 7, 2020
1 parent 84b8a85 commit 10964b9
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 5 deletions.
166 changes: 166 additions & 0 deletions tests/cypress/integration/case_9_cuboid_shape_track_label.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

/// <reference types="cypress" />

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)
})

})
})
})
11 changes: 10 additions & 1 deletion tests/cypress/integration/issue_1568_cuboid_dump_annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
})
Expand Down
20 changes: 16 additions & 4 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 10964b9

Please sign in to comment.