-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check UI does not crash if to activate an object while frame fetching #7873
Check UI does not crash if to activate an object while frame fetching #7873
Conversation
WalkthroughRecent updates to the Cypress test suite for CVAT include the addition of regression tests for object activation during frame fetching and a new custom command, Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Out of diff range and nitpick comments (3)
tests/cypress/e2e/actions_objects/regression_tests.js (3)
7-7
: Consider removing the commented-out import statement if it's no longer needed.
37-43
: Setup block looks good. Consider parameterizing the image dimensions and positions for increased flexibility in future tests.
45-72
: The core test logic is sound and effectively simulates the condition being tested. Consider adding comments to explain the use ofcy.intercept
for delaying the network request, as it's crucial for understanding the test's intention.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/cypress/e2e/actions_objects/regression_tests.js (1 hunks)
Additional comments not posted (1)
tests/cypress/e2e/actions_objects/regression_tests.js (1)
75-78
: Cleanup block is appropriately implemented to ensure no residual data affects subsequent tests.
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, | ||
posY, labelName, imagesCount); | ||
cy.createZipArchive(directoryToArchive, archivePath, zipLevel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use headless function to create tasks in new tests whenever it is possible.
It is quicker and more reliable.
describe('Regression tests', () => { | ||
it('Object is not activated while frame fetching', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe('Regression tests', () => { | |
it('Object is not activated while frame fetching', () => { | |
describe('Regression tests', () => { | |
it('UI does not crash if to activate an object while frame fetching', () => { |
cy.get('.cvat-player-last-button').click(); | ||
cy.createRectangle(createRectangleShape2Points); | ||
cy.get('#cvat_canvas_shape_1').trigger('mousemove'); | ||
cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); | ||
cy.saveJob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will recommend to add objects in headless mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/cypress/e2e/actions_objects/regression_tests.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/cypress/e2e/actions_objects/regression_tests.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/cypress/e2e/actions_objects/regression_tests.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/cypress/e2e/actions_objects/regression_tests.js
|
||
/// <reference types="cypress" /> | ||
|
||
// import { taskName, labelName } from '../../support/const'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// import { taskName, labelName } from '../../support/const'; |
cy.headlessCreateTask(taskPayload, dataPayload).then((response) => { | ||
taskID = response.taskID; | ||
[jobID] = response.jobIDs; | ||
|
||
cy.visit(`/tasks/${taskID}/jobs/${jobID}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That has to be in before
function.
We do not test creating/opening a task here.
cy.get('.cvat-player-last-button').click(); | ||
cy.createRectangle(createRectangleShape2Points); | ||
cy.get('#cvat_canvas_shape_1').trigger('mousemove'); | ||
cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated'); | ||
cy.saveJob(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also should be in before
.
Additionally I will recommend to create annotations using headless method. Now we do not have such cypress command, but it would be nice to create and use in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
tests/mounted_file_share/bigArchive.zip
is excluded by!**/*.zip
Files selected for processing (2)
- tests/cypress/e2e/actions_objects/regression_tests.js (1 hunks)
- tests/cypress/support/commands.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/cypress/e2e/actions_objects/regression_tests.js
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(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper error handling for asynchronous operations.
The function does not handle potential errors that might occur during asynchronous operations such as fetching the job, clearing annotations, and saving annotations. Consider adding error handling to improve robustness.
Cypress.Commands.add('headlessCreateObject', (objects, jobID) => {
cy.window().then(async ($win) => {
try {
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();
} catch (error) {
console.error('Error creating objects:', error);
}
return cy.wrap();
});
});
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
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('headlessCreateObject', (objects, jobID) => { | |
cy.window().then(async ($win) => { | |
try { | |
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(); | |
} catch (error) { | |
console.error('Error creating objects:', error); | |
} | |
return cy.wrap(); | |
}); | |
}); |
Motivation and context
Test to check - object is not activated while frame fetching. Bug: #7834
How has this been tested?
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
headlessCreateObject
to facilitate object creation in jobs using CVAT annotations.