Skip to content

Commit

Permalink
Added e2e test to check export hash (#6532)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
Depends on #6529

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [x] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
bsekachev authored Jul 21, 2023
1 parent fea0dae commit ded24ad
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 109 deletions.
8 changes: 4 additions & 4 deletions tests/cypress/e2e/actions_objects/case_37_object_make_copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ context('Object make a copy.', () => {
const createEllipseShape = {
type: 'Shape',
labelName,
cx: 550,
cy: 100,
rightX: 600,
topY: 150,
firstX: 550,
firstY: 100,
secondX: 600,
secondY: 150,
};
const countObject = 6;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@ context('Actions on ellipse.', () => {
const createEllipseShape = {
type: 'Shape',
labelName,
cx: 250,
cy: 350,
rightX: 450,
topY: 280,
firstX: 250,
firstY: 350,
secondX: 450,
secondY: 280,
};
const createEllipseTrack = {
type: 'Track',
labelName,
cx: createEllipseShape.cx,
cy: createEllipseShape.cy - 150,
rightX: createEllipseShape.rightX,
topY: createEllipseShape.topY - 150,
firstX: createEllipseShape.firstX,
firstY: createEllipseShape.firstY - 150,
secondX: createEllipseShape.secondX,
secondY: createEllipseShape.secondY - 150,
};
const createEllipseShapeSwitchLabel = {
type: 'Shape',
labelName: newLabelName,
cx: createEllipseShape.cx + 250,
cy: createEllipseShape.cy,
rightX: createEllipseShape.rightX + 250,
topY: createEllipseShape.topY,
firstX: createEllipseShape.firstX + 250,
firstY: createEllipseShape.firstY,
secondX: createEllipseShape.secondX + 250,
secondY: createEllipseShape.secondY,
};
const createEllipseTrackSwitchLabel = {
type: 'Track',
labelName: newLabelName,
cx: createEllipseShape.cx + 250,
cy: createEllipseShape.cy - 150,
rightX: createEllipseShape.rightX + 250,
topY: createEllipseShape.topY - 150,
firstX: createEllipseShape.firstX + 250,
firstY: createEllipseShape.firstY - 150,
secondX: createEllipseShape.secondX + 250,
secondY: createEllipseShape.secondY - 150,
};

function testCompareRotate(shape, toFrame) {
Expand Down
205 changes: 205 additions & 0 deletions tests/cypress/e2e/actions_tasks2/test_annotations_export_hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

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

context('Test export hash when saving annotations', () => {
const taskName = 'Test export hash when saving annotations';
const serverFiles = {
images: ['image_1.jpg', 'image_2.jpg', 'image_3.jpg'],
};

const generalLabel = {
name: 'test label',
};

const skeletonLabel = {
name: 'skeleton',
points: [
{ x: 0.55, y: 0.15 },
{ x: 0.20, y: 0.35 },
{ x: 0.43, y: 0.55 },
{ x: 0.63, y: 0.38 },
{ x: 0.27, y: 0.15 },
],
};

let taskID = null;
let jobID = null;

before(() => {
cy.headlessLogin();
cy.visit('/tasks/create');
cy.get('#name').type(taskName);
cy.addNewLabel({ name: generalLabel.name });
cy.addNewSkeletonLabel(skeletonLabel);
cy.selectFilesFromShare(serverFiles);
cy.intercept('POST', '/api/tasks**').as('createTaskRequest');
cy.intercept('GET', '/api/jobs**').as('getJobsRequest');
cy.contains('button', 'Submit & Continue').click();
cy.wait('@createTaskRequest').then((interception) => {
expect(interception.response.statusCode).to.equal(201);
taskID = interception.response.body.id;
});
cy.wait('@getJobsRequest').then((interception) => {
expect(interception.response.statusCode).to.equal(200);
jobID = interception.response.body.results[0].id;
});
});

describe('Check saving twice', () => {
it('Saving twice different shapes', () => {
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
cy.get('.cvat-canvas-container').should('exist').and('be.visible');

cy.createRectangle({
points: 'By 2 Points',
type: 'Shape',
labelName: generalLabel.name,
firstX: 150,
firstY: 350,
secondX: 200,
secondY: 400,
});

cy.createRectangle({
points: 'By 2 Points',
type: 'Track',
labelName: generalLabel.name,
firstX: 200,
firstY: 400,
secondX: 250,
secondY: 450,
});

cy.createEllipse({
type: 'Shape',
labelName: generalLabel.name,
firstX: 150,
firstY: 350,
secondX: 200,
secondY: 400,
});

cy.createEllipse({
type: 'Track',
labelName: generalLabel.name,
firstX: 200,
firstY: 400,
secondX: 250,
secondY: 450,
});

cy.createPolygon({
reDraw: false,
type: 'Shape',
labelName: generalLabel.name,
pointsMap: [
{ x: 200, y: 350 },
{ x: 250, y: 350 },
{ x: 250, y: 400 },
{ x: 200, y: 400 },
],
complete: true,
numberOfPoints: null,
});

cy.createPolygon({
reDraw: false,
type: 'Track',
labelName: generalLabel.name,
pointsMap: [
{ x: 150, y: 400 },
{ x: 200, y: 400 },
{ x: 200, y: 450 },
{ x: 150, y: 450 },
],
complete: true,
numberOfPoints: null,
});

cy.createSkeleton({
xtl: 150,
ytl: 350,
xbr: 200,
ybr: 400,
labelName: skeletonLabel.name,
type: 'Shape',
});

cy.createSkeleton({
xtl: 200,
ytl: 400,
xbr: 250,
ybr: 450,
labelName: skeletonLabel.name,
type: 'Track',
});

cy.createTag(generalLabel.name);

cy.intercept('PATCH', `/api/jobs/${jobID}/annotations**action=create**`).as('createJobAnnotations');
cy.intercept('PATCH', `/api/jobs/${jobID}/annotations**action=update`).as('updateJobAnnotations');
cy.intercept('PATCH', `/api/jobs/${jobID}/annotations**action=delete`).as('deleteJobAnnotations');

cy.saveJob();
cy.wait('@createJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(4);
expect(shapes.length).to.be.equal(4);
expect(tags.length).to.be.equal(1);
});

cy.wait('@updateJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(0);
expect(shapes.length).to.be.equal(0);
expect(tags.length).to.be.equal(0);
});

cy.wait('@deleteJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(0);
expect(shapes.length).to.be.equal(0);
expect(tags.length).to.be.equal(0);
});

cy.saveJob();
cy.wait('@createJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(0);
expect(shapes.length).to.be.equal(0);
expect(tags.length).to.be.equal(0);
});

cy.wait('@updateJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(0);
expect(shapes.length).to.be.equal(0);
expect(tags.length).to.be.equal(0);
});

cy.wait('@deleteJobAnnotations').then((interception) => {
const { shapes, tags, tracks } = interception.response.body;
expect(tracks.length).to.be.equal(0);
expect(shapes.length).to.be.equal(0);
expect(tags.length).to.be.equal(0);
});
});
});

after(() => {
cy.logout();
cy.getAuthKey().then((response) => {
const authKey = response.body.key;
cy.request({
method: 'DELETE',
url: `/api/tasks/${taskID}`,
headers: {
Authorization: `Token ${authKey}`,
},
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ context('Filters functionality.', () => {
const createEllipseTrack = {
type: 'Track',
labelName: labelTrack,
cx: 250,
cy: 350,
rightX: 450,
topY: 280,
firstX: 250,
firstY: 350,
secondX: 450,
secondY: 280,
};

const cvatCanvasShapeList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ context('Annotations statistics.', () => {
const createEllipseShape = {
type: 'Shape',
labelName,
cx: 400,
cy: 400,
rightX: 500,
topY: 350,
firstX: 400,
firstY: 400,
secondX: 500,
secondY: 350,
};
const createEllipseTrack = {
type: 'Track',
labelName,
cx: createEllipseShape.cx,
cy: createEllipseShape.cy - 150,
rightX: createEllipseShape.rightX,
topY: createEllipseShape.topY - 150,
firstX: createEllipseShape.firstX,
firstY: createEllipseShape.firstY - 150,
secondX: createEllipseShape.secondX,
secondY: createEllipseShape.secondY - 150,
};
const createCuboidShape2Points = {
points: 'From rectangle',
Expand Down
Loading

0 comments on commit ded24ad

Please sign in to comment.