Skip to content

Commit

Permalink
Regression test for UI crash when navigation during resize (#8615)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Oct 30, 2024
1 parent 9ecafb6 commit 4dd7f22
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 77 deletions.
4 changes: 4 additions & 0 deletions tests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

const { defineConfig } = require('cypress');
const baseConfig = require('./cypress.base.config');

Expand Down
67 changes: 44 additions & 23 deletions tests/cypress/e2e/actions_objects/regression_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}],
Expand All @@ -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(() => {
Expand All @@ -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}`,
},
});
});
});
});
6 changes: 6 additions & 0 deletions tests/cypress/e2e/features/masks_basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions tests/cypress_canvas3d.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

const { defineConfig } = require('cypress');
const baseConfig = require('./cypress.base.config');

Expand Down

0 comments on commit 4dd7f22

Please sign in to comment.