From f664ff385eb7921c9bc15f268496fe05befd50dd Mon Sep 17 00:00:00 2001 From: zaha Date: Tue, 26 Mar 2024 18:34:41 +0300 Subject: [PATCH 1/5] add test to check "remove underlying pixels" tool --- tests/cypress/e2e/features/masks_basics.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index 28b80e696520..1e920ecf0e35 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -158,6 +158,39 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { cy.drawMask(editingActions); cy.finishMaskDrawing(); }); + + it('Underlying pixels are removed on enabling "Remove underlying pixels" tool', () => { + const mask1 = [{ + method: 'brush', + coordinates: [[450, 250], [600, 400]], + }]; + const mask2 = [{ + method: 'brush', + coordinates: [[450, 250], [525, 325]], + }]; + + cy.startMaskDrawing(); + cy.drawMask(mask1); + cy.get('.cvat-brush-tools-continue').click(); + + cy.drawMask(mask2); + cy.get('.cvat-brush-tools-underlying-pixels').click(); + cy.get('.cvat-brush-tools-underlying-pixels').should('have.class', 'cvat-brush-tools-active-tool'); + cy.finishMaskDrawing(); + + cy.get('#cvat-objects-sidebar-state-item-2').within(() => { + cy.get('.cvat-object-item-button-hidden').click(); + }); + + cy.get('.cvat-canvas-container').then(([$canvas]) => { + cy.wrap($canvas).trigger('mousemove', { clientX: 450, clientY: 250, bubbles: true }); + cy.get('#cvat_canvas_shape_1').should('not.have.class', 'cvat_canvas_shape_activated'); + + cy.wrap($canvas).trigger('mousemove', { clientX: 550, clientY: 350, bubbles: true }); + cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); + }); + cy.removeAnnotations(); + }); }); describe('Tests to make sure that empty masks cannot be created', () => { From 81087906e979ec7bd87cead11d28734a670213ac Mon Sep 17 00:00:00 2001 From: zaha Date: Tue, 26 Mar 2024 19:37:27 +0300 Subject: [PATCH 2/5] click to active tool only if tool is inactive --- tests/cypress/e2e/features/masks_basics.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index 1e920ecf0e35..bf213466fc9f 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -282,7 +282,11 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { }]]; cy.startMaskDrawing(); - cy.get('.cvat-brush-tools-underlying-pixels').click(); + cy.get('.cvat-brush-tools-underlying-pixels').then(($el) => { + if (!$el.hasClass('cvat-brush-tools-active-tool')) { + cy.wrap($el).click(); + } + }); cy.get('.cvat-brush-tools-underlying-pixels').should('have.class', 'cvat-brush-tools-active-tool'); cy.finishMaskDrawing(); From be3728017aca89558d39d778aaefd6881c88a503 Mon Sep 17 00:00:00 2001 From: zaha Date: Wed, 27 Mar 2024 11:39:02 +0300 Subject: [PATCH 3/5] remove extra code --- tests/cypress/e2e/features/masks_basics.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index bf213466fc9f..ac3b4e9a44ca 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -183,13 +183,12 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { }); cy.get('.cvat-canvas-container').then(([$canvas]) => { - cy.wrap($canvas).trigger('mousemove', { clientX: 450, clientY: 250, bubbles: true }); + cy.wrap($canvas).trigger('mousemove', { clientX: 450, clientY: 250 }); cy.get('#cvat_canvas_shape_1').should('not.have.class', 'cvat_canvas_shape_activated'); - cy.wrap($canvas).trigger('mousemove', { clientX: 550, clientY: 350, bubbles: true }); + cy.wrap($canvas).trigger('mousemove', { clientX: 550, clientY: 350 }); cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); }); - cy.removeAnnotations(); }); }); From f4f219454fdc599c1f8bc550b5ff683593480eac Mon Sep 17 00:00:00 2001 From: zaha Date: Wed, 27 Mar 2024 12:09:40 +0300 Subject: [PATCH 4/5] disable tool after using --- tests/cypress/e2e/features/masks_basics.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index ac3b4e9a44ca..f59d7ffc2f9e 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -189,6 +189,11 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { cy.wrap($canvas).trigger('mousemove', { clientX: 550, clientY: 350 }); cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); }); + + cy.startMaskDrawing(); + cy.get('.cvat-brush-tools-underlying-pixels').click(); + cy.get('.cvat-brush-tools-underlying-pixels').should('have.class', 'cvat-brush-tools-active-tool'); + cy.finishMaskDrawing(); }); }); @@ -281,11 +286,7 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { }]]; cy.startMaskDrawing(); - cy.get('.cvat-brush-tools-underlying-pixels').then(($el) => { - if (!$el.hasClass('cvat-brush-tools-active-tool')) { - cy.wrap($el).click(); - } - }); + cy.get('.cvat-brush-tools-underlying-pixels').click(); cy.get('.cvat-brush-tools-underlying-pixels').should('have.class', 'cvat-brush-tools-active-tool'); cy.finishMaskDrawing(); From cd8bedcb8e582a2bc6f09d11a3bdfb0b3f0385a5 Mon Sep 17 00:00:00 2001 From: zaha Date: Wed, 27 Mar 2024 14:47:48 +0300 Subject: [PATCH 5/5] fix checking tool disabling --- tests/cypress/e2e/features/masks_basics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index f59d7ffc2f9e..035a6353be48 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -192,7 +192,7 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { cy.startMaskDrawing(); cy.get('.cvat-brush-tools-underlying-pixels').click(); - cy.get('.cvat-brush-tools-underlying-pixels').should('have.class', 'cvat-brush-tools-active-tool'); + cy.get('.cvat-brush-tools-underlying-pixels').should('not.have.class', 'cvat-brush-tools-active-tool'); cy.finishMaskDrawing(); }); });