Skip to content

Commit

Permalink
Cypress tests for issues 1882, 1886.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kruchinin committed Aug 24, 2020
1 parent 9e05ffc commit 9580b94
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/cypress/integration/issue_1882_polygon_interpolation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

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

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')
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

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

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-buttons > :nth-child(3) > svg').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])
}
})
})
})
22 changes: 22 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,25 @@ Cypress.Commands.add('createTrack', (firstX, firstY, lastX, lastY) => {
cy.get('.cvat-canvas-container')
.click(lastX, lastY)
})

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

0 comments on commit 9580b94

Please sign in to comment.