Skip to content

Commit

Permalink
Check UI does not crash if to activate an object while frame fetching (
Browse files Browse the repository at this point in the history
  • Loading branch information
novda committed May 16, 2024
1 parent f4ee3f9 commit 39c2063
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
85 changes: 85 additions & 0 deletions tests/cypress/e2e/actions_objects/regression_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (C) 2024 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

context('Regression tests', () => {
let taskID = null;
let jobID = null;

const taskPayload = {
name: 'Test annotations actions',
labels: [{
name: 'label 1',
attributes: [],
type: 'any',
}],
project_id: null,
source_storage: { location: 'local' },
target_storage: { location: 'local' },
};

const dataPayload = {
server_files: ['bigArchive.zip'],
image_quality: 70,
use_zip_chunks: true,
use_cache: true,
sorting_method: 'lexicographical',
};

const rectanglePayload = {
frame: 99,
objectType: 'SHAPE',
shapeType: 'RECTANGLE',
points: [250, 64, 491, 228],
occluded: false,
};

before(() => {
cy.visit('auth/login');
cy.login();

cy.headlessCreateTask(taskPayload, dataPayload).then((response) => {
taskID = response.taskID;
[jobID] = response.jobIDs;

cy.headlessCreateObject([rectanglePayload], jobID);
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
});
});

describe('Regression tests', () => {
it('UI does not crash if to activate an object while frame fetching', () => {
cy.reload();
cy.get('.cvat-player-last-button').click();

cy.intercept('GET', '/api/jobs/**/data?**', (req) => {
req.continue((res) => {
res.setDelay(1000);
});
}).as('delayedRequest');

cy.get('#cvat_canvas_shape_1').trigger('mousemove');
cy.get('#cvat_canvas_shape_1').should('not.have.class', 'cvat_canvas_shape_activated');

cy.wait('@delayedRequest');
cy.get('#cvat_canvas_shape_1').trigger('mousemove');
cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated');
});
});

after(() => {
cy.logout();
cy.getAuthKey().then((response) => {
const authKey = response.body.key;
cy.request({
method: 'DELETE',
url: `/api/tasks/${taskID}`,
headers: {
Authorization: `Token ${authKey}`,
},
});
});
});
});
23 changes: 23 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,29 @@ Cypress.Commands.add('headlessLogin', (username = Cypress.env('user'), password
});
});

Cypress.Commands.add('headlessCreateObject', (objects, jobID) => {
cy.window().then(async ($win) => {
const job = (await $win.cvat.jobs.get({ jobID }))[0];
await job.annotations.clear(true);

const objectStates = objects
.map((object) => new $win.cvat.classes
.ObjectState({
frame: object.frame,
objectType: $win.cvat.enums.ObjectType[object.objectType],
shapeType: $win.cvat.enums.ShapeType[object.shapeType],
points: $win.Array.from(object.points),
occluded: object.occluded,
label: job.labels[0],
zOrder: 0,
}));

await job.annotations.put($win.Array.from(objectStates));
await job.annotations.save();
return cy.wrap();
});
});

Cypress.Commands.add('headlessCreateTask', (taskSpec, dataSpec) => {
cy.window().then(async ($win) => {
const task = new $win.cvat.classes.Task({
Expand Down
Binary file added tests/mounted_file_share/bigArchive.zip
Binary file not shown.

0 comments on commit 39c2063

Please sign in to comment.