From 15acb953e3d4e4903b2320a1ec41ba690ecb3f0d Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 31 Aug 2020 12:06:11 +0300 Subject: [PATCH] Cypress test for issue 1444. (#2099) Co-authored-by: Dmitry Kruchinin --- .../issue_1444_filter_property_shape.js | 57 +++++++++++++++++++ tests/cypress/support/commands.js | 11 ++-- 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 tests/cypress/integration/issue_1444_filter_property_shape.js diff --git a/tests/cypress/integration/issue_1444_filter_property_shape.js b/tests/cypress/integration/issue_1444_filter_property_shape.js new file mode 100644 index 00000000..6859869d --- /dev/null +++ b/tests/cypress/integration/issue_1444_filter_property_shape.js @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Filter property "shape" work correctly', () => { + + const issueId = '1444' + 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 shape', () => { + cy.createShape(309, 431, 616, 671) + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'RECTANGLE SHAPE') + }) + it('Create a polygon', () => { + cy.createPolygon('Shape', [ + {x: 300, y: 100}, + {x: 400, y: 400}, + {x: 400, y: 250}, + ]) + cy.get('#cvat-objects-sidebar-state-item-2') + .should('contain', '2').and('contain', 'POLYGON SHAPE') + }) + it('Input filter "shape == "polygon""', () => { + cy.get('.cvat-annotations-filters-input') + .type('shape == "polygon"{Enter}') + }) + it('Only polygon is visible', () => { + cy.get('#cvat_canvas_shape_2') + .should('exist') + cy.get('#cvat_canvas_shape_1') + .should('not.exist') + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index ec6538c9..981b0de4 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -136,10 +136,13 @@ Cypress.Commands.add('createPolygon', ( mode, 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}) + cy.contains('Draw new polygon') + .parents('.cvat-draw-shape-popover-content') + .within(() => { + cy.get('button') + .contains(mode) + .click({force: true}) + }) } pointsMap.forEach(element => { cy.get('.cvat-canvas-container')