From 6dce957d06e0953ccdd613c3bd90b995591ad834 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Wed, 2 Dec 2020 20:37:48 +0300 Subject: [PATCH 1/6] add test --- .../case_24_delete_unlock_lock_object.js | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js new file mode 100644 index 000000000000..8a0b098a33d9 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js @@ -0,0 +1,87 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName, labelName } from '../../support/const'; + +context('Delete unlock/lock object', () => { + const caseId = '24'; + + const createRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 100, + firstY: 100, + secondX: 300, + secondY: 300, + }; + + function lockObject() { + cy.get('div.cvat-objects-sidebar-state-item').within(() => { + cy.get('.cvat-object-item-button-lock').click(); + }); + }; + + function deleteObjectViaShortcut(shortcut) { + cy.get('.cvat-canvas-container') + .trigger('mousemove', createRectangleShape2Points.secondX - 10, createRectangleShape2Points.secondY - 10) // activate shape + .get('body') + .type(shortcut); + }; + + function deleteObjectViaGUI() { + cy.get('div.cvat-objects-sidebar-state-item').within(() => { + cy.get('i.ant-dropdown-trigger').click(); + }); + cy.get('ul.cvat-object-item-menu').within(() => { + cy.contains('Remove').click(); + }); + }; + + function confirmationToDelete() { + cy.get('.ant-modal-confirm').within(() => { + cy.contains('OK').click(); + }); + }; + + function checkExistObject() { + cy.get('rect.cvat_canvas_shape').should('not.exist'); + cy.get('div.cvat-objects-sidebar-state-item').should('not.exist'); + }; + + before(() => { + cy.openTaskJob(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Create and delete object via "Delete" shortcut', () => { + cy.createRectangle(createRectangleShape2Points); + deleteObjectViaShortcut('{del}'); + checkExistObject(); + }); + + it('Create and delete object via GUI', () => { + cy.createRectangle(createRectangleShape2Points); + deleteObjectViaGUI(); + checkExistObject(); + }); + + it('Create, lock and delete object via "Shift+Delete" shortcuts', () => { + cy.createRectangle(createRectangleShape2Points); + lockObject(); + deleteObjectViaShortcut('{shift}{del}'); + checkExistObject(); + }); + + it('Create, lock and delete object via GUI', () => { + cy.createRectangle(createRectangleShape2Points); + lockObject(); + deleteObjectViaGUI(); + confirmationToDelete(); + checkExistObject(); + }); + }); +}); From 733ba57a0b93d1611167da4025f22093e6e963f9 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Wed, 2 Dec 2020 20:58:19 +0300 Subject: [PATCH 2/6] add step checkFailDeleteLockObject --- .../case_24_delete_unlock_lock_object.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js index 8a0b098a33d9..1079b490d1b1 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js +++ b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js @@ -47,6 +47,13 @@ context('Delete unlock/lock object', () => { }); }; + function checkFailDeleteLockObject(shortcut) { + deleteObjectViaShortcut(shortcut); + cy.get('rect.cvat_canvas_shape').should('exist'); + cy.get('div.cvat-objects-sidebar-state-item').should('exist'); + cy.contains('.ant-notification-topRight', 'Error: Could not remove the locked object').should('exist'); + }; + function checkExistObject() { cy.get('rect.cvat_canvas_shape').should('not.exist'); cy.get('div.cvat-objects-sidebar-state-item').should('not.exist'); @@ -72,6 +79,7 @@ context('Delete unlock/lock object', () => { it('Create, lock and delete object via "Shift+Delete" shortcuts', () => { cy.createRectangle(createRectangleShape2Points); lockObject(); + checkFailDeleteLockObject('{del}'); deleteObjectViaShortcut('{shift}{del}'); checkExistObject(); }); From 70b67ccdca920eb1db9081ab8d1419a1d4b89c46 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Thu, 3 Dec 2020 16:39:18 +0300 Subject: [PATCH 3/6] improvements test --- .../case_24_delete_unlock_lock_object.js | 95 +++++++++++++------ 1 file changed, 67 insertions(+), 28 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js index 1079b490d1b1..e070a6d73057 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js +++ b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js @@ -20,43 +20,74 @@ context('Delete unlock/lock object', () => { }; function lockObject() { - cy.get('div.cvat-objects-sidebar-state-item').within(() => { + cy.get('.cvat-objects-sidebar-state-item').within(() => { cy.get('.cvat-object-item-button-lock').click(); }); }; - function deleteObjectViaShortcut(shortcut) { - cy.get('.cvat-canvas-container') - .trigger('mousemove', createRectangleShape2Points.secondX - 10, createRectangleShape2Points.secondY - 10) // activate shape - .get('body') + function deleteObjectViaShortcut(shortcut, stateLockObject) { + if (stateLockObject == 'unlock') { + cy.get('.cvat-canvas-container').within(() => { + cy.get('.cvat_canvas_shape') + .trigger('mousemove') + .should('have.class', 'cvat_canvas_shape_activated'); + }); + }; + cy.get('body') .type(shortcut); }; - function deleteObjectViaGUI() { - cy.get('div.cvat-objects-sidebar-state-item').within(() => { - cy.get('i.ant-dropdown-trigger').click(); + function clickRemoveOnDropdownMenu() { + cy.get('.ant-dropdown') + .not('.ant-dropdown-hidden') + .contains(new RegExp('^Remove$', 'g')) + .click({ force: true }); + }; + + function deleteObjectViaGUIFromSidebar() { + cy.get('.cvat-objects-sidebar-states-list').within(() => { + cy.get('.cvat-objects-sidebar-state-item').within(() => { + cy.get('[aria-label="icon: more"]').click(); + }); }); - cy.get('ul.cvat-object-item-menu').within(() => { - cy.contains('Remove').click(); + clickRemoveOnDropdownMenu(); + }; + + function deleteObjectViaGUIFromObject() { + cy.get('.cvat-canvas-container').within(() => { + cy.get('.cvat_canvas_shape') + .trigger('mousemove') + .rightclick(); }); + cy.get('.cvat-canvas-context-menu').within(() => { + cy.get('.cvat-objects-sidebar-state-item').within(() => { + cy.get('[aria-label="icon: more"]').click(); + }); + }); + clickRemoveOnDropdownMenu(); }; - function confirmationToDelete() { + function actionOnConfirmWindow(textBuntton) { cy.get('.ant-modal-confirm').within(() => { - cy.contains('OK').click(); + cy.contains(new RegExp(`^${textBuntton}$`, 'g')) + .click(); }); }; function checkFailDeleteLockObject(shortcut) { - deleteObjectViaShortcut(shortcut); - cy.get('rect.cvat_canvas_shape').should('exist'); - cy.get('div.cvat-objects-sidebar-state-item').should('exist'); - cy.contains('.ant-notification-topRight', 'Error: Could not remove the locked object').should('exist'); + deleteObjectViaShortcut(shortcut, 'lock'); + checkExistObject(); + cy.get('.ant-notification-topRight').should('exist'); }; function checkExistObject() { - cy.get('rect.cvat_canvas_shape').should('not.exist'); - cy.get('div.cvat-objects-sidebar-state-item').should('not.exist'); + cy.get('.cvat_canvas_shape').should('exist'); + cy.get('.cvat-objects-sidebar-state-item').should('exist'); + }; + + function checkNotExistObject() { + cy.get('.cvat_canvas_shape').should('not.exist'); + cy.get('.cvat-objects-sidebar-state-item').should('not.exist'); }; before(() => { @@ -66,29 +97,37 @@ context('Delete unlock/lock object', () => { describe(`Testing case "${caseId}"`, () => { it('Create and delete object via "Delete" shortcut', () => { cy.createRectangle(createRectangleShape2Points); - deleteObjectViaShortcut('{del}'); - checkExistObject(); + deleteObjectViaShortcut('{del}', 'unlock'); + checkNotExistObject(); }); - it('Create and delete object via GUI', () => { + it('Create and delete object via GUI from sidebar', () => { cy.createRectangle(createRectangleShape2Points); - deleteObjectViaGUI(); - checkExistObject(); + deleteObjectViaGUIFromSidebar(); + checkNotExistObject(); }); it('Create, lock and delete object via "Shift+Delete" shortcuts', () => { cy.createRectangle(createRectangleShape2Points); lockObject(); checkFailDeleteLockObject('{del}'); - deleteObjectViaShortcut('{shift}{del}'); - checkExistObject(); + deleteObjectViaShortcut('{shift}{del}', 'lock'); + checkNotExistObject(); + }); + + it('Create, lock and delete object via GUI from sidebar', () => { + cy.createRectangle(createRectangleShape2Points); + lockObject(); + deleteObjectViaGUIFromSidebar(); + actionOnConfirmWindow('OK'); + checkNotExistObject(); }); - it('Create, lock and delete object via GUI', () => { + it('Create, lock and cancel delete object via GUI from object', () => { cy.createRectangle(createRectangleShape2Points); lockObject(); - deleteObjectViaGUI(); - confirmationToDelete(); + deleteObjectViaGUIFromObject(); + actionOnConfirmWindow('Cancel'); checkExistObject(); }); }); From 127e1ca37bb90fafc80724c068353613ca5cd1f7 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Thu, 3 Dec 2020 17:03:27 +0300 Subject: [PATCH 4/6] merge checkExistObject and checkNotExistObject functions --- .../case_24_delete_unlock_lock_object.js | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js index e070a6d73057..394dd3afe4fa 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js +++ b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js @@ -76,18 +76,13 @@ context('Delete unlock/lock object', () => { function checkFailDeleteLockObject(shortcut) { deleteObjectViaShortcut(shortcut, 'lock'); - checkExistObject(); + checkExistObject('exist'); cy.get('.ant-notification-topRight').should('exist'); }; - function checkExistObject() { - cy.get('.cvat_canvas_shape').should('exist'); - cy.get('.cvat-objects-sidebar-state-item').should('exist'); - }; - - function checkNotExistObject() { - cy.get('.cvat_canvas_shape').should('not.exist'); - cy.get('.cvat-objects-sidebar-state-item').should('not.exist'); + function checkExistObject(state) { + cy.get('.cvat_canvas_shape').should(state); + cy.get('.cvat-objects-sidebar-state-item').should(state); }; before(() => { @@ -98,13 +93,13 @@ context('Delete unlock/lock object', () => { it('Create and delete object via "Delete" shortcut', () => { cy.createRectangle(createRectangleShape2Points); deleteObjectViaShortcut('{del}', 'unlock'); - checkNotExistObject(); + checkExistObject('not.exist'); }); it('Create and delete object via GUI from sidebar', () => { cy.createRectangle(createRectangleShape2Points); deleteObjectViaGUIFromSidebar(); - checkNotExistObject(); + checkExistObject('not.exist'); }); it('Create, lock and delete object via "Shift+Delete" shortcuts', () => { @@ -112,7 +107,7 @@ context('Delete unlock/lock object', () => { lockObject(); checkFailDeleteLockObject('{del}'); deleteObjectViaShortcut('{shift}{del}', 'lock'); - checkNotExistObject(); + checkExistObject('not.exist'); }); it('Create, lock and delete object via GUI from sidebar', () => { @@ -120,7 +115,7 @@ context('Delete unlock/lock object', () => { lockObject(); deleteObjectViaGUIFromSidebar(); actionOnConfirmWindow('OK'); - checkNotExistObject(); + checkExistObject('not.exist'); }); it('Create, lock and cancel delete object via GUI from object', () => { @@ -128,7 +123,7 @@ context('Delete unlock/lock object', () => { lockObject(); deleteObjectViaGUIFromObject(); actionOnConfirmWindow('Cancel'); - checkExistObject(); + checkExistObject('exist'); }); }); }); From ddb225da0443f730a8c3072dfb59aaacf95e9e58 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Mon, 7 Dec 2020 14:28:01 +0300 Subject: [PATCH 5/6] add className for elements --- cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- .../objects-side-bar/object-item-menu.tsx | 1 + cvat-ui/src/components/cvat-app.tsx | 6 ++++-- cvat-ui/src/reducers/interfaces.ts | 1 + cvat-ui/src/reducers/notifications-reducer.ts | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 45c2f0f475cc..54519190334f 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.11.5", + "version": "1.11.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index b3f718c574ab..71d8290ae124 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.11.5", + "version": "1.11.6", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-menu.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-menu.tsx index 9f88ae43cec5..77efbdf3d75d 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-menu.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item-menu.tsx @@ -200,6 +200,7 @@ function RemoveItem(props: ItemProps): JSX.Element { onClick={(): void => { if (locked) { Modal.confirm({ + className: 'cvat-modal-confirm', title: 'Object is locked', content: 'Are you sure you want to remove it?', onOk() { diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index b3c742cd9862..7e361bdf71e1 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -187,9 +187,11 @@ class CVATApplication extends React.PureComponent Date: Mon, 7 Dec 2020 14:28:37 +0300 Subject: [PATCH 6/6] change cssLocators for find elements --- .../case_24_delete_unlock_lock_object.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js index 394dd3afe4fa..6b8d148d381f 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js +++ b/tests/cypress/integration/actions_tasks_objects/case_24_delete_unlock_lock_object.js @@ -38,8 +38,7 @@ context('Delete unlock/lock object', () => { }; function clickRemoveOnDropdownMenu() { - cy.get('.ant-dropdown') - .not('.ant-dropdown-hidden') + cy.get('.cvat-object-item-menu') .contains(new RegExp('^Remove$', 'g')) .click({ force: true }); }; @@ -68,7 +67,7 @@ context('Delete unlock/lock object', () => { }; function actionOnConfirmWindow(textBuntton) { - cy.get('.ant-modal-confirm').within(() => { + cy.get('.cvat-modal-confirm').within(() => { cy.contains(new RegExp(`^${textBuntton}$`, 'g')) .click(); }); @@ -77,7 +76,7 @@ context('Delete unlock/lock object', () => { function checkFailDeleteLockObject(shortcut) { deleteObjectViaShortcut(shortcut, 'lock'); checkExistObject('exist'); - cy.get('.ant-notification-topRight').should('exist'); + cy.get('.cvat-notification-notice-remove-object-failed').should('exist'); }; function checkExistObject(state) {