Skip to content
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

Merged

Conversation

novda
Copy link
Member

@novda novda commented May 10, 2024

Motivation and context

Test to check - object is not activated while frame fetching. Bug: #7834

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • Tests
    • Added regression tests for object activation during frame fetching in the CVAT environment.
    • Introduced a new Cypress command headlessCreateObject to facilitate object creation in jobs using CVAT annotations.

@novda novda requested a review from bsekachev May 10, 2024 09:44
@novda novda requested a review from azhavoro as a code owner May 10, 2024 09:44
Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

Recent 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, headlessCreateObject, for creating annotation objects in a headless mode. These changes enhance the robustness and flexibility of automated testing for CVAT functionalities.

Changes

File Path Change Summary
tests/cypress/e2e/actions_objects/regression_tests.js Added regression tests for object activation during frame fetching in CVAT.
tests/cypress/support/commands.js Introduced a new Cypress command headlessCreateObject to facilitate object creation in a job using CVAT annotations.

🐇
In the land of code, where tests do run,
New commands and checks have just begun.
Headless objects now take flight,
Ensuring all functions work just right.
With frames fetched and objects set,
CVAT’s future is bright, you bet!
🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 of cy.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

Commits Files that changed from the base of the PR and between 899735d and 8570a1e.
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.

Comment on lines 40 to 42
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX,
posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath, zipLevel);
Copy link
Member

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.

Comment on lines 45 to 46
describe('Regression tests', () => {
it('Object is not activated while frame fetching', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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', () => {

Comment on lines 51 to 55
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();
Copy link
Member

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

@novda novda changed the title Check object is not activated while frame fetching Check UI does not crash if to activate an object while frame fetching May 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 8570a1e and a2c9595.
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

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between a2c9595 and 884526b.
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// import { taskName, labelName } from '../../support/const';

Comment on lines 50 to 54
cy.headlessCreateTask(taskPayload, dataPayload).then((response) => {
taskID = response.taskID;
[jobID] = response.jobIDs;

cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
Copy link
Member

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.

Comment on lines 56 to 60
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();
Copy link
Member

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 884526b and 4b1d64b.
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

Comment on lines +268 to +289
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();
});
});
Copy link
Contributor

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.

Suggested change
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();
});
});

@bsekachev bsekachev merged commit 39c2063 into cvat-ai:develop May 16, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants