Cypress tests for issues 1882, 1886. (#2075)

* Cypress tests for issues 1882, 1886.

* Applying comments.

Add command to open/close settings.

Co-authored-by: Dmitry Kruchinin <dmitryx.kruchinin@intel.com>
main
Dmitry Kruchinin 6 years ago committed by GitHub
parent 026e8e58b4
commit 4cede5c959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,68 @@
/*
* 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 polygon', () => {
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.openSettings()
cy.get('.ant-modal-content').within(() => {
cy.contains('Workspace').click()
cy.get('.cvat-workspace-settings-autoborders').within(() => {
cy.get('[type="checkbox"]').check()
})
})
cy.closeSettings()
})
it('Old points invisible', () => {
cy.get('.cvat_canvas_autoborder_point')
.should('not.exist')
})
})
})

@ -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 polygon', () => {
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-previous-button').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])
}
})
})
})

@ -129,3 +129,41 @@ Cypress.Commands.add('shapeGrouping', (firstX, firstY, lastX, lastY) => {
.trigger('keydown', {key: 'g'})
.trigger('keyup', {key: 'g'})
})
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'})
}
})
Cypress.Commands.add('openSettings', () => {
cy.get('.cvat-right-header')
.find('.cvat-header-menu-dropdown')
.trigger('mouseover', {which: 1})
cy.get('.anticon-setting')
.click()
})
Cypress.Commands.add('closeSettings', () => {
cy.get('.ant-modal-content')
.should('contain', 'Settings')
.within(() => {
cy.contains('button', 'Close').click()
})
})

Loading…
Cancel
Save