From bf8e9c252925ff04b1d9388b44df60518c63577d Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Tue, 24 Nov 2020 13:38:13 +0300 Subject: [PATCH] Cypress test. Issue 1823. --- ...ntext_menu_when_switching_another_frame.js | 76 +++++++++++++++++++ tests/cypress/support/commands.js | 33 +++++--- 2 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 tests/cypress/integration/actions_tasks_objects/issue_1823_opening_context_menu_when_switching_another_frame.js diff --git a/tests/cypress/integration/actions_tasks_objects/issue_1823_opening_context_menu_when_switching_another_frame.js b/tests/cypress/integration/actions_tasks_objects/issue_1823_opening_context_menu_when_switching_another_frame.js new file mode 100644 index 000000000000..c2b2b75b14f2 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/issue_1823_opening_context_menu_when_switching_another_frame.js @@ -0,0 +1,76 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +context('Cannot read property label of undefined', () => { + const issueId = '1823'; + 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 = 10; + const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}`; + const width = 800; + const height = 800; + const posX = 10; + const posY = 10; + const color = 'gray'; + const archiveName = `${imageFileName}.zip`; + const archivePath = `cypress/fixtures/${archiveName}`; + const imagesFolder = `cypress/fixtures/${imageFileName}`; + const directoryToArchive = imagesFolder; + const advancedConfigurationParams = { + chunkSize: 1, + }; + + const createRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 250, + firstY: 350, + secondX: 350, + secondY: 450, + }; + + before(() => { + cy.visit('auth/login'); + cy.login(); + cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount); + cy.createZipArchive(directoryToArchive, archivePath); + }); + + after(() => { + cy.goToTaskList(); + cy.getTaskID(taskName).then(($taskID) => { + cy.deleteTask(taskName, $taskID); + }); + }); + + describe(`Testing "${labelName}"`, () => { + it('Create a task with chunk size === 1. Open the task.', () => { + cy.createAnnotationTask( + taskName, + labelName, + attrName, + textDefaultValue, + archiveName, + null, + advancedConfigurationParams, + ); + cy.openTaskJob(taskName); + }); + it('Create a shape on the first frame.', () => { + cy.createRectangle(createRectangleShape2Points); + }); + it('Go to another frame. During this procedure open context menu for a shape.', () => { + cy.get('body').type('f'); + cy.get('#cvat_canvas_shape_1').trigger('mousemove').rightclick(); + }); + it('Page with the error is missing', () => { + cy.get('.cvat-global-boundary').should('not.exist'); + }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 695007b3e51e..c4454500f0dd 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -116,12 +116,17 @@ Cypress.Commands.add('createRectangle', (createRectangleParams) => { }); Cypress.Commands.add('switchLabel', (labelName, objectType) => { - const pattern = `^(Draw new|Setup) ${objectType}$` - const regex = new RegExp(pattern, 'g'); - cy.contains(regex).parents('.cvat-draw-shape-popover-content').within(() => { - cy.get('.ant-select-selection-selected-value').click(); - }); - cy.get('.ant-select-dropdown').not('.ant-select-dropdown-hidden').contains(new RegExp(`^${labelName}$`, 'g')).click(); + const pattern = `^(Draw new|Setup) ${objectType}$`; + const regex = new RegExp(pattern, 'g'); + cy.contains(regex) + .parents('.cvat-draw-shape-popover-content') + .within(() => { + cy.get('.ant-select-selection-selected-value').click(); + }); + cy.get('.ant-select-dropdown') + .not('.ant-select-dropdown-hidden') + .contains(new RegExp(`^${labelName}$`, 'g')) + .click(); }); Cypress.Commands.add('checkObjectParameters', (objectParameters, objectType) => { @@ -236,7 +241,10 @@ Cypress.Commands.add('changeLabelAAM', (labelName) => { cy.get('.attribute-annotation-sidebar-basics-editor').within(() => { cy.get('.ant-select-selection').click(); }); - cy.get('.ant-select-dropdown').not('.ant-select-dropdown-hidden').contains(new RegExp(`^${labelName}$`, 'g')).click(); + cy.get('.ant-select-dropdown') + .not('.ant-select-dropdown-hidden') + .contains(new RegExp(`^${labelName}$`, 'g')) + .click(); } }); }); @@ -326,6 +334,9 @@ Cypress.Commands.add('advancedConfiguration', (advancedConfigurationParams) => { cy.get('#stopFrame').type(advancedConfigurationParams.stopFrame); cy.get('#frameStep').type(advancedConfigurationParams.frameStep); } + if (advancedConfigurationParams.chunkSize) { + cy.get('#dataChunkSize').type(advancedConfigurationParams.chunkSize); + } }); Cypress.Commands.add('removeAnnotations', () => { @@ -360,7 +371,9 @@ Cypress.Commands.add('addNewLabel', (newLabelName) => { Cypress.Commands.add('createTag', (labelName) => { cy.get('.cvat-setup-tag-control').click(); cy.switchLabel(labelName, 'tag'); - cy.contains('Setup tag').parents('.cvat-draw-shape-popover-content').within(() => { - cy.get('button').click(); - }); + cy.contains('Setup tag') + .parents('.cvat-draw-shape-popover-content') + .within(() => { + cy.get('button').click(); + }); });