-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathissue_8952_interpolation_impossible.js
152 lines (135 loc) · 5.18 KB
/
issue_8952_interpolation_impossible.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright (C) CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
/// <reference types="cypress" />
import { translatePoints } from '../../support/utils';
const taskName = '5frames';
const labelName = 'label';
const attrName = 'attr1';
const textDefaultValue = 'Some text';
const issueId = '8952';
const imagesCount = 5;
const width = 400;
const height = 400;
const posX = 50;
const posY = 50;
const color = 'white';
const imageFileName = `image_${issueId}`;
const archiveName = `${imageFileName}.zip`;
const archivePath = `cypress/fixtures/${archiveName}`;
const imagesFolder = `cypress/fixtures/${imageFileName}`;
const rect = [
30,
30,
30 + 34,
30 + 23,
];
context('Create any track, check if track works correctly after deleting some frames', () => {
function readShapeCoords() {
return cy.get('.cvat_canvas_shape').then(($shape) => ({
x: +$shape.attr('x'),
y: +$shape.attr('y'),
}));
}
function validateShapeCoords({ x, y }) {
const precision = 0.01; // db server precision is 2 digits
cy.get('.cvat_canvas_shape').then(($shape) => {
const [xVal, yVal] = [
+$shape.attr('x'),
+$shape.attr('y'),
];
expect(xVal).to.be.closeTo(x, precision);
expect(yVal).to.be.closeTo(y, precision);
});
}
describe('Description: user error, Could not receive frame 43 No one left position or right position was found. Interpolation impossible', () => {
let jobID = null;
const delta = 300;
before(() => {
cy.visit('/auth/login');
cy.login();
// Create assets for task using nodeJS
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(imagesFolder, archivePath);
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName);
cy.goToTaskList();
cy.openTaskJob(taskName);
cy.url().should('contain', 'jobs').then((url) => {
const last = url.lastIndexOf('/');
jobID = parseInt(url.slice(last + 1), 10);
}).then(() => {
// Remove all annotations and draw a track rect
const points0 = rect;
const points1 = translatePoints(points0, delta, 'x');
const points2 = translatePoints(points1, delta, 'y');
const track = {
shapes: [
{
frame: 0,
type: 'rectangle',
points: points0,
},
{
frame: 2,
type: 'rectangle',
points: points1,
},
{
frame: 4,
type: 'rectangle',
points: points2,
},
],
frame: 0,
labelName,
objectType: 'track',
};
cy.headlessCreateObjects([track], jobID);
});
});
beforeEach(() => {
cy.headlessRestoreAllFrames(jobID);
// Get job meta updates from the server and reload page to bring changes to UI
cy.reload();
cy.saveJob();
cy.get('.cvat-player-first-button').click();
});
it('Delete interpolated frames 0, 2, 4. Error should not appear', () => {
// Delete frames 0, 2, 4. Watch out for errors
cy.get('.cvat-player-first-button').click();
cy.checkFrameNum(0);
cy.clickDeleteFrameAnnotationView();
cy.checkFrameNum(1);
cy.goToNextFrame(2);
cy.clickDeleteFrameAnnotationView();
cy.checkFrameNum(3);
cy.goToNextFrame(4);
cy.clickDeleteFrameAnnotationView();
// There should be no objects on the deleted frame
cy.get('.cvat_canvas_shape').should('not.exist');
cy.clickSaveAnnotationView();
// Reopening a task with bad metadata might throw an exception that we can catch
cy.goToTaskList();
cy.openTaskJob(taskName);
});
it('Change track positions on frames 2 and 4. Delete frame. Confirm same shape positions', () => {
cy.goCheckFrameNumber(2);
cy.clickDeleteFrameAnnotationView();
cy.checkFrameNum(3);
cy.clickSaveAnnotationView();
let pos3 = null;
readShapeCoords().then((posOnFrame3) => {
pos3 = posOnFrame3;
cy.goToPreviousFrame(1);
});
let pos1 = null;
readShapeCoords().then((posOnFrame1) => {
pos1 = posOnFrame1;
});
cy.reload().then(() => {
cy.goToNextFrame(1).then(() => validateShapeCoords(pos1));
cy.goToNextFrame(3).then(() => validateShapeCoords(pos3));
});
});
});
});