From 778b7f52273b47aa3a01396f3c9f35dc0ef01d75 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Wed, 26 Aug 2020 16:20:11 +0300 Subject: [PATCH] Cypress test for issue 1841 (#2057) Co-authored-by: Dmitry Kruchinin --- ...sue_1841_hidden_points_cuboids_grouping.js | 66 +++++++++++++++++++ tests/cypress/support/commands.js | 30 +++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js diff --git a/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js b/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js new file mode 100644 index 00000000..890f36fb --- /dev/null +++ b/tests/cypress/integration/issue_1841_hidden_points_cuboids_grouping.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Hidden objects mustn\'t consider when we want to group visible objects only and use an grouping area for it.', () => { + + const issueId = '1841' + 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' + let bgcolor = '' + + 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('Change appearance to "Group"', () => { + cy.changeAppearance('Group') + }) + it('Create three points as different objects', () => { + cy.createPoint(300, 410) + cy.get('#cvat-objects-sidebar-state-item-1') + .should('contain', '1').and('contain', 'POINTS SHAPE') + cy.createPoint(350, 410) + cy.get('#cvat-objects-sidebar-state-item-2') + .should('contain', '2').and('contain', 'POINTS SHAPE') + cy.createPoint(400, 410) + cy.get('#cvat-objects-sidebar-state-item-3') + .should('contain', '3').and('contain', 'POINTS SHAPE') + .should('have.attr', 'style').then(($bgcolor) => { + bgcolor = $bgcolor // Get style attr "background-color" + }) + }) + it('Hide the last point', () => { + cy.get('#cvat-objects-sidebar-state-item-3') + .find('.anticon-eye') + .click() + cy.get('#cvat-objects-sidebar-state-item-3') + .find('.anticon-eye-invisible') + .should('exist') + }) + it('Group the created points', () => { + cy.shapeGrouping(250, 380, 430, 450) + }) + it('The hidden point is not grouping', () => { + cy.get('#cvat-objects-sidebar-state-item-3') + .should('have.attr', 'style', bgcolor) // "background-color" should not be changed + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index faf8e2d1..82848433 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -99,3 +99,33 @@ Cypress.Commands.add('createTrack', (firstX, firstY, lastX, lastY) => { cy.get('.cvat-canvas-container') .click(lastX, lastY) }) + +Cypress.Commands.add('createPoint', (posX, posY) => { + cy.get('.cvat-draw-points-control').click() + cy.get('.cvat-draw-shape-popover-content') + .find('button') + .contains('Shape') + .click({force: true}) + cy.get('.cvat-canvas-container') + .click(posX, posY) + .trigger('keydown', {key: 'n'}) + .trigger('keyup', {key: 'n'}) +}) + +Cypress.Commands.add('changeAppearance', (colorBy) => { + cy.get('.cvat-objects-appearance-content').within(() => { + cy.get('[type="radio"]') + .check(colorBy, {force: true}) + }) +}) + +Cypress.Commands.add('shapeGrouping', (firstX, firstY, lastX, lastY) => { + cy.get('.cvat-canvas-container') + .trigger('keydown', {key: 'g'}) + .trigger('keyup', {key: 'g'}) + .trigger('mousedown', firstX, firstY, {which: 1}) + .trigger('mousemove', lastX, lastY) + .trigger('mouseup', lastX, lastY) + .trigger('keydown', {key: 'g'}) + .trigger('keyup', {key: 'g'}) +})