Skip to content

Commit

Permalink
Cypress test for issue 1425. (#2122)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Kruchinin <dmitryx.kruchinin@intel.com>
dvkruchinin and Dmitry Kruchinin authored Sep 7, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent bd14385 commit bd6cefe
Showing 2 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/

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

context('The highlighted attribute in AAM should correspond to the chosen attribute', () => {

const issueId = '1425'
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 = 'gray'
const additionalAttrName = `Attr 2`
const additionalValue = `Attr value 2`
const typeAttribute = 'Text'
let textValue = ''

before(() => {
cy.visit('auth/login')
cy.login()
cy.imageGenerator('cypress/fixtures', image, width, height, color, posX, posY, labelName)
})

describe(`Testing issue "${issueId}"`, () => {
it('Create a task with multiple attributes, create a object', () => {
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, image, false, 1, true, additionalAttrName, typeAttribute, additionalValue)
cy.openTaskJob(taskName)
cy.createShape(309, 431, 616, 671)
})
it('Go to AAM', () => {
cy.changeAnnotationMode('Attribute annotation')
})
it('Check if highlighted attribute correspond to the chosen attribute in right panel', () => {
cy.get('.cvat_canvas_text').within(() => {
cy.get('[style="fill: red;"]').then($textValue => {
textValue = $textValue.text().split(': ')[1]
})
})
cy.get('.attribute-annotation-sidebar-attr-editor').within(() => {
cy.get('[type="text"]').should('have.value', textValue)
})
})
it('Go to next attribute and check again', () => {
cy.get('.attribute-annotation-sidebar-attribute-switcher')
.find('.anticon-right')
.click({force: true})
cy.get('.cvat_canvas_text').within(() => {
cy.get('[style="fill: red;"]').then($textValue => {
textValue = $textValue.text().split(': ')[1]
})
})
cy.get('.attribute-annotation-sidebar-attr-editor').within(() => {
cy.get('[type="text"]').should('have.value', textValue)
})
})
})
})
21 changes: 18 additions & 3 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -31,7 +31,11 @@ Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task',
textDefaultValue='Some default value for type Text',
image='image.png',
multiJobs=false,
segmentSize=1) => {
segmentSize=1,
multiAttr=false,
additionalAttrName,
typeAttribute,
additionalValue) => {
cy.get('#cvat-create-task-button').click()
cy.url().should('include', '/tasks/create')
cy.get('[id="name"]').type(taksName)
@@ -42,15 +46,18 @@ Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task',
cy.get('div[title="Select"]').click()
cy.get('li').contains('Text').click()
cy.get('[placeholder="Default value"]').type(textDefaultValue)
if (multiAttr) {
cy.updateAttributes(additionalAttrName, typeAttribute, additionalValue)
}
cy.contains('button', 'Done').click()
cy.get('input[type="file"]').attachFile(image, { subjectType: 'drag-n-drop' });
cy.get('input[type="file"]').attachFile(image, { subjectType: 'drag-n-drop' })
if (multiJobs) {
cy.contains('Advanced configuration').click()
cy.get('#segmentSize')
.type(segmentSize)
}
cy.contains('button', 'Submit').click()
cy.contains('The task has been created', {timeout: '8000'})
cy.contains('The task has been created')
cy.get('[value="tasks"]').click()
cy.url().should('include', '/tasks?page=')
})
@@ -195,3 +202,11 @@ Cypress.Commands.add('createCuboid', (mode, firstX, firstY, lastX, lastY) => {
cy.get('.cvat-canvas-container')
.click(lastX, lastY)
})

Cypress.Commands.add('updateAttributes', (additionalAttrName, typeAttribute, additionalValue) => {
cy.contains('button', 'Add an attribute').click()
cy.get('[placeholder="Name"]').first().type(additionalAttrName)
cy.get('div[title="Select"]').first().click()
cy.get('.ant-select-dropdown').last().contains(typeAttribute).click()
cy.get('[placeholder="Default value"]').first().type(additionalValue)
})

0 comments on commit bd6cefe

Please sign in to comment.