From 4dd7f2207dd6b1933eaa0e4c9c36df12db55d19f Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 30 Oct 2024 15:16:26 +0200 Subject: [PATCH] Regression test for UI crash when navigation during resize (#8615) --- tests/cypress.config.js | 4 ++ .../e2e/actions_objects/regression_tests.js | 67 ++++++++++++------- tests/cypress/e2e/features/masks_basics.js | 6 ++ ..._error_canvas_is_busy_at_resize_element.js | 54 --------------- tests/cypress_canvas3d.config.js | 4 ++ 5 files changed, 58 insertions(+), 77 deletions(-) delete mode 100644 tests/cypress/e2e/issues_prs/issue_1922_error_canvas_is_busy_at_resize_element.js diff --git a/tests/cypress.config.js b/tests/cypress.config.js index da1f20d8dee..17f157c59c8 100644 --- a/tests/cypress.config.js +++ b/tests/cypress.config.js @@ -1,3 +1,7 @@ +// Copyright (C) 2024 CVAT.ai Corporation +// +// SPDX-License-Identifier: MIT + const { defineConfig } = require('cypress'); const baseConfig = require('./cypress.base.config'); diff --git a/tests/cypress/e2e/actions_objects/regression_tests.js b/tests/cypress/e2e/actions_objects/regression_tests.js index 8cf00b90e0c..7bf11c7b0d7 100644 --- a/tests/cypress/e2e/actions_objects/regression_tests.js +++ b/tests/cypress/e2e/actions_objects/regression_tests.js @@ -9,9 +9,9 @@ context('Regression tests', () => { let jobID = null; const taskPayload = { - name: 'Test annotations actions', + name: 'Regression tests', labels: [{ - name: 'label 1', + name: 'car', attributes: [], type: 'any', }], @@ -29,12 +29,9 @@ context('Regression tests', () => { }; const rectanglePayload = { - frame: 99, - objectType: 'shape', shapeType: 'rectangle', - points: [250, 64, 491, 228], occluded: false, - labelName: 'label 1', + labelName: taskPayload.labels[0].name, }; before(() => { @@ -45,41 +42,65 @@ context('Regression tests', () => { taskID = response.taskID; [jobID] = response.jobIDs; - cy.headlessCreateObjects([rectanglePayload], jobID); - cy.visit(`/tasks/${taskID}/jobs/${jobID}`); + cy.headlessCreateObjects([ + { + ...rectanglePayload, frame: 99, points: [250, 64, 491, 228], objectType: 'shape', + }, + { + ...rectanglePayload, frame: 0, points: [10, 10, 30, 30], objectType: 'track', + }, + ], jobID); }); }); - describe('Regression tests', () => { + describe('UI does not crash', () => { + beforeEach(() => { + cy.visit(`/tasks/${taskID}/jobs/${jobID}`); + cy.get('.cvat-canvas-container').should('not.exist'); + cy.get('.cvat-canvas-container').should('exist').and('be.visible'); + }); + it('UI does not crash if to activate an object while frame fetching', () => { - cy.reload(); cy.intercept('GET', '/api/jobs/**/data?**', (req) => { req.continue((res) => { - res.setDelay(1000); + res.setDelay(3000); }); }).as('delayedRequest'); + cy.get('.cvat-player-last-button').click(); - cy.get('#cvat_canvas_shape_1').trigger('mousemove'); - cy.get('#cvat_canvas_shape_1').should('not.have.class', 'cvat_canvas_shape_activated'); + cy.get('#cvat-objects-sidebar-state-item-1').trigger('mousemove'); + cy.get('#cvat-objects-sidebar-state-item-1').should('not.have.class', 'cvat-objects-sidebar-state-active-item'); cy.wait('@delayedRequest'); cy.get('#cvat_canvas_shape_1').trigger('mousemove'); cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); }); + + it('UI does not crash if to navigate during an element resizing (issue 1922)', { scrollBehavior: false }, () => { + cy.get('#cvat_canvas_shape_2').then(([el]) => { + const rect = el.getBoundingClientRect(); + + cy.get('body').trigger('mousemove', rect.x + rect.width / 2, rect.y + rect.height / 2); + cy.get('#cvat_canvas_shape_2').should('have.class', 'cvat_canvas_shape_activated'); + + cy.get('body').trigger('mousedown', rect.right, rect.bottom, { button: 0 }); + cy.get('body').trigger('mousemove', rect.right + 100, rect.bottom + 100); + + cy.get('body').type('f'); // go to next frame + cy.get('body').trigger('mouseup'); + + // Page with the error is missing + cy.get('.cvat-global-boundary').should('not.exist'); + cy.checkFrameNum(0); + }); + }); }); after(() => { + if (taskID !== null) { + cy.headlessDeleteTask(taskID); + } cy.logout(); - cy.getAuthKey().then((response) => { - const authKey = response.body.key; - cy.request({ - method: 'DELETE', - url: `/api/tasks/${taskID}`, - headers: { - Authorization: `Token ${authKey}`, - }, - }); - }); }); }); diff --git a/tests/cypress/e2e/features/masks_basics.js b/tests/cypress/e2e/features/masks_basics.js index b39d6ea769d..3e119e97f03 100644 --- a/tests/cypress/e2e/features/masks_basics.js +++ b/tests/cypress/e2e/features/masks_basics.js @@ -156,6 +156,12 @@ context('Manipulations with masks', { scrollBehavior: false }, () => { cy.interactAnnotationObjectMenu('#cvat-objects-sidebar-state-item-1', 'Edit'); cy.drawMask(editingActions); + + // Check issue fixed in https://github.com/cvat-ai/cvat/pull/8598 + // Frames navigation should not work during editing + cy.get('.cvat-player-next-button').click(); + cy.checkFrameNum(0); + cy.finishMaskDrawing(); }); diff --git a/tests/cypress/e2e/issues_prs/issue_1922_error_canvas_is_busy_at_resize_element.js b/tests/cypress/e2e/issues_prs/issue_1922_error_canvas_is_busy_at_resize_element.js deleted file mode 100644 index 53b5606f457..00000000000 --- a/tests/cypress/e2e/issues_prs/issue_1922_error_canvas_is_busy_at_resize_element.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2020-2022 Intel Corporation -// Copyright (C) 2023 CVAT.ai Corporation -// -// SPDX-License-Identifier: MIT - -/// - -import { taskName, labelName } from '../../support/const'; - -context('Check error canvas is busy at resize element', () => { - const issueId = '1922'; - const createRectangleShape2Points = { - points: 'By 2 Points', - type: 'Shape', - labelName, - firstX: 100, - firstY: 100, - secondX: 300, - secondY: 300, - }; - - before(() => { - cy.openTaskJob(taskName); - }); - - describe(`Testing issue "${issueId}"`, () => { - it('Create an object in first frame', () => { - cy.createRectangle(createRectangleShape2Points); - }); - - it('Go to next frame and create an object in second frame', () => { - cy.get('.cvat-player-next-button').click(); - cy.createRectangle(createRectangleShape2Points); - }); - - it('Switching mode of button on "back with a filter"', () => { - cy.get('.cvat-player-previous-button').rightclick(); - cy.get('.cvat-player-previous-filtered-inlined-button').click(); - }); - - it('Resize element on second frame and go to previous frame at resizing element', () => { - const { secondX, secondY } = createRectangleShape2Points; - cy.get('.cvat-canvas-container').trigger('mousemove', secondX - 10, secondY - 10); // activate second shape - cy.get('.cvat-canvas-container').trigger('mousedown', secondX, secondY, { button: 0 }); - cy.get('.cvat-canvas-container').trigger('mousemove', secondX + 100, secondY + 100); - cy.get('body').type('d'); // go to previous frame - cy.get('body').trigger('mouseup'); - }); - - it('Page with the error is missing', () => { - cy.get('.cvat-global-boundary').should('not.exist'); - }); - }); -}); diff --git a/tests/cypress_canvas3d.config.js b/tests/cypress_canvas3d.config.js index e1cd5ede69f..f542fe78bde 100644 --- a/tests/cypress_canvas3d.config.js +++ b/tests/cypress_canvas3d.config.js @@ -1,3 +1,7 @@ +// Copyright (C) 2024 CVAT.ai Corporation +// +// SPDX-License-Identifier: MIT + const { defineConfig } = require('cypress'); const baseConfig = require('./cypress.base.config');