From bd6cefeada8d4ce3c73e5903c99dc853d49baeb1 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 7 Sep 2020 09:27:41 +0300 Subject: [PATCH] Cypress test for issue 1425. (#2122) Co-authored-by: Dmitry Kruchinin --- ...d_attribute_correspond_chosen_attribute.js | 66 +++++++++++++++++++ tests/cypress/support/commands.js | 21 +++++- 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 tests/cypress/integration/issue_1425_highlighted_attribute_correspond_chosen_attribute.js diff --git a/tests/cypress/integration/issue_1425_highlighted_attribute_correspond_chosen_attribute.js b/tests/cypress/integration/issue_1425_highlighted_attribute_correspond_chosen_attribute.js new file mode 100644 index 000000000000..756a4702e1cf --- /dev/null +++ b/tests/cypress/integration/issue_1425_highlighted_attribute_correspond_chosen_attribute.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +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) + }) + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 20767e486416..a9cef747b346 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -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) +})